MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sort the Detailed Records and adjust the Trailer Record

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Dinesh.G
Beginner


Joined: 18 Jan 2005
Posts: 9
Topics: 2

PostPosted: Mon Jan 31, 2005 3:52 am    Post subject: Sort the Detailed Records and adjust the Trailer Record Reply with quote

I have an Input File of LRECL=53 with the following Records

The First Byte=
0 represents header Record
1 to
6 represents Detailed Records
9 Represents the Trailer record

I need to sort the Input File On (2,15) and (26,8) and remove the duplicate detailed records and adjust the Trailer Record count with the remaining bytes in the Trailer Record intact.There will be only one Header Record and one trailer Record.The trailer Record Count byte is from (2,9).

Is it possible to solve the problem using PGM=SORT in one step (one pass)



Input File

Code:
0NQSIEXTR 05.17002  1725370000000       00000........
1371010071002000111     005202106007SJAN17002........
1371010071002000111     005202106007SJAN17002........
137101009200200511131   005202239004SJAN17002........
1371010121001002111     005202106007SJAN17002........
137101014300400011131   005202106007SJAN17002........
437399811720100811L  409055402010009SJAN17002........
437399811720100811L  409055402010009SJAN17002........
6378665454991005311     005302302007SJAN17002........
9000000010               00000000       00000........     


Expected Output File


Code:
0NQSIEXTR 05.17002  1725370000000       00000........
1371010071002000111     005202106007SJAN17002........
137101009200200511131   005202239004SJAN17002........
1371010121001002111     005202106007SJAN17002........
137101014300400011131   005202106007SJAN17002........
437399811720100811L  409055402010009SJAN17002........
6378665454991005311     005302302007SJAN17002........
9000000008               00000000       00000........




Thanks & rgds
Dinesh
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Jan 31, 2005 6:49 am    Post subject: Reply with quote

Dinesh,

Updating the trailer count is a little bit tricky and may not be possible to do within a single pass/step.

try this job.

Code:

//STEP0100 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=YOUR INOUT FILE,
//            DISP=SHR
//SORTOUT  DD DSN=YOUR HEADER +DETAIL RECORDS,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//TRLR     DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE),UNIT=SYSDA
//SYSIN    DD *
//SYSIN    DD *                             
  INREC FIELDS=(1,53,                         
                1,1,CHANGE=(1,C'0',C'0',     
                              C'9',C'9'),     
                    NOMATCH=(C'1'))               
  SORT FIELDS=(54,1,CH,A,                     
               02,15,CH,A,                   
               26,08,CH,A)                   
  SUM FIELDS=NONE                             
  OUTREC FIELDS=(1,53,SEQNUM,9,ZD)           
  OUTFIL INCLUDE=(1,1,CH,NE,C'9'),
  OUTREC=(1,53)                               
  OUTFIL FNAMES=TRLR,SAVE,                   
  OUTREC=(1,1,54,9,11,43)                     
/*
//STEP0200 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=&T1,
//            DISP=SHR
//SORTOUT  DD DSN=YOUR HEADER+DETAIL RECORDS,
//            DISP=(MOD,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *
  SORT FIELDS=COPY
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Jan 31, 2005 11:46 am    Post subject: Reply with quote

With z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004), you can do this in one pass using DFSORT's new IFTHEN clauses as follows:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT  DD DSN=...  output file
//SYSIN    DD    *
* Set temp. key in 54 from 1 as '0' for '0', '9' for '9'
* or '1' otherwise.  This allows us to use the temp. key
* for SORT/SUM.
  INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'0',OR,1,1,CH,EQ,C'9'),
         OVERLAY=(54:1,1)),
       IFTHEN=(WHEN=NONE,OVERLAY=(54:C'1'))
* SORT on the temp. key and the other keys.
  SORT FIELDS=(54,1,CH,A,2,15,CH,A,26,8,CH,A)
* SUM to eliminate duplicates.
  SUM FIELDS=NONE
* Add a sequence number in 55-63 for each remaining record.
  OUTREC OVERLAY=(55:SEQNUM,9,ZD)
* Replace the count in the trailer ('9') record with
* the sequence number from 55-63.
  OUTFIL IFTHEN=(WHEN=(1,1,CH,EQ,C'9'),OVERLAY=(2:55,9)),
* Remove the temp. key and sequence number.
        IFOUTLEN=53
/*


For complete details on all of the new DFSORT and ICETOOL functions available with this PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/

If you don't have this PTF installed, ask your System Programmer to install it (it's free).
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Nov 02, 2010 3:02 pm    Post subject: Reply with quote

With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct,2010), you can now use DFSORT's new IFTRAIL function to do this like so:

Code:

  INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'0',OR,1,1,CH,EQ,C'9'),
          OVERLAY=(54:1,1)),
        IFTHEN=(WHEN=NONE,OVERLAY=(54:C'1'))
  SORT FIELDS=(54,1,CH,A,2,15,CH,A,26,8,CH,A)
  SUM FIELDS=NONE
  OUTFIL BUILD=(1,53),
   IFTRAIL=(TRLID=(1,1,CH,EQ,C'9'),
    TRLUPD=(2:COUNT+1=(TO=ZD,LENGTH=9)))


For complete details on the new functions for DFSORT and DFSORT's ICETOOL available with the Oct, 2010 PTF, see:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group