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

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


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts How to move DB2 Installation HLQ DB2 4
Search our Forums:

Back to Top