Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

how to check A string contains string B

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: how to check A string contains string B
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    Post subject: Re: how to check A string contains string B
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    Post subject:
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    Post subject: Re: how to check A string contains string B
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm
No new posts How to insert a lengthy string havin... vidyaa DB2 7 Thu Aug 25, 2016 5:20 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us