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
 

 

[Solved]Move Char(X) to Num(9)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
kvivek

New User


Joined: 09 May 2005
Posts: 51
Location: Singapore

PostPosted: Tue May 10, 2005 1:31 pm    Post subject: Move Char(X) to Num(9)
Reply with quote

Hi All,

Case1:
Var1 Pic X(05) = '900 '
Move var1 to var2
Var2 Pic 9(05) = '900 '

Case2:
Var1 Pic X(05) = '90 '
Move var1 to var2
Var2 Pic 9(05) = '90 '

Is it possible to get the same as Var2 = 00900 in case1 and Var2 = 00090 in case2 without adding extra logic like traverse till first space?

Thanks,
Vivek
Back to top
View user's profile Send private message

ankyhunk

Moderator


Joined: 05 May 2005
Posts: 98
Location: Navi Mumbai, India

PostPosted: Tue May 10, 2005 5:10 pm    Post subject:
Reply with quote

You can use the picture clause as ZZ999 for a var. And move the value to that var. If this doesnt answer yr question, then elaborate.
Back to top
View user's profile Send private message
kvivek

New User


Joined: 09 May 2005
Posts: 51
Location: Singapore

PostPosted: Tue May 10, 2005 7:31 pm    Post subject:
Reply with quote

Hi Ankur,

Thanks for your reply, Please note that in both the cases I have used the same varaiables and it could have different values in different case.

In case1 Var1 has three charasters and two spaces.

In case2 Var1 has two characters and three spaces.

If I move Var1 to Var2 directly then i will be getting S0C7 when using Var2.

I would like to move Var1(1:3) to Var2 (Case1) and Var1(1:2) to Var2(Case2). Since X is a variable part in Var1(1:X), I have added a logic to identify the first occurace of space (i.e. value for X).

Is it possible to move directly Var1 to Var2 in both the cases without spaces?

Note: I don't want to use String function.

Thanks,
Vivek
Back to top
View user's profile Send private message
ankyhunk

Moderator


Joined: 05 May 2005
Posts: 98
Location: Navi Mumbai, India

PostPosted: Tue May 10, 2005 8:12 pm    Post subject:
Reply with quote

If I am not wrong you want to convert alphanumeric data into a number which can be used for calculations. For this, you can use the NUMVAL function i.e. var2 = NUMVAL(var1).
Let me know any concerns. You can also refer cobol manuals on this site for more clarifications.
Back to top
View user's profile Send private message
kvivek

New User


Joined: 09 May 2005
Posts: 51
Location: Singapore

PostPosted: Tue May 10, 2005 8:44 pm    Post subject:
Reply with quote

Hi Ankur,

This is what exactly i wanted, Thanks a lot for information.

Thanks,
Vivek
Back to top
View user's profile Send private message
rohit_k21

New User


Joined: 06 Jun 2005
Posts: 2
Location: India-Pune

PostPosted: Mon Jun 06, 2005 7:23 pm    Post subject:
Reply with quote

you can use redefine clause, this way
01 Var1 Pic X(05)

01 var3 redefine var1 pic 9(05).


this way you can use VAR3 as numerical data.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:23 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:21 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am


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