Posted: Fri Mar 05, 2010 1:24 pm Post subject: sort sum - expand output length
Hi,
I have a input file which has 2 fields. The layout is
01 INPUT-REC
05 CUST-NO PIC X(9)
05 CUST-DESC PIC X(30)
05 CUST-QTY PIC S9(10)V999 COMP-3
The input file has many records for a single cust-no. I am trying to have only 1 record per cust-no and sum cust-qty to an output file.
I used the below given sortcard
SORT FIELDS=(1,9,CH,A)
SUM FIELDS=(40,7,PD)
OUTREC FIELDS=(1:1,9,10:40,7)
However, if the CUST-QTY for 2 records is already at the max for a single CUST-NO then the sort sum doesn't work and I get multiple records.
For eg., it doesn't work for the below condition.
Cust-NO CUST-QTY
XXXXXXX1X -4004000000.000
XXXXXXX1X -8000000000.000
I want to expand the CUST-QTY for the output record to avoid this issue. Can someone please advise how to resolve this using SORT.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Mar 05, 2010 2:02 pm Post subject:
This would exapnd the CUST-QTY to PIC S9(12)V999:
Code:
INREC BUILD=(1,9,10:Z,40,7)
SORT FIELDS=(1,9,CH,A)
SUM FIELDS=(10,8,PD)
Z is used to insert X'00' before the PD value to expand it. _________________ 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
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