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

Help on SORT Logic.


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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Mar 27, 2012 2:37 pm
Reply with quote

So we continue, even though Ashutosh is already happy with half the job done.

Less code, more steps, or, more accurately, more step, or another step. Less code, another step.

There are two fields whose length we are interested in calculating. Put those fields last on records going to two different files and make them variable with trailing blanks removed (FTOV with VLTRIM).

In the second step, a JOINKEYS, process both files, calculating the length of the two fields in question by knowing the length that the maximum record would be. Stick the records together with the JOINKEYS using a sequence number. Make the output fixed (VTOF).

Code:
//S1 EXEC PGM=SORT
//SYSOUT  DD SYSOUT=*
//WDSGN   DD DSN=&&WDSGN,UNIT=SYSDA,SPACE=(CYL,1),DISP=(,PASS)
//WADDR   DD DSN=&&WADDR,UNIT=SYSDA,SPACE=(CYL,1),DISP=(,PASS)
//SORTIN DD *
AA|BB|C234567890123456789C|D2345678901234567890123456789D|EEEEEEEEEX
F|G|H|I|J
K|L|MMMMMMMZ|NNNNNNNNNNNNNZ|O
//SYSIN DD *
  OPTION COPY
  OUTREC IFTHEN=(WHEN=INIT,
         PARSE=(%00=(ENDBEFR=C'|',FIXLEN=10),
                %01=(ENDBEFR=C'|',FIXLEN=30),
                %02=(ENDBEFR=C'|',FIXLEN=20),
                %03=(ENDBEFR=C'|',FIXLEN=30),
                %04=(ENDBEFR=C'|',FIXLEN=10))),
         IFTHEN=(WHEN=INIT,
                 BUILD=(%00,%01,%04,%02,%03))
                                                                     
  OUTFIL FNAMES=WDSGN,FTOV,VLTRIM=C' ',
         OVERLAY(71:30X)
  OUTFIL FNAMES=WADDR,FTOV,VLTRIM=C' ',
         BUILD=(71,30)
//HUMPHREY EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1    DD DSN=&&WDSGN,DISP=(OLD,PASS)
//SORTJNF2    DD DSN=&&WADDR,DISP=(OLD,PASS)
//SORTOUT DD SYSOUT=*
//SYSIN DD *
                                                           
    JOINKEYS FILE=F1,FIELDS=(7,8,A),SORTED,NOSEQCK
    JOINKEYS FILE=F2,FIELDS=(7,8,A),SORTED,NOSEQCK
    REFORMAT FIELDS=(F1:1,4,5,2,F2:5,2,F1:15,70,F2:15,30)
    OPTION COPY
    INREC BUILD=(9,40,-54,ADD,5,2,BI,TO=BI,LENGTH=2,
                 59,20,-4,ADD,7,2,BI,TO=BI,LENGTH=2,
                 79,30,49,10)
    OUTFIL VTOF
//JNF1CNTL DD *
    INREC IFTHEN=(WHEN=INIT,
                   PARSE=(%00=(ABSPOS=55,FIXLEN=20))),
          IFTHEN=(WHEN=INIT,
                   BUILD=(1,4,1,2,SEQNUM,8,ZD,5,50,%00))
//JNF2CNTL DD *
    INREC IFTHEN=(WHEN=INIT,
                   PARSE=(%00=(ABSPOS=5,FIXLEN=30))),
          IFTHEN=(WHEN=INIT,
                   BUILD=(1,4,1,2,SEQNUM,8,ZD,%00))
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 Goto page Previous  1, 2

 


Similar Topics
Topic Forum Replies
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 JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top