Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
JAYANT KUMAR SAHOO

New User

Joined: 15 Mar 2006
Posts: 14

 Posted: Fri Mar 24, 2006 12:41 pm    Post subject: C2D function in rexx not giving me correct result. 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.

superk

Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

 Posted: Fri Mar 24, 2006 4:19 pm    Post subject: Re: C2D function in rexx not giving me correct result. What exactly is it that you believe the C2D function does?
JAYANT KUMAR SAHOO

New User

Joined: 15 Mar 2006
Posts: 14

 Posted: Sat Mar 25, 2006 12:59 am    Post subject: C2D function in rexx not giving me correct 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
superk

Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

Posted: Sat Mar 25, 2006 1:20 am    Post subject: Re: C2D function in rexx not giving me correct result.

 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

Result "SUM 2023242000"
Marso

REXX Moderator

Joined: 13 Mar 2006
Posts: 1275
Location: Israel

 Posted: Mon Mar 27, 2006 3:03 pm    Post subject: In fact, if you add within the loop: SAY 'DATATYPE OF 'J.I' IS 'DATATYPE(J.I) you will see that J.I is already a number and there is no need for conversion. C2D is mostly used to transform a character into it's numeric value: C2D('A') returns 193 and C2D(1) returns 241 similarly, C2X('A') returns 'C1' (a 2 chars string)
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics GDG gen check using REXX raghuraman123 CLIST & REXX 6 Wed Apr 18, 2018 9:18 pm Handling result sets in the calling N... Rusikesh DB2 7 Fri Apr 13, 2018 12:25 am How to control Panel Attributes throu... rsshanmugam CLIST & REXX 3 Mon Feb 26, 2018 9:51 pm Find a string in PS file opened in br... mukkas CLIST & REXX 3 Sat Feb 24, 2018 2:15 pm WRITE to VSAM giving duplicate RC picus_mf CICS 1 Fri Feb 23, 2018 2:52 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us