Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
kvivek

New User

Joined: 09 May 2005
Posts: 51
Location: Singapore

 Posted: Tue May 10, 2005 1:31 pm    Post subject: Move Char(X) to Num(9) 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

ankyhunk

Moderator

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

 Posted: Tue May 10, 2005 5:10 pm    Post subject: 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.
kvivek

New User

Joined: 09 May 2005
Posts: 51
Location: Singapore

 Posted: Tue May 10, 2005 7:31 pm    Post subject: 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
ankyhunk

Moderator

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

 Posted: Tue May 10, 2005 8:12 pm    Post subject: 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.
kvivek

New User

Joined: 09 May 2005
Posts: 51
Location: Singapore

 Posted: Tue May 10, 2005 8:44 pm    Post subject: Hi Ankur, This is what exactly i wanted, Thanks a lot for information. Thanks, Vivek
rohit_k21

New User

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

 Posted: Mon Jun 06, 2005 7:23 pm    Post subject: 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.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics RMM Cannot move a volume from SHELF l... tspr52 IBM Tools 0 Thu Mar 01, 2018 3:48 pm how can i move s9(9) to s9(9) usage comp HARENDRA CHOUDHARY COBOL Programming 3 Mon Nov 06, 2017 12:10 am Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us