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

How to update the trailer with the count of records and sum


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

New User


Joined: 21 Sep 2010
Posts: 17
Location: India

PostPosted: Sun Apr 03, 2011 12:04 am
Reply with quote

Hi to all. I have a situation mentioned below.

I have two input files, File-A and File-B(both are FB, LRECL=80).

File-A contains Header(3 lines identified by 'HDR1','HDR2'&'HDR3'), Detail Records and Trailer(one line identified by 'TLR'). as below.

Code:
HDR1000121data
HDR2000122data
HDR3000123data
RECORD1 A 0001 XXX
RECORD2 B 0002 YYY
RECORD3 C 0003 ZZZ
RECORD4 D 0004 AAA
RECORD5 E 0005 BBB
TLRXXX 00015 COUNT = 00005



File-B contains only the Detail records.

Code:
RECORD6 X 0001 AAA
RECORD7 Y 0002 BBB
RECORD8 Z 0003 CCC


I need to
1. Merge File-A and File-B(format of the o/p file should be similar to File-A, i.e. Header, Detail Records from File-A and File-B, Trailer)
2. Column 8 to 12 of Trailer should contain the SUM of the numeric data present in column 11 to 14 of File-A and File-B.
3. Column 22 to 26 of Trailer should contain the COUNT of detail records of File-A and File-B.

The output file must look like

Code:
HDR1000121data
HDR2000122data
HDR3000123data
RECORD1 A 0001 XXX
RECORD2 B 0002 YYY
RECORD3 C 0003 ZZZ
RECORD4 D 0004 AAA
RECORD5 E 0005 BBB
RECORD6 X 0001 AAA
RECORD7 Y 0002 BBB
RECORD8 Z 0003 CCC
TLRXXX 00021 COUNT = 00008


How can i achieve this using SORT???
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Apr 04, 2011 8:37 pm
Reply with quote

Quote:
How can i achieve this using SORT???

Yes.

Few questions, Is there any identifier for detail record?

Will trailer records be always,

Code:
TLRXXX nnnnn COUNT = nnnnn
?
Back to top
View user's profile Send private message
padhumainframe

New User


Joined: 21 Sep 2010
Posts: 17
Location: India

PostPosted: Mon Apr 04, 2011 9:21 pm
Reply with quote

Hi, Please find the answers for ur questions.

Few questions, Is there any identifier for detail record?

No. Only Header and Trailer records contains identifiers.

Will trailer records be always, TLRXXX nnnnn COUNT = nnnnn

Yes.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Apr 04, 2011 10:06 pm
Reply with quote

padhumainframe,

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 update the trailer record. The following DFSORT JCL will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=Your input file 1 with 3 headers,DISP=SHR             
//         DD DSN=your input file 2,DISP=SHR
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,4C'0')),             
  IFTHEN=(WHEN=(81,8,ZD,GT,3,AND,1,3,CH,NE,C'TLR'),OVERLAY=(89:11,4)),
  IFTHEN=(WHEN=(1,3,CH,EQ,C'TLR'),OVERLAY=(81:8C'9'))                 

  SORT FIELDS=(81,8,CH,A)                                             

  OUTFIL BUILD=(1,80),IFTRAIL=(TRLID=(1,3,CH,EQ,C'TLR'),               
  TRLUPD=(08:TOT=(89,4,ZD,M11,LENGTH=5),                               
          22:COUNT-3=(M11,LENGTH=5)))                                 
//*


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

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Apr 04, 2011 10:09 pm
Reply with quote

Here is one alternative...
Code:

//S1    EXEC  PGM=SORT           
//SORTIN DD *                     
HDR1000121DATA                   
HDR2000122DATA                   
HDR3000123DATA                   
RECORD1 A 0001 XXX               
RECORD2 B 0002 YYY               
RECORD3 C 0003 ZZZ               
RECORD4 D 0004 AAA               
RECORD5 E 0005 BBB               
TLRXXX 00015 COUNT = 00005       
//       DD *                     
RECORD6 X 0001 AAA               
RECORD7 Y 0002 BBB               
RECORD8 Z 0003 CCC               
//SORTOUT DD SYSOUT=*             
//SYSOUT    DD  SYSOUT=*         
//SYSPRINT DD SYSOUT=*           
//SYSIN    DD  *                 
  OMIT COND=(1,3,CH,EQ,C'TLR')   
  SORT FIELDS=COPY,EQUALS         
  INREC IFTHEN=(WHEN=(1,3,CH,NE,C'HDR'),OVERLAY=(81:11,4))
  OUTFIL FNAMES=SORTOUT,REMOVECC,BUILD=(1,80),             
  TRAILER1=('TLRXXX ',TOT=(81,4,ZD,M11,LENGTH=5),         
            ' COUNT = ',COUNT-3=(M11,LENGTH=5))           
/*
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Apr 05, 2011 3:06 pm
Reply with quote

Quote:
These PTFs provide important enhancements to DFSORT and DFSORT's ICETOOL for resizing records (RESIZE
operator); updating the trailer record (IFTRAIL); processing subsets (ACCEPT); translation of ASCII to EBCDIC
(TRAN=ATOE), EBCDIC to ASCII (TRAN=ETOA), EBCDIC hex to binary (TRAN=UNHEX), and more; date
field arithmetic (ADDDAYS, ADDMONS, ADDYEARS, SUBDAYS, SUBMONS, SUBYEARS, DATEDIFF,
NEXTDday, PREVDday, LASTDAYW, LASTDAYM, LASTDAYQ and LASTDAYY); timestamp constant with
microseconds (DATE5); group functions (KEYBEGIN); use of SET and PROC symbols in control statements
(JPn"string" in EXEC PARM); more information in reports; larger fields; easier migration from other sort products,
and more.


I was away from mainframes for most of last year... and so from DFSORT too...

I just read through new functions... These are incredible ... especially DATE manipulation related and IFTRAIL...

Kudos to your team Frank and Kolusu...
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: Tue Apr 05, 2011 10:37 pm
Reply with quote

Sambhaji,

Thanks for the kind words. FYI, Kolusu developed the DATE functions. I developed IFTRAIL and the other functions.
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 To get the count of rows for every 1 ... DB2 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top