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

Author Message
vinu78

Active User

Joined: 02 Oct 2008
Posts: 155
Location: India

Posted: Tue Apr 16, 2013 11:00 am    Post subject: Alphanumeric to decimal conversion logic

Hi All,

My reqt is to accept alphanumeric value as input and the output should be as mentioned below.

01 WS-INPUT PIC X(10)
01 WS-OUTPUT PIC X(10)

 Code: Input                  Output 4006.65             0004006650             905.65             0000905650   1                 0000001000

Reason for above conversion
The output will be passed to another existing logic that is defined as 9(6)V9(3). So the values will be read and passed to further downstream as 4006.65, 905.65, 1.00

Please help in coming with the conversion logic. I have tried with NUMVAL however not able to achieve the result.

Thanks
Vinu

Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Tue Apr 16, 2013 11:38 am    Post subject: Reply to: Alphanumeric to decimal Where are you not getting the result? And what result are you getting? 9(6)V9(3) is only nine bytes, so it you think it 10, that could be the problem. V is an implied, not actual decimal place, so if you expect ".", that could be the problem. As long as all the input data are valid, NUMVAL should do what you want. If the data are not all valid, NUMVAL will turn it's nose up at the first one it doesn't like, and an abend will ensue, so be sure.
chandan.inst

Active User

Joined: 03 Nov 2005
Posts: 271
Location: Mumbai

 Posted: Tue Apr 16, 2013 11:39 am    Post subject: Hi, Agree with BIll.. Even You can try below approach. This is untested 1. Unstring INPUT fields in two numeric fields with delimited by '.' 2. Multiply 1st part of ustring output by 1000 and then add later part of unstring output to multiplication result I might be missing something here so its better try out and play around the logic Also it will be better if you show us how you have used Numval and provide answers to Bill's question Regards, Chandan
mistah kurtz

Active User

Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

 Posted: Tue Apr 16, 2013 11:42 am    Post subject: Check out the below post: http://ibmmainframes.com/about56428.html
vinu78

Active User

Joined: 02 Oct 2008
Posts: 155
Location: India

 Posted: Tue Apr 16, 2013 9:02 pm    Post subject: Hi Bill, I have tried the following: 01 WS-INPUT PIC X(10). 01 WS-TEMP PIC 9(7)V9(3). COMPUTE WS-TEMP = FUNCTION NUMVAL (WS-INPUT). MOVE WS-TEMP TO WS-INPUT. While compiling, I am getting the error message at the COMPUTE step as follows: "WS-TEMP (NUMERIC NON-INTEGER)" and "WS-INPUT(ALPHANUMERIC)" did not follow the statement compatibility rules. The statement was discarded. Then I tried changing the WS-INPUT as 9(10) and got the following error: Function argument "WS-INPUT" did not have the correct type for function "NUMVAL". The statement was discarded. Not sure how to get rid of this error. Plz help. Thanks Vinu
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8406
Location: Dubuque, Iowa, USA

 Posted: Tue Apr 16, 2013 9:21 pm    Post subject: The statement compatability rules error is due to you attempting to move an alphanumeric variable to a numeric variable with a decimal point. The invalid function argument is because NUMVAL only works on alphanumeric variables; numbers are already numeric and valued.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Comparing Signed Packed decimal and p... Virendra Shambharkar SYNCSORT 2 Wed Nov 14, 2018 9:37 am RPG II Problem with unsigned Packed d... Andi1982 All Other Mainframe Topics 6 Tue Sep 11, 2018 6:11 pm Code char set conversion from IBM-420... thelefthandofdarkness IBM Tools 4 Thu Jul 26, 2018 3:03 pm How can I convert charactor to fixed ... liying DFSORT/ICETOOL 7 Tue May 22, 2018 3:35 pm Removing the period or dot from the v... gopinak COBOL Programming 6 Wed May 09, 2018 1:53 pm

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