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
 

 

Search a string in a file, if found write hearder in outfile

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
raghavmcs

Active User


Joined: 14 Jul 2005
Posts: 105

PostPosted: Thu Mar 13, 2014 10:49 am    Post subject: Search a string in a file, if found write hearder in outfile
Reply with quote

Hi,

I have a file of length 133 and need to search a string 'INDEED' (it may come in any column or row) in that file. If string found, 20th postion to 31st postion of 4th row in the file should be write into output file.

Is it possible do this task using JCL? If yes, please let me know the sample JCL.

And we are using SYNCSORT in our house.

Thanks
Raghav
Back to top
View user's profile Send private message

TheMFKid

New User


Joined: 20 Nov 2013
Posts: 91
Location: India

PostPosted: Thu Mar 13, 2014 11:22 am    Post subject:
Reply with quote

If you find the string "INDEED" anywhere in your file, you have to capure 20th postion to 31st postion of 4th row in your file. So your output file will contain only one record(extracted from 4th row), if your string is present in file.
I am not sure if the complete requirement can be achieved using Sort.
You can use Search utility in batch PGM=ISRSUPC,PARM=(SRCHCMP,'ANYC') to search for your string in entire file, and based on its return code extract the 4th record using SYNCHSORT.
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 73
Location: Boston

PostPosted: Thu Mar 13, 2014 2:37 pm    Post subject:
Reply with quote

Why don't you try posting your sample input and expected output which would make it more self-explanatory instead of us trying to guess what you expect your output to be?

Thanks,
Ashwin.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1713
Location: UK

PostPosted: Thu Mar 13, 2014 5:26 pm    Post subject: Reply to: Search a string in a file, if found write hearder
Reply with quote

Yes! You can do it using JCL. But...the JCL will only request the OS to execute the program that will actually carry out the task.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Thu Mar 13, 2014 7:19 pm    Post subject: Reply to: Search a string in a file, if found write hearder
Reply with quote

One short step, STOPAFT=4 on the OPTION, and generate a SORT symbol for the value you want. 80-bytes fixed.

Second step, which uses the dataset from above on a //SYMNAMES DD. Include //SYMNOUT DD SYSOUT=whatever so you have a record of the symbol in the sysout.

Have your main step with the required logic, using the symbol which has been generated.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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