Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 154
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: 7314

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: 154
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 LOW VALUES as a KEY juares castro DB2 10 Sat Apr 07, 2018 1:06 am
No new posts Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am
No new posts Unloading DB2 table in CSV format alo... grvtomar COBOL Programming 7 Sun Jan 28, 2018 2:05 am
No new posts attchmvs from rexx subroutine that re... harisukumaran CLIST & REXX 1 Fri Jan 19, 2018 5:29 am
No new posts Sum the fields in particular format f... sharana64 DFSORT/ICETOOL 9 Fri Jan 05, 2018 1:11 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us