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

Problem in Summing Fields


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 97
Location: India

PostPosted: Mon Feb 11, 2008 6:26 pm
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: 2146
Location: At my coffee table

PostPosted: Mon Feb 11, 2008 8:33 pm
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: 97
Location: India

PostPosted: Tue Feb 12, 2008 10:17 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
Search our Forums:

Back to Top