Hi All,
I am using a rexx routine to get the sum of a particular numeric field for all the records present in a file.The numeric field appears in the input file at pos 55-64.
suppose my input file has 2 records having nos
1011621000
1011621000
in 55-64 pos then the sum should be 2023242000
I am using the below code
ADDRESS TSO
"ALLOC FI(DD1) DA('F3674AO.PDTEST.OUT.REC3.IN') SHR REUS"
"ALLOC FI(DD4) DA('F3674AO.PDTEST.OUT.REC3.OUT') SHR REUS"
"EXECIO * DISKR DD1 (FINIS STEM A."
SUM = 0
DO I = 1 TO A.0
J.I = SUBSTR(A.I,55,10)
SUM = SUM + C2D('J.I')
END
"EXECIO * DISKW DD4 (FINIS STEM J."
SAY 'SUM' SUM
I know somewhere the C2D function is wrong and thats why I am not getting the proper result.Can anybody tell me how to achieve the same result.
C2D is the decimal representation of the binary character string.Maybe I am wrong in my concept to use that for my rexx.
Could you please help me out for the same problem by providing the sample rexx code.
I am using a rexx routine to get the sum of a particular numeric field for all the records present in a file.The numeric field appears in the input file at pos 55-64.
suppose my input file has 2 records having nos
1011621000
1011621000
in 55-64 pos then the sum should be 2023242000
Joined: 26 Apr 2004 Posts: 3314 Location: Charlotte,NC USA
Code:
"EXECIO * DISKR DD1 (FINIS STEM A."
SUM = 0
DO I = 1 TO A.0
J.I = SUBSTR(A.I,55,10)
SUM = SUM + J.I
END
"EXECIO * DISKW DD4 (FINIS STEM J."
SAY 'SUM' SUM