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: 1845
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: 7315

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 Match two files using multiple keys a... santoshks1987 SYNCSORT 10 Fri Aug 18, 2017 10:50 am
No new posts change string before sertan string anatol DFSORT/ICETOOL 8 Tue Aug 15, 2017 5:43 pm
No new posts Multiple VSAM files single output fil... Mohan Kothakota DFSORT/ICETOOL 11 Wed Aug 09, 2017 7:57 pm
This topic is locked: you cannot edit posts or make replies. rexx code to create a ps file Bharath Vikraman CLIST & REXX 4 Mon Aug 07, 2017 10:30 am
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm


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