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
 

 

Sum the values in alphanumeric format

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 151
Location: India

PostPosted: Sat Oct 15, 2011 3:10 am    Post subject: Sum the values in alphanumeric format
Reply with quote

My requirement is sum the amount in the file that is declared as alphanumeric (X15) as mentioned below

Input layout
01 WS-ITEM PIC 9(3)
01 FILLER PIC X(2)
01 WS-PREM PIC X(15)

Code:
123              100.50
123             -250.50
123            -1000.50
234                1.25
234               -1.25


Ouput should be
Code:
123            -1150.50
234                0.00

I have tried converting char format to ZD using UFF, M11 however it is not taking the signed format. Here we need to consider the -ve sign too.

Please help or guide me how to accomplish this task using DFSORT

Thanks
Vinu
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Sat Oct 15, 2011 3:20 am    Post subject: Reply to: Sum the values in alphanumeric format
Reply with quote

What do you think the "U" in UFF might mean?

This topic is using a trailing sign. See if you can get to a leading sign.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Sat Oct 15, 2011 3:32 am    Post subject: Reply to: Sum the values in alphanumeric format
Reply with quote

Assuming the data is sorted on the first 3 bytes, the following DFSORT JCl will give you the desired results. If the data is not sorted , change the

Code:

  SORT FIELDS=COPY


to

Code:

  SORT FIELDS=(1,3,CH,A)


Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                   
----+----1----+----2----+----3----+----4----+----5----+----6----+--
123           100.50                                               
123          -250.50                                               
123         -1000.50                                               
234             1.25                                               
234            -1.25                                               
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
  OUTFIL REMOVECC,NODETAIL,                                       
  SECTIONS=(1,3,                                                   
  TRAILER3=(1,3,X,                                                 
            TOT=(6,15,SFF,EDIT=(SIIIIIIIIIIIIIIT.TT),SIGNS=(,-))))
//*     
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 151
Location: India

PostPosted: Thu Nov 03, 2011 10:38 pm    Post subject:
Reply with quote

Thanks Kolusu. This works like a charm.

Regards
Vinu
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 Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm
No new posts How to pick only YYMMDD from DATE1P (... atulbaviskar SYNCSORT 7 Wed Mar 22, 2017 11:39 am


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