IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sorting amounts and find their difference using sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chinnielr

New User


Joined: 11 Jul 2005
Posts: 87

PostPosted: Wed Feb 18, 2009 8:51 pm
Reply with quote

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
View user's profile Send private message
chinnielr

New User


Joined: 11 Jul 2005
Posts: 87

PostPosted: Wed Feb 18, 2009 9:38 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Feb 18, 2009 9:55 pm
Reply with quote

chinnielr,

If you sum the amounts it would be 10 200.00DR , 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
View user's profile Send private message
chinnielr

New User


Joined: 11 Jul 2005
Posts: 87

PostPosted: Wed Feb 18, 2009 11:35 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Feb 18, 2009 11:52 pm
Reply with quote

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
View user's profile Send private message
chinnielr

New User


Joined: 11 Jul 2005
Posts: 87

PostPosted: Thu Feb 19, 2009 12:03 am
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Feb 19, 2009 12:26 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top