IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convert a string input entry to a numeric with format indica


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gr_mohanram

New User


Joined: 02 Aug 2003
Posts: 5

PostPosted: Fri Dec 02, 2005 5:07 pm
Reply with quote

We have been searching a solution to create a COBOL program which allows to convert a string input entry
to a numeric with format indications like examples below :

Input entry
"123" or "123.56" or ...
"999" or "999.99" or... (Output format wanted)

Output entry
123 or 123.56 or ...

We don't found any solution on the web (despite our's efforts), do someone
have a solution for this ?


Thanks in Advance,
Mohan.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Dec 02, 2005 6:35 pm
Reply with quote

Do you mean to remove quotes (") from the inout string & place the numeric value only to output string.

Regards,

Priyesh.
Back to top
View user's profile Send private message
gr_mohanram

New User


Joined: 02 Aug 2003
Posts: 5

PostPosted: Fri Dec 02, 2005 7:14 pm
Reply with quote

We found to resolve,

The follwoing is the resolution..

Example 1

77 ALPHA-NUM PIC X(16) VALUE "$ 123.45 CR ".
77 NUM PIC S9(5)V99.
PROCEDURE DIVISION.
010-PARA.
COMPUTE NUM = FUNCTION NUMVAL-C (ALPHA-NUM).
DISPLAY ALPHA-NUM.
DISPLAY NUM.
STOP RUN.

The above example displays the following:

$ 123.45 CR
-00123.45

Thanks for your efforts...
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Dec 02, 2005 7:18 pm
Reply with quote

Mohan,

I still didnt get ..whether ur prob resolved now.....

If not... Plz give input & output string....

Regards,

Priyesh.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Dec 03, 2005 9:02 am
Reply with quote

Mohan,

You didn't solve the whole problem you stated.

Using your solution for "123", I'm pretty sure DISPLAY NUM would produce 0123.00 not 123
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
Search our Forums:

Back to Top