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
 

 

Alphanumeric to decimal conversion logic

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

Active User


Joined: 02 Oct 2008
Posts: 151
Location: India

PostPosted: Tue Apr 16, 2013 11:00 am    Post subject: Alphanumeric to decimal conversion logic
Reply with quote

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
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Apr 16, 2013 11:38 am    Post subject: Reply to: Alphanumeric to decimal
Reply with quote

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.
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Tue Apr 16, 2013 11:39 am    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
mistah kurtz

Active User


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

PostPosted: Tue Apr 16, 2013 11:42 am    Post subject:
Reply with quote

Check out the below post:

http://ibmmainframes.com/about56428.html
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 151
Location: India

PostPosted: Tue Apr 16, 2013 9:02 pm    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8120
Location: East Dubuque, Illinois, USA

PostPosted: Tue Apr 16, 2013 9:21 pm    Post subject:
Reply with quote

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.
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 Need help in building a logic Benchwarmer All Other Mainframe Topics 4 Wed Feb 22, 2017 2:49 am
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 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 File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm


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