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: 129
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: 7251

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: 129
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 SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am


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