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
 

 

Finding a String in a file..

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
srikanthkailasam

New User


Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

PostPosted: Tue Mar 17, 2009 4:42 am    Post subject: Finding a String in a file..
Reply with quote

I have a flat file of LRECL 8000. I have to search for the string 'ABC='. If present, then I have to extract into a new variable starting from 'ABC=' till the first occurence of '/'. I am not worried about the rest of the data.
Please note that the position of 'ABC=' is not fixed and will vary from one record to another. I can use INSPECT to check for the existence of 'ABC=' but how can I put it into a new variable.

Please suggest a solution for this.
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 17, 2009 5:57 am    Post subject:
Reply with quote

Hello,

Once you find the 'ABC=' move the characters one at a time to the "output" area (using reference modification on both the input and the output) until you hit the '/'.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Mar 17, 2009 1:57 pm    Post subject:
Reply with quote

Hi,

What code you have been using for this, please show us that - we might start from there . . .
Back to top
View user's profile Send private message
srikanthkailasam

New User


Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

PostPosted: Tue Mar 17, 2009 8:18 pm    Post subject:
Reply with quote

Thanks Dick and Anuj for your replies.

Anuj,
I was thinking in the same line as Dick... I will start reading my input file as a group of 4 bytes and when I hit 'ABC=', then start procedding byte by bte until I hit '/'..
Back to top
View user's profile Send private message
srikanthkailasam

New User


Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

PostPosted: Wed Mar 18, 2009 12:27 am    Post subject:
Reply with quote

Code:
MOVE WS-TEXT (A:4) TO HOLD-VAR             
IF HOLD-VAR = 'ABC='                       
   PERFORM UNTIL WS-TEXT(A:1) = '/'         
      MOVE WS-TEXT (A:1) TO FINAL-VAR(B:1) 
      ADD +1 TO B A                         
   END-PERFORM                             
   SET RECORD-DONE TO TRUE                 
ELSE                                       
   ADD +1 TO A                             
END-IF.                                     



The above code is working. Thanks Dick and Anuj for your time.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Mar 18, 2009 1:10 am    Post subject: Reply to: Finding a String in a file..
Reply with quote

You're welcome - thank you for letting us know it is working icon_smile.gif

d
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 Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm


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