Page 1 of 1

Sort after a string

PostPosted: Mon Nov 28, 2011 6:19 pm
by vinodj
Hello,

My input file is as follows :

mainframe > xx*
xxst1
xxst2
xxstdatasome
xxsomepoints
yyyy
zzzz
end of file

I want to search for string "mainframe >" which is a constant then sort all the subsequent records into output file as follows :

xxst1
xxst2
xxstdatasome
xxsomepoints

here string "xx" is two characters but it is variable e.g. if it is "te" then subsequent records are :
test1
test2
testdatasome
testsomepoints. Please tell me if this can be done and how.

I have code for searching the string "mainframe >" and sorting the subsequent records into output file. This is as follows :
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
------------------
-----------------
mainframe > xxxxxxxxxxxxx
ramesh
suresh
nnnn
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,11,CH,EQ,C'mainframe >'),
PUSH=(81:ID=1))
OUTFIL OMIT=(81,1,CH,EQ,C' ',OR,1,11,CH,EQ,C'mainframe >'),
BUILD=(1,80)
/*

Re: Sort after a string

PostPosted: Mon Nov 28, 2011 7:31 pm
by BillyBoyo
Have a look at PUSH. You should be able to store that value from the mainframe> record and OVERLAY or BUILD to include that value in the correct position on your output.

Re: Sort after a string

PostPosted: Mon Nov 28, 2011 11:41 pm
by Frank Yaeger
vinodj,

Your requirement isn't clear. You need to do a better job of explaining it.

Does "mainframe >" always appear in the first record, or can it appear somewhere else (e.g. 5th record).

Do you want to get the 2 characters after 'mainframe > ' and use them to INCLUDE only subsequent records that start with those 2 characters?
If not, exactly what do you want to do?

You say you want to "sort" the subsequent records, but you show the output as unsorted. Do you want the output sorted or not? If you want it sorted, what positions do you want it sorted on?

What is the RECFM and LRECL of your input file?

Re: Sort after a string

PostPosted: Wed Dec 14, 2011 6:40 pm
by vinodj
Hello Frank and Billy,

Thanks for your reply!
This issue is already solved (I didn't have to do anymore sorting).

Regards,
Vinod.