Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all articles
Browse latest Browse all 9405

DFSORT/ICETOOL :: RE: Performing arithmetic on input field

$
0
0
Author: Arun Raj
Posted: Wed Dec 07, 2016 11:08 pm (GMT 5.5)

Quote:
Code:
987654321

My Input record

Code:
9 (2) + 8 + 7(2) + 6 + 5(2) + 4 + 3(2) + 1   
Multiplying every alternate digit with 2, starting from left.

From your original post, if it is every alternate digit, should it not be like this?

9 (2) + 8 + 7(2) + 6 + 5(2) + 4 + 3(2) + 2 + 1(2) = 70 * 9 = 630

You don't need to worry about the format of intermediate results because, as suggested you can do multiple computations one after the other, like this and edit only the final result.
Code:
//SORTIN  DD *                                     
987654321                                         
//SYSIN   DD *                                     
  OPTION COPY                                     
  OUTREC BUILD=((1,1,ZD,MUL,+2,ADD,               
                 2,1,ZD,ADD,                       
                 3,1,ZD,MUL,+2,ADD,               
                 4,1,ZD,ADD,                       
                 5,1,ZD,MUL,+2,ADD,               
                 6,1,ZD,ADD,                       
                 7,1,ZD,MUL,+2,ADD,               
                 8,1,ZD,ADD,                       
                 9,1,ZD,MUL,+2),MUL,+9,EDIT=(TTTT))
SORTOUT
Code:
 0630

_________________
Arun
----------------------------------------------------------------------------------------------------
Love is like an hourglass, with the heart filling up as the brain empties. -Jules Renard


Viewing all articles
Browse latest Browse all 9405

Latest Images

Trending Articles



Latest Images