View previous topic :: View next topic
Author
Message
comp_ashok New User Joined: 30 Nov 2007Posts: 15 Location: India
Hi all,
My input file is FB, Lrec=20
Code:
2222 I 500.00
2222 D 200.00
2222 I 300.00
3333 I 500.00
3333 D 200.00
3333 R 300.00
2222 I 500.00
4444 D 200.00
3333 I 300.00
My output should come as:
Code:
2222 I 1100.00
3333 I 0600.00
3333 R 0300.00
4444 D 0200.00-
Starting 4 bytes is the key. If 7th byte is 'I', we need to add. If it is 'D' we need to subtract. If 'R' We need to left record as it is. In output file it doesn't matter whether we are showing 'I' or 'D'. But it should show 'R' correctly.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Here's a DFSORT job that will do what you asked for.
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/20)
//SORTOUT DD DSN=... output file (FB/21)
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(22:14,6)),
IFTHEN=(WHEN=(7,1,CH,EQ,C'D'),OVERLAY=(7:C'I',21:C'-'))
SORT FIELDS=(1,7,CH,A,7,1,CH,A)
OUTFIL REMOVECC,NODETAIL,
BUILD=(1,21),
SECTIONS=(1,7,
TRAILER3=(1,7,14:TOT=(21,7,SFF,EDIT=(TTTT.TTS),SIGNS=(,,,-))))
/*
For your input example, SORTOUT will have:
Code:
2222 I 1100.00
3333 I 0600.00
3333 R 0300.00
4444 I 0200.00-
Quote:
In output file it doesn't matter whether we are showing 'I' or 'D'. But it should show 'R' correctly.
'I' or 'R' will be shown as appropriate.
Back to top
karthikr44 Active User Joined: 25 Aug 2007Posts: 235 Location: Chennai
HI,
I had executed your code.
Quote:
If 'R' We need to left record as it is.
But for R case also, it add the records.
Input:
Code:
2222 I 500.00
2222 D 200.00
2222 I 300.00
3333 I 500.00
3333 D 200.00
3333 R 300.00
3333 R 500.00
Output:
Code:
2222 I 0600.00
3333 I 0300.00
3333 R 0800.00
Kindly suggest any way to avoid this scenario.
Regards
R KARTHIK
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Karthik,
I didn't realize you could have more than 1 R record for a given key (you didn't show that in your example), so I didn't code for it. Here's a new version of the DFSORT job that will take care of that:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/20)
//SORTOUT DD DSN=... output file (FB/21)
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(22:14,6,28:1,5,33:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(7,1,CH,EQ,C'D'),
OVERLAY=(7:C'I',21:C'-',33:8C'0')),
IFTHEN=(WHEN=(7,1,CH,EQ,C'I'),OVERLAY=(33:8C'0'))
SORT FIELDS=(28,13,CH,A)
OUTFIL REMOVECC,NODETAIL,
BUILD=(1,21),
SECTIONS=(28,13,
TRAILER3=(1,7,14:TOT=(21,7,SFF,EDIT=(TTTT.TTS),SIGNS=(,,,-))))
/*
Back to top
vivekkodan New User Joined: 18 Sep 2008Posts: 3 Location: India
how does "SIGNS" work here? plz calrify
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
SIGNS(a,b,c,d)
a is the leading positive sign.
b is the trailing positive sign.
c is the leading negative sign.
d is the trailing negative sign.
EDIT=(TTTT.TTS) has a trailing sign (S), so a and b are not relevant.
SIGNS(,,,-)
Specifies the trailing positive sign (c) is a blank and the trailing negative sign (d) is a minus sign.
Back to top
Please enable JavaScript!