View previous topic :: View next topic
Author
Message
svlim New User Joined: 14 Mar 2006Posts: 2
I have an input file with following structure
00,02/09/2009,03/09/2009
01,ABCD,XXXX,XXX, +100.000
01,XYZZ,VBDF,DFD, +20.000
02,WDDR,DFGF,GDS, -3000.000
I need to add a trailer in the end of the file as follows
99,0005, +120.000, -3000.000
where 99 is a constant
0005 is the number of records in the files including trailer
+120.000 is total of amounts with records having 01 as the 1st 2 bytes
-3000.000 is the total of amounts with records having 02 as the 1st 2 bytes
How to add the above trailer through DFSORT.
The amount filed is of 14 bytes and file length is 80 bytes.
Thanks in Advance.
Back to top
svlim New User Joined: 14 Mar 2006Posts: 2
For testing purpose I changed the file structure as
00,02/09/2009,03/09/2009
01,+100.0
01, +20.0
02, -10.0
and with following sort card the output was
00,02/09/2009,03/09/2009
01,+100.0
01, +20.0
02, -10.0
99,0004, +120.0, -10.0
Code:
OPTION COPY
INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'01'),
PARSE=(%01=(ABSPOS=4,FIXLEN=6)),
OVERLAY=(81:%01,SFF,TO=ZD,LENGTH=6)),
IFTHEN=(WHEN=(1,2,CH,EQ,C'02'),
PARSE=(%02=(ABSPOS=4,FIXLEN=6)),
OVERLAY=(87:%01,SFF,TO=ZD,LENGTH=6))
OUTFIL FNAMES=SORTOUT,BUILD=(1,80),REMOVECC,
TRAILER1=(C'99',',',COUNT=(EDIT=(TTTT)),',',
TOT=(81,6,ZD,EDIT=SIITT.T),SIGNS=(+,-)),',',
TOT=(87,6,ZD,EDIT=SIITT.T),SIGNS=(+,-)))
Back to top
saiprasadh Active User Joined: 20 Sep 2006Posts: 154 Location: US
Hi svlim,
Your sort card created return code 16. please find the updated one
Code:
OPTION COPY
INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'01'),
PARSE=(%01=(ABSPOS=4,FIXLEN=6)),
OVERLAY=(81:%01,SFF,TO=ZD,LENGTH=6)),
IFTHEN=(WHEN=(1,2,CH,EQ,C'02'),
PARSE=(%02=(ABSPOS=4,FIXLEN=6)),
OVERLAY=(87:%02,SFF,TO=ZD,LENGTH=6))
OUTFIL FNAMES=SORTOUT,BUILD=(1,92),REMOVECC,
TRAILER1=(C'99',',',COUNT=(EDIT=(TTTT)),',',
TOT=(81,6,ZD,EDIT=(SIITT.T),SIGNS=(+,-)),',',
TOT=(87,6,ZD,EDIT=(SIITT.T),SIGNS=(+,-)))
Sai
Back to top
Please enable JavaScript!