Page 1 of 1

Mulitply two fields in a record

PostPosted: Thu Jan 03, 2013 1:31 am
by Puffe
Hi,

I want to multiply two fields in a record and create a new field in that record. The file is FB with LRECL=20.
In position 1-3 is an integer-field (actually percentage) and i position 10-18 a numeric zoned value with two decimals.

File A
075ABCDEF001000.00GH

The result I want is:
075ABCDEF001000.00GH000750.00

so field 21-29 is the amount of 075% * 001000.00.

Suggestion how I fix this in DFSORT ?

Best regards,

Micke S

Re: Mulitply two fields in a record

PostPosted: Thu Jan 03, 2013 2:35 am
by tivrfoa
Hi,

You can use OUTREC and MUL.
http://publib.boulder.ibm.com/infocente ... cg4021.htm

try:
OUTREC OVERLAY=(21:(1,3,ZD,DIV,100),MUL,10,8,ZD)

Re: Mulitply two fields in a record

PostPosted: Thu Jan 03, 2013 2:36 am
by skolusu
//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
----+----1----+----2----+----3----+----4----+----5----+----6----+---
075ABCDEF003230.00GH                                               
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC OVERLAY=(21:(1,3,ZD,MUL,10,9,UFF),DIV,+100,EDIT=(TTTTTT.TT))
//*

Re: Mulitply two fields in a record

PostPosted: Thu Jan 03, 2013 3:10 am
by BillyBoyo
tivrfoa,

Always do any division last. If you do it first, you will loose significant digits before anything else is done with the values.

Re: Mulitply two fields in a record

PostPosted: Thu Jan 03, 2013 11:05 am
by Puffe
Thank You very much !!!