Mulitply two fields in a record



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Mulitply two fields in a record

Postby Puffe » Thu Jan 03, 2013 1:31 am

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
Puffe
 
Posts: 21
Joined: Mon May 02, 2011 1:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Mulitply two fields in a record

Postby tivrfoa » Thu Jan 03, 2013 2:35 am

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)
tivrfoa
 
Posts: 84
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 60 times
Been thanked: 0 time

Re: Mulitply two fields in a record

Postby skolusu » Thu Jan 03, 2013 2:36 am

//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))
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

These users thanked the author skolusu for the post:
tivrfoa (Thu Jan 03, 2013 2:52 am)
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Mulitply two fields in a record

Postby BillyBoyo » Thu Jan 03, 2013 3:10 am

tivrfoa,

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

These users thanked the author BillyBoyo for the post:
tivrfoa (Thu Jan 03, 2013 3:16 am)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Mulitply two fields in a record

Postby Puffe » Thu Jan 03, 2013 11:05 am

Thank You very much !!!
Puffe
 
Posts: 21
Joined: Mon May 02, 2011 1:41 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post