View previous topic :: View next topic
|
Author |
Message |
kvivek
New User
Joined: 09 May 2005 Posts: 51 Location: Singapore
|
|
|
|
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 |
|
|
ankyhunk
Moderator
Joined: 05 May 2005 Posts: 98 Location: Navi Mumbai, India
|
|
|
|
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 |
|
|
kvivek
New User
Joined: 09 May 2005 Posts: 51 Location: Singapore
|
|
|
|
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 |
|
|
ankyhunk
Moderator
Joined: 05 May 2005 Posts: 98 Location: Navi Mumbai, India
|
|
|
|
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 |
|
|
kvivek
New User
Joined: 09 May 2005 Posts: 51 Location: Singapore
|
|
|
|
Hi Ankur,
This is what exactly i wanted, Thanks a lot for information.
Thanks,
Vivek |
|
Back to top |
|
|
rohit_k21
New User
Joined: 06 Jun 2005 Posts: 2 Location: India-Pune
|
|
|
|
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 |
|
|
|