View previous topic :: View next topic
Author
Message
chinnielr New User Joined: 11 Jul 2005Posts: 87
Hi,
I have an I/P file with LRECL 80, FB
ID Amounts CR/DR
--- ---------- -------
10 100.00 CR
10 200.00 DR
10 100.00 DR
My O/P should be
10 100.00 DR
ID -> Start position =1, length 2
Amounts -> Start position 3, length=10
CR/DR -> Start position 13, length=2
Here the Amounts are in displayable format (ZZZ.99)
Can you please let me know how to do this using DFSORT?
Regards,
Kiran.
Back to top
chinnielr New User Joined: 11 Jul 2005Posts: 87
Hi,
I have an I/P file with LRECL 80, FB
ID Amounts CR/DR
--- ---------- -------
10 100.00 CR
10 200.00 DR
10 100.00 DR
My O/P should be
10 200.00 DR
ID -> Start position =1, length 2
Amounts -> Start position 3, length=10. Amounts are not in SFF format. its in ZZZ.99 format.
CR/DR -> Start position 13, length=2
Here the Amounts are in displayable format (ZZZ.99)
Can you please let me know how to do this using DFSORT?
Regards,
Kiran.
Regards,
Chinni.
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
chinnielr,
If you sum the amounts it would be 10 200.00 DR , not 100.00 DR
I assumed CR is positive amounts and DR is negative amounts. The following JCL will give you the desired results
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
10 100.00CR
10 200.00DR
10 100.00DR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=(13,2,CH,EQ,C'CR'),
OVERLAY=(81:C'+',3,10,81,11,SFF,PD,LENGTH=8)),
IFTHEN=(WHEN=(13,2,CH,EQ,C'DR'),
OVERLAY=(81:C'-',3,10,81,11,SFF,PD,LENGTH=8))
SORT FIELDS=(1,2,CH,A)
SUM FIELDS=(92,8,PD)
OUTREC IFOUTLEN=80,
IFTHEN=(WHEN=(92,8,PD,LT,0),
OVERLAY=(3:92,8,PD,EDIT=(IIIIIII.IT),C'DR')),
IFTHEN=(WHEN=NONE,
OVERLAY=(3:92,8,PD,EDIT=(IIIIIII.IT),C'CR'))
/*
Back to top
chinnielr New User Joined: 11 Jul 2005Posts: 87
Hi Kolusu,
Thanks for your kind reply. Can you please explain me the below syntax.
OVERLAY=(81:C'+',3,10,81,11,SFF,PD,LENGTH=8))
Regards,
Chinni.
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
chinnielr,
You have the Amounts in CR and DR form. We need to convert them into positive and negative numbers inorder to sum.
So using an IFTHEN we look at the CR/DR flag and put and + or - negative sign in 81st byte followed by your amount field from pos 3 for 10 bytes
so now your Amount field looks like this at pos 81 for 11 bytes which would look like SFF format.
Code:
+ 100.00
- 200.00
- 100.00
Now we take that 11 SFF bytes from pos 81 for and convert it into packed decimal format for a length of 8 bytes
Once we have summed the values we convert it back again to CR and DR format
Back to top
chinnielr New User Joined: 11 Jul 2005Posts: 87
Hi Kolusu,
I am glad to see you response. Thanks. Can you kindly let me know how you decided 8 bytes for PD?
Thanks and regards,
Chinni.
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
chinnielr,
Packed-decimal(PD) items occupy 1 byte of storage for every two decimal digits and the rightmost byte contains only one digit and the sign. Since your input is only 10 bytes of decimal digits data I chose 8 bytes of Packed decimal format as we are summing.
Back to top
Please enable JavaScript!