MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Addition and Multiplication of Fields

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
davinski.bby
Beginner


Joined: 30 Jul 2007
Posts: 31
Topics: 10

PostPosted: Tue Aug 21, 2007 5:21 pm    Post subject: Addition and Multiplication of Fields Reply with quote

Hi,

I have a dataset which has the following fields:
Code:

PRODUCT AVERAGE-COST QTY-SENT QTY-RECVD 
3/AN    5/PS         3/PS      3/PS     
(1-3)   (4-8)        (9-11)    (12-14)   
-----------------------------------------
AAA          100.000        1         2 
BBB           50.000        1         4 
CCC          200.225        1         2 


Code:

AVERAGE-COST    PIC S9(6)V999 COMP-3.
QTY-SENT             PIC S9(05)    COMP-3.
QTY-RECVD           PIC S9(05)    COMP-3.


I need to get the total sum of the AVERAGE COST fields but I need to get first the total average cost by

"Total Average Cost = (QTY-RECVD - QTY-SENT)* AVERAGE-COST"

then get the total sum of the TOTAL-AVE-COST for all records.

In this example, the desired output would be:

Total sum is 450.225

Can this be done in a JCL?

Thanks.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Aug 21, 2007 5:42 pm    Post subject: Reply with quote

Here's a DFSORT job that will do what I think you're asking for:

Code:

/S1    EXEC  PGM=ICEMAN                                       
/SYSOUT    DD  SYSOUT=*                                       
/SORTIN DD DSN=...  input file
/SORTOUT DD SYSOUT=*                                           
/SYSIN    DD    *                                             
  OPTION COPY                                                   
  INREC BUILD=(1:(9,3,PD,SUB,6,3,PD),MUL,1,5,PD,TO=PD,LENGTH=5,
     25:X)                                                       
  OUTFIL REMOVECC,NODETAIL,                                     
    TRAILER1=('Total sum is ',TOT=(1,5,PD,EDIT=(IIIIIT.TTT)))   


For your input example, SORTOUT will have one record with:

Code:

Total sum is    450.225 


For more information on using arithmetic with DFSORT, see:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG20/2.4.10?DT=20060615173822
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
davinski.bby
Beginner


Joined: 30 Jul 2007
Posts: 31
Topics: 10

PostPosted: Tue Aug 21, 2007 8:15 pm    Post subject: Reply with quote

Thanks Frank! It worked!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group