IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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: 74
Location: Boston

PostPosted: Thu Mar 13, 2014 2:37 pm
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: 2455
Location: Hampshire, UK

PostPosted: Thu Mar 13, 2014 5:26 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Mar 13, 2014 7:19 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts How I Found a Bug in a FORTRAN Compiler All Other Mainframe Topics 4
Search our Forums:

Back to Top