sathyaraj
New User
Joined: 28 Sep 2007 Posts: 71 Location: India.
|
|
|
|
Hi,
I have an input file which looks like the one below.
5T37 4373950054835 LE 0102....07821448033509
7T37 4373950054835 LE 01020152S000003
7T37 4373950054835 LE 01020165S000002
7T37 4373950054835 LE 01022600S000002
7T37 4373950054835 LE 01022972S000003
7T37 4373950054835 LE 01023777S000002
7T37 4373950054835 LE 01023955S000003
5T37 4373950054835 LE 0103....07821455033509
7T37 4373950054835 LE 01030152S000001
7T37 4373950054835 LE 01030165S000001
7T37 4373950054835 LE 01032600S000001
7T37 4373950054835 LE 01032972S000001
5T37 4373950054835 LE 0202....07821462033509
7T37 4373950054835 LE 02020152S000007
7T37 4373950054835 LE 02020165S000005
7T37 4373950054835 LE 02022600S000005
5T37 4373950022023 JC 0200....03540701033449
7T37 4373950022023 JC 02000152S000009
7T37 4373950022023 JC 02002972S000009
7T37 4373950022023 JC 02003955S000009
7T37 4373950022023 JC 02004048S000009
7T37 4373950022023 JC 02004129S000009
5T37 4373950022023 JC 0300....01001129033449
7T37 4373950022023 JC 03000152S000008
Here, in the output file I should have the records starting with '5T' and then followed by records starting with '7T'. but only a maximum of 3 '7T' records can follow the '5T' records.
Any idea would be of really a great Help.
Thanks,
Sathya. |
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Below sortstep will give you desired result. I have assumed LRECL=80
Code: |
//STEP010 EXEC PGM=SORT
//DFSMSG DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
5T37 4373950054835 LE 0102....07821448033509
7T37 4373950054835 LE 01020152S000003
7T37 4373950054835 LE 01020165S000002
7T37 4373950054835 LE 01022600S000002
7T37 4373950054835 LE 01022972S000003
7T37 4373950054835 LE 01023777S000002
7T37 4373950054835 LE 01023955S000003
5T37 4373950054835 LE 0103....07821455033509
7T37 4373950054835 LE 01030152S000001
7T37 4373950054835 LE 01030165S000001
7T37 4373950054835 LE 01032600S000001
7T37 4373950054835 LE 01032972S000001
5T37 4373950054835 LE 0202....07821462033509
7T37 4373950054835 LE 02020152S000007
7T37 4373950054835 LE 02020165S000005
7T37 4373950054835 LE 02022600S000005
5T37 4373950022023 JC 0200....03540701033449
7T37 4373950022023 JC 02000152S000009
7T37 4373950022023 JC 02002972S000009
7T37 4373950022023 JC 02003955S000009
7T37 4373950022023 JC 02004048S000009
7T37 4373950022023 JC 02004129S000009
5T37 4373950022023 JC 0300....01001129033449
7T37 4373950022023 JC 03000152S000008
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'5T'),PUSH=(81:SEQ=8))
OUTFIL INCLUDE=(81,8,ZD,LE,4),BUILD=(1,80)
/*
|
|
|