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: 1224
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
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm


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