Page 1 of 1

Sort after a string

PostPosted: Wed Apr 11, 2012 6:04 pm
by vinodj
I posted following query some days ago :
I have a PS like this

mainframe > xxxxxxxxxxxxx
end of file

I want to search for the string "mainframe >" (this string is constant) using a JCL and then sort all the following records into another file
so the other file will contain all the following records :


I got solution for this as follows and it worked :

//SORTOUT DD SYSOUT=*                                           
//SYSIN DD *                                                     
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,11,CH,EQ,C'mainframe >'),   
  OUTFIL OMIT=(81,1,CH,EQ,C' ',OR,1,11,CH,EQ,C'mainframe >'),   


Since I did not understand the solution I asked whether my understanding of the solution (which I posted like below) was correct and got an answer that I was correct in my understanding..

WHEN=GROUP means we are working on a group of records (so this is input file)
when 'mainframe >' is encounterd in columns 1 to 11 we are assigning an ID to all the subsequent records( in 81st column). We are then omitting the records that have ID blank or those that start with 'mainframe >'


Now I tried to sort the below file using the same solution (there are spaces at the start of 'ramesh', 'suresh', 'nnnn')

mainframe > xxxxxxxxxxxxx
<some spaces>ramesh
<some spaces>suresh
<some spaces>nnnn
end of file

But this solution won't work. The output file is empty. Am I missing something in my understanding?


Re: Sort after a string

PostPosted: Wed Apr 11, 2012 6:49 pm
by BillyBoyo
You have to show the sort cards which you are using. Otherwise we can have no idea.

Re: Sort after a string

PostPosted: Wed Apr 11, 2012 9:52 pm
by skolusu
check and see if you input is a VB file. if so then you need to add 4 bytes of RDW to the start position of the field to be checked.

Re: Sort after a string

PostPosted: Wed Apr 11, 2012 9:57 pm
by Frank Yaeger
As Kolusu says, if your input file has RECFM=VB, then the approach would be somewhat different (insert the id between the RDW and the first data byte).
If you confirm that your input file has RECFM=VB, we can show you how to do it correctly.

If your input file has RECFM=FB, then you need to show us your complete JES log with all of the messages you received so we can try to determine what you're doing wrong.