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
 

 

Problem in Summing Fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 75
Location: India

PostPosted: Mon Feb 11, 2008 6:26 pm    Post subject: Problem in Summing Fields
Reply with quote

Hi,

I have an i/p field as :
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
123/2345 400.00        AAA2345                                         
123/4986 300.00        BBB4986                                         
123/4986 250.00        BBB1532                                         
123/4986-100.00        BBB8901                                         
999/000  800.00        OOO5532                                         
999/000 -100.00        OOO6981                                         
123/5960 200.00        XYZ5960                                         
123/5960 200.00        XYZ1135                                         


The 1st field is 8 bytes, 2nd field is 15 bytes and 3rd field is 20 bytes

I want the o/p as:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8-
123/2345 400.00       AAA                                                     
123/4986 450.00       BBB                                                     
123/5960 400.00       XYZ                                                     
999/000  800.00       OOO5532                                                 
999/000 -100.00       OOO6981                                                 


However when i use the JCL as:
Code:
//STEP1 EXEC PGM=SYNCTOOL                   
//TOOLMSG DD SYSOUT=*                       
//DFSMSG DD SYSOUT=*                       
//INDD DD *                                 
123/2345 400.00        AAA2345             
123/4986 300.00        BBB4986             
123/4986 250.00        BBB1532             
123/4986-100.00        BBB8901             
999/000  800.00        OOO5532             
999/000 -100.00        OOO6981             
123/5960 200.00        XYZ5960             
123/5960 200.00        XYZ1135             
/*                                         
//OUTDD DD SYSOUT=*                         
//TOOLIN DD *                               
  SORT FROM(INDD) TO(OUTDD) USING(CNT1)     
/*                                         
//CNT1CNTL DD *                             
  INREC IFTHEN=(WHEN=(1,8,CH,NE,C'999/000'),
  OVERLAY=(9:9,15,SFF,TO=ZD,LENGTH=15,27:17X,44:8C'0')),
  IFTHEN=(WHEN=(1,8,CH,EQ,C'999/000'),                 
  OVERLAY=(9:9,15,SFF,TO=ZD,LENGTH=15,44:SEQNUM,8,ZD)) 
  SORT FIELDS=(1,8,CH,A,44,8,ZD,A)                     
  SUM FIELDS=(9,15,ZD)                                 
  OUTREC IFTHEN=(WHEN=(1,8,CH,NE,C'999/000'),           
  OVERLAY=(9:9,15,ZD,TO=FS,LENGTH=15,44:37X)),         
  IFTHEN=(WHEN=(1,8,CH,EQ,C'999/000'),                 
  OVERLAY=(9:9,15,ZD,TO=FS,LENGTH=15,44:37X))           
/*


The o/p comes as:
Code:
123/2345         +40000AAA   
123/4986         +45000BBB   
123/5960         +40000XYZ   
999/000          +80000OOO5532
999/000          -10000OOO6981
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Mon Feb 11, 2008 8:33 pm    Post subject:
Reply with quote

Are you guaranteeing that the sum will always be less than six digits?
Is your problem that the summed values are not left justified and the positive sign is included?
Back to top
View user's profile Send private message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 75
Location: India

PostPosted: Tue Feb 12, 2008 10:17 am    Post subject:
Reply with quote

Hi CICS Guy

The SUM as well as the value might be of 15 digits as I mentioned that the 2nd field having length of 15 bytes. The o/p should be left justified without the positive sign but a -ve sign should be present if the result is -ve. Moreover the decimal point should also be included.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 4 Thu Mar 30, 2017 10:34 am
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am


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