Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

C2D function in rexx not giving me correct result.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
JAYANT KUMAR SAHOO

New User


Joined: 15 Mar 2006
Posts: 14

PostPosted: Fri Mar 24, 2006 12:41 pm    Post subject: C2D function in rexx not giving me correct result.
Reply with quote

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.
Back to top
View user's profile Send private message

superk

Moderator Team Head


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

PostPosted: Fri Mar 24, 2006 4:19 pm    Post subject: Re: C2D function in rexx not giving me correct result.
Reply with quote

What exactly is it that you believe the C2D function does?
Back to top
View user's profile Send private message
JAYANT KUMAR SAHOO

New User


Joined: 15 Mar 2006
Posts: 14

PostPosted: Sat Mar 25, 2006 12:59 am    Post subject: C2D function in rexx not giving me correct result.
Reply with quote

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
Back to top
View user's profile Send private message
superk

Moderator Team Head


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

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

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"
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1226
Location: Israel

PostPosted: Mon Mar 27, 2006 3:03 pm    Post subject:
Reply with quote

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)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Is the explanation correct? XRST,CHKP Martylin IMS DB/DC 1 Wed Mar 15, 2017 9:26 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts scheduling between OPC and TWS give u... nsbl IBM Tools 3 Sun Mar 12, 2017 5:35 pm
No new posts REXX cdoe to purge a JOB from spool a... Sulabh Agrawal CLIST & REXX 11 Thu Mar 09, 2017 11:36 am
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us