Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sorting amounts and find their difference using sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sorting amounts and find their difference using sort
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    Post subject: Reply to: Sorting amounts and find their difference using so
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    Post subject: Reply to: Sorting amounts and find their difference using so
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    Post subject: Reply to: Sorting amounts and find their difference using so
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    Post subject: Reply to: Sorting amounts and find their difference using so
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    Post subject: Reply to: Sorting amounts and find their difference using so
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us