I have a requirement where in I have to sort a file based on some particular records. I have paste my input file below.
*First 33 characters of my file are same
*Then it is followed by 4 character sequence number (0,1,2 etc)
*Then follows other texts.
My requirement for my output file is -
*First two records in my input file should come as first two records in output file
*Followed by the record having text as "Enclosed is our........." till record having "bearing date......"
*Followed by all the records having $ amount
I have a requirement where in I have to sort a file based on some particular records. I have paste my input file below.
*First 33 characters of my file are same
*Then it is followed by 4 character sequence number (0,1,2 etc)
*Then follows other texts.
My requirement for my output file is -
*First two records in my input file should come as first two records in output file
*Followed by the record having text as "Enclosed is our........." till record having "bearing date......"
*Followed by all the records having $ amount
Is there any way to achieve it?
Code:
1231234567890123456789012201202170 Company cd. 1234-123456-
1231234567890123456789012201202171
1231234567890123456789012201202172 $ 12,345.00
1231234567890123456789012201202173 $ 0.00
1231234567890123456789012201202174 - 12,345.00
1231234567890123456789012201202175 + 12,345.00
1231234567890123456789012201202176 -------------
1231234567890123456789012201202177 $ 12,345.00
1231234567890123456789012201202178 Enclosed is our check made
1231234567890123456789012201202179
12312345678901234567890122012021710 Company
12312345678901234567890122012021711
12312345678901234567890122012021712 for $12,345.00
12312345678901234567890122012021713 to pay from 1/1/20
12312345678901234567890122012021714 to 1/31/2012 according to
12312345678901234567890122012021715 bearing date of 3/10/
can You read ... I said use the code tags, not change the color
the effort for You would have been the same ,
for me I had to edit You post to fix Your dumbness
text within the code tags uses a fixed font so to preserve alignment
and make understanding code and data easier
Sorry...I am new to this forum. Dont know much about the features.
Yes the blank lines are part of my data
Ameet
enrico-sorichetti wrote:
Quote:
... use the code tags
can You read ... I said use the code tags, not change the color
the effort for You would have been the same ,
for me I had to edit You post to fix Your dumbness
text within the code tags uses a fixed font so to preserve alignment
and make understanding code and data easier
use the preview button to see how Your post looks like
Your previous post was one more edited to fix things.
one more and You are out
and anyway the word description of Your requirement does not match
the output posted
taking verbatim the description the blank lines would not be moved
i simple words You want to move what comes before the line/record containing
use the preview button to see how Your post looks like
Your previous post was one more edited to fix things.
one more and You are out
and anyway the word description of Your requirement does not match
the output posted
taking verbatim the description the blank lines would not be moved
i simple words You want to move what comes before the line/record containing
Code:
Enclosed is our check made
after the line/record containing
Code:
bearing date of
Yes you are right. The lines before the line containing "Enclosed is our..."
should come after "bearing date of", but except the first two lines. The first two lines of input file should also be written as first two lines in output file as well
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
You can't change the program producing the data because....?
If you have a sequence number, it is more convenient if it is usable directly, and not left-justified, with trailing space, for those less than 10. Who thought of a sequence number you can't SORT on directly?
*First two records in my input file should come as first two records in output file
*Followed by the record having text as "Enclosed is our........." till record having "bearing date......"
*Followed by all the records having $ amount
You 2nd requirememnt definition doesn't match expected output. You said you only want records till "bearing date" but then you show 2 more record before records that has $ amount. These 2 are the ones which ends in 122012021716 and 122012021717.
Did you mean to copy all the records from "Enclosed is our check made..until the start of new company code?
Regardless here is another way to do it, however on the same lines of solution Frank already provided.
1) This keeps first 2 records for each company code as is..
2) followed by records starting with "Enclosed is our.." until end of record for that company code
3) followed by all other records for that company code in their original order..
Code:
//STEP0001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1231234567890123456789012201202170 COMPANY CD. 1234-123456-
1231234567890123456789012201202171
1231234567890123456789012201202172 $ 12,345.00
1231234567890123456789012201202173 $ 0.00
1231234567890123456789012201202174 - 12,345.00
1231234567890123456789012201202175 + 12,345.00
1231234567890123456789012201202176 -------------
1231234567890123456789012201202177 $ 12,345.00
1231234567890123456789012201202178 ENCLOSED IS OUR CHECK MADE
1231234567890123456789012201202179
12312345678901234567890122012021710 COMPANY
12312345678901234567890122012021711
12312345678901234567890122012021712 FOR $12,345.00
12312345678901234567890122012021713 TO PAY FROM 1/1/20
12312345678901234567890122012021714 TO 1/31/2012 ACCORDING TO
12312345678901234567890122012021715 BEARING DATE OF 3/10/
12312345678901234567890122012021716
12312345678901234567890122012021717
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(89:8C'9',8C'0')),
IFTHEN=(WHEN=GROUP,BEGIN=(40,11,CH,EQ,C'COMPANY CD.'),
PUSH=(81:ID=8)),
IFTHEN=(WHEN=GROUP,
BEGIN=(40,26,CH,EQ,C'ENCLOSED IS OUR CHECK MADE'),
PUSH=(89:SEQ=8)),
IFTHEN=(WHEN=GROUP,RECORDS=2,
BEGIN=(40,11,CH,EQ,C'COMPANY CD.'),
PUSH=(89:97,8))
SORT FIELDS=(81,8,ZD,A,89,8,ZD,A),EQUALS
OUTFIL BUILD=(1,80)
/*
OUTPUT
Code:
1231234567890123456789012201202170 COMPANY CD. 1234-123456-
1231234567890123456789012201202171
1231234567890123456789012201202178 ENCLOSED IS OUR CHECK MADE
1231234567890123456789012201202179
12312345678901234567890122012021710 COMPANY
12312345678901234567890122012021711
12312345678901234567890122012021712 FOR $12,345.00
12312345678901234567890122012021713 TO PAY FROM 1/1/20
12312345678901234567890122012021714 TO 1/31/2012 ACCORDING TO
12312345678901234567890122012021715 BEARING DATE OF 3/10/
12312345678901234567890122012021716
12312345678901234567890122012021717
1231234567890123456789012201202172 $ 12,345.00
1231234567890123456789012201202173 $ 0.00
1231234567890123456789012201202174 - 12,345.00
1231234567890123456789012201202175 + 12,345.00
1231234567890123456789012201202176 -------------
1231234567890123456789012201202177 $ 12,345.00