Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparision

Status
Not open for further replies.

venkat2003

Programmer
Feb 11, 2003
8
IN
Hi,

Just I want to know how to convert alphanumeric data item to numeric dataitem.

For example User will enter the amount filed as alphanumeric item as 1000.555 and sending this text amount to backend system. In back end I have to compare this text field to db2 data item is defined as s9(8)v99 comp-3. Please tell me the approache to do this req.

Thanks
Venkat
 
Hi Venkat,

More specifically, try this:
Code:
In WS

01 YOUR-VAR   PIC  X(008)    VALUE '1000.555'.
01 COMP3-VAR  PIC S9(008)V99 COMP-3.

In PD

COMPUTE COMP3-VAR 
      = FUNCTION NUMVAL YOUR-VAR

Regards, Jack.

The value 0000100055 will appear in COMP3-VAR. If you want to round up use:

COMPUTE COMP3-VAR ROUNDED
      = FUNCTION NUMVAL YOUR-VAR
 
Just a heads-up: the function NUMVAL uses floating-point arithmetic and may not always yield the result you expect.

Regards.

Glenn

P.S. Don't forget the parentheses:
Code:
COMPUTE COMP3-VAR ROUNDED
      = FUNCTION NUMVAL (YOUR-VAR)[\code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top