IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

how to check A string contains string B


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bharat_juneja

New User


Joined: 21 Dec 2005
Posts: 20
Location: US

PostPosted: Wed Apr 05, 2006 10:25 pm
Reply with quote

I have a file which has the first name let's say FNAME pic x(12)
which needs to be match with the name in file FullName pic x(25).
This fullName is a combination of first name and last name logically but its not physically divided in 2 parts of first name and last name.

Problem:-
FNAME contains a string/name say Bharat
and FullName contains Bharat Juneja.

I need to check that :
1) FullName contains Fname
OR
2) The part of FullName from beginning of the string till the first space encounters i.e. before the last name starts should match with the FNAME in the first file.

I hope its clear. Please ask if you need any clarifications.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Apr 05, 2006 10:43 pm
Reply with quote

bharat_juneja,

A question.

if fullname contains

' Bharat Juneja' (space preceeds Bharat)
'Bharati Juneja' (additional letter added to Bharat)
'Juneja Bharat' (first name follows last name seperated by space)
'Juneja,Bharat' (first name follows last name seperated by comma)

Do you want these found or not

Thans,

Dave
Back to top
View user's profile Send private message
bharat_juneja

New User


Joined: 21 Dec 2005
Posts: 20
Location: US

PostPosted: Wed Apr 05, 2006 11:10 pm
Reply with quote

Well, the requirement is not pretty clear as of now.
But I assume all the above stated should also be found along with
"Bharat Juneja".

It will be great if you could also suggest -> If I don't want above 4 cases to be processed but only "Bharat Juneja" to get processed.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Apr 06, 2006 12:42 am
Reply with quote

bharat_juneja,

This code is one of several ways your query can be accomplished.

Code:

01  FNAME                       PIC X(12)   VALUE           
    'BHARAT'.                                               
01  FULLNAME                    PIC X(25)   VALUE           
    'BHARAT JUNEJA'.                                       
01  FNAME-LEN                   PIC 9(5)    COMP-3.         
                                                           
LINKAGE SECTION.                                           
                                                           
PROCEDURE DIVISION.                                         
                                                           
    INSPECT FNAME                                           
      TALLYING FNAME-LEN FOR CHARACTERS BEFORE INITIAL ' '.
                                                           
    IF FULLNAME(1:FNAME-LEN + 1) = FNAME                   
    THEN                                                   
        DISPLAY 'FOUND'                                     
    ELSE                                                   
        DISPLAY 'NOT FOUND'                                 
    END-IF.                                                 


Don't forget that you will have to sort both input files so you can do a two file match.

Dave
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top