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

Reformat the input using SORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ameetmund

New User


Joined: 02 Jun 2006
Posts: 11

PostPosted: Thu Mar 15, 2012 7:24 pm
Reply with quote

Hi,

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?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Mar 15, 2012 7:25 pm
Reply with quote

do not post images, they clutter the forum
use a plain text cut and paste and use the code tags
the image has been deleted
Back to top
View user's profile Send private message
ameetmund

New User


Joined: 02 Jun 2006
Posts: 11

PostPosted: Thu Mar 15, 2012 7:41 pm
Reply with quote

Hi,

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/         
                                                                       
12312345678901234567890122012021716                                     
                                                                       
12312345678901234567890122012021717
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Mar 15, 2012 7:46 pm
Reply with quote

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

are the blank lines part of the data or not ???
Back to top
View user's profile Send private message
ameetmund

New User


Joined: 02 Jun 2006
Posts: 11

PostPosted: Thu Mar 15, 2012 8:05 pm
Reply with quote

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

are the blank lines part of the data or not ???
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Mar 15, 2012 8:07 pm
Reply with quote

if that is the input, just show how the output should look like
Back to top
View user's profile Send private message
ameetmund

New User


Joined: 02 Jun 2006
Posts: 11

PostPosted: Thu Mar 15, 2012 8:17 pm
Reply with quote

enrico-sorichetti wrote:
if that is the input, just show how the output should look like


The output should look like the below one -

Code:
1231234567890123456789012201202170   Company cd.  1234-123456-00       
                                                                       
1231234567890123456789012201202171                                     
                                                                       
1231234567890123456789012201202178   Enclosed is our check made payable
                                                                       
1231234567890123456789012201202179                                     
                                                                       
12312345678901234567890122012021710       Company name                 
                                                                       
12312345678901234567890122012021711                                     
                                                                       
12312345678901234567890122012021712  for $12,345.00                     
                                                                       
12312345678901234567890122012021713  to pay from 1/1/2012               
                                                                       
12312345678901234567890122012021714  to 1/31/2012 according to the terms
                                                                       
12312345678901234567890122012021715  bearing date of 3/10/1984         
                                                                       
12312345678901234567890122012021716                                     
                                                                       
12312345678901234567890122012021717                                     

1231234567890123456789012201202172   $    12,345.00                   
                                                                       
1231234567890123456789012201202173   $         0.00                   
                                                                       
1231234567890123456789012201202174   -    12,345.00                   
                                                                       
1231234567890123456789012201202175   +    12,345.00                   
                                                                       
1231234567890123456789012201202176    -------------                   
                                                                       
1231234567890123456789012201202177   $    12,345.00           
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Mar 15, 2012 8:21 pm
Reply with quote

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 icon_evil.gif

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
Back to top
View user's profile Send private message
ameetmund

New User


Joined: 02 Jun 2006
Posts: 11

PostPosted: Thu Mar 15, 2012 8:41 pm
Reply with quote

enrico-sorichetti wrote:
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 icon_evil.gif

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
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 15, 2012 9:10 pm
Reply with quote

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?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 15, 2012 11:17 pm
Reply with quote

ammetmund,

You can use a DFSORT/ICETOOL job like the following to do what you asked for:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN DD *
COPY FROM(IN) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  OMIT COND=(1,20,CH,EQ,C' ')
  INREC IFTHEN=(WHEN=(40,7,CH,EQ,C'Company'),OVERLAY=(81:C'1')),
    IFTHEN=(WHEN=(40,2,SS,EQ,C'$ ,- ,+ , -'),OVERLAY=(82:C'3')),
    IFTHEN=(WHEN=(40,8,CH,EQ,C'Enclosed'),OVERLAY=(81:C'2'))
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(81,1,CH,EQ,C'1'),RECORDS=2,
    PUSH=(82:81,1)),
   IFTHEN=(WHEN=GROUP,BEGIN=(81,1,CH,EQ,C'2'),
    PUSH=(82:81,1))
/*
//CTL2CNTL DD *
  OPTION EQUALS
  SORT FIELDS=(82,1,CH,A)
  OUTFIL REMOVECC,BUILD=(1,80,/)
/*
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Fri Mar 16, 2012 12:55 am
Reply with quote

ameetmund,
ameetmund wrote:
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


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           

Thanks,
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top