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

Sum the values in alphanumeric format


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

Active User


Joined: 02 Oct 2008
Posts: 179
Location: India

PostPosted: Sat Oct 15, 2011 3:10 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Oct 15, 2011 3:20 am
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
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: 179
Location: India

PostPosted: Thu Nov 03, 2011 10:38 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top