IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Character to Arithemtic conversion in PL/I


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
hsbawari
Currently Banned

New User


Joined: 16 Sep 2008
Posts: 9
Location: chennai

PostPosted: Tue Sep 23, 2008 1:16 pm
Reply with quote

I have one character variable defined as

DCL X char(100);

However the current value in X is numeric with 4 digits say '0120'

Now I need to get this numeric value. how should my numeric variable declared in which I will hav the value extracted from the text?
Can any one help me??

Its a PL/I code.
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Tue Sep 23, 2008 2:09 pm
Reply with quote

This May Solve your problem
Code:
DCL X FIXED BINARY(31,0);
DCL Y CHAR(04) INIT('0123');
X=BINARY(Y);
Back to top
View user's profile Send private message
hsbawari
Currently Banned

New User


Joined: 16 Sep 2008
Posts: 9
Location: chennai

PostPosted: Tue Sep 23, 2008 3:10 pm
Reply with quote

yeah thanks

I got another one without using built in function

DCL TIME_CHAR CHAR(4) INIT('');
DCL TIME_VALID PIC'(4)9' BASED(ADDR(TIME_CHAR));

TIME_VALID=string_char

/* this would work fine now string_char can be any character string*/
Back to top
View user's profile Send private message
Cary

New User


Joined: 23 Sep 2008
Posts: 3
Location: China

PostPosted: Wed Sep 24, 2008 7:26 am
Reply with quote

can not we move char to pic?

DCL TIME_CHAR CHAR(04);
DCL TIME_V PIC '9999'
TIME_V = TIME_CHAR
when time_char is numeric,
it is ok?
Back to top
View user's profile Send private message
cheryala

New User


Joined: 20 Mar 2006
Posts: 46

PostPosted: Thu Oct 02, 2008 3:03 am
Reply with quote

1) dcl xchar char(04) init('1234');
dcl xpic pic'(9)4' based(addr(xchar));

now you can use XPIC variable in any arithmetic expressions instead of XCHAR variable..


2) what Cary has proposed is also correct..you can directly assign character string to pic variable ..
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
No new posts file manager is doing string conversion IBM Tools 3
No new posts Panvalet - 9 Character name - Issue c... CA Products 6
No new posts SMF Record Date conversion failing CLIST & REXX 1
Search our Forums:

Back to Top