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

How to code the SUM Fields, If half of the field has spaces


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

New User


Joined: 15 Mar 2006
Posts: 13

PostPosted: Fri Apr 06, 2007 2:37 am
Reply with quote

Hi,

I would like to aggregate Products field based on Dept. I tried using sum fields control statement. But I am getting SOC7 since there is the Products field. DEPT is a 4 byte field and Products is a 10 byte field, Out of 10 fields only two fields have decimal values the rest 8 bytes are spaces.

Expected Output is given below

Input:

Code:

Dept  Products
----------------
0001        11
0001        91
0002        11
0002        11
0003        81
0003        11
0003        11


Output

Code:

0001       102
0002       022
0003       103
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Apr 06, 2007 3:07 am
Reply with quote

If your amount field is right-aligned, then you could use the following DFSORT statements and you wouldn't get an S0C7.

Code:

   OPTION ZDPRINT
   SORT FIELDS=(1,4,CH,A)
   SUM FIELDS=(5,10,ZD)


However, the output would not be what you want. It would be:

Code:

00010000000102
00020000000022
00030000000103


To get what you want you could use these DFSORT statements:

Code:

   SORT FIELDS=(1,4,CH,A)                         
   SUM FIELDS=(5,10,ZD)                           
   OUTREC OVERLAY=(5:5,10,ZD,EDIT=(IIIIIIITTT))   


The output would be:

Code:

0001       102
0002       022
0003       103
Back to top
View user's profile Send private message
chandrakanth_s

New User


Joined: 15 Mar 2006
Posts: 13

PostPosted: Fri Apr 06, 2007 7:29 pm
Reply with quote

Hi Frank,

Thanks for the help, it worked as expected.

Regards,
Chandrakanth
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 run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
Search our Forums:

Back to Top