Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 1894
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 line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us