|
View previous topic :: View next topic
|
| Author |
Message |
padhumainframe
New User
Joined: 21 Sep 2010 Posts: 17 Location: India
|
|
|
|
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 |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| 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 |
|
 |
padhumainframe
New User
Joined: 21 Sep 2010 Posts: 17 Location: India
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| 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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Sambhaji,
Thanks for the kind words. FYI, Kolusu developed the DATE functions. I developed IFTRAIL and the other functions. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|