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

How to handle a signed numeric filed with dot and decimals?


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

New User


Joined: 15 May 2008
Posts: 1
Location: bangalore

PostPosted: Fri Jun 20, 2008 5:52 pm
Reply with quote

Hi,

I need to read an amount filed x(12) field from a flat file and move it into s9(9)v99 format. My client is preparing the flat file with decimal point and sign, we dont have any other option but to receiving it into X(12) field. I had made a work aroung using redifines clause, which was working fine with +ve sign. If the amount have -Ve sign my program is abending.

For ex: if value is -90000.90 in x(12) filed, how can I move this to
S9(9)v99 field. I am having issues with handling the sign.

Thanks a lot for you help.
Heman.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jun 20, 2008 5:56 pm
Reply with quote

Code:
in-field   pic -999999999.99.

out-field pic s9(9)v99.

move in-field to out-field.


That will work with most current versions of COBOL.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Jun 20, 2008 5:56 pm
Reply with quote

COMPUTE NUMERICVARIABLE = FUNCTION NUMVAL (XVARIABLE) .
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jun 22, 2008 3:40 am
Reply with quote

Here's something to consider:

If you have 9 significant digits before the decimal point for any value occurence for the field, you will truncate the the sign. Not a prob if the sign is pos; bad if it's neg.

If your I/P fld only contains 8 integer digits you can change the O/P fld to S9(8)V99 when using NUMVAL.
Back to top
View user's profile Send private message
Max Payne

New User


Joined: 13 Dec 2007
Posts: 10
Location: Shanghai

PostPosted: Tue Jun 24, 2008 1:42 pm
Reply with quote

-90000.90 in x(12)

you mean BBB-90000.90 or -90000.90BBB?
Back to top
View user's profile Send private message
star_dhruv2000

New User


Joined: 03 Nov 2006
Posts: 87
Location: Plymouth, MN USA

PostPosted: Tue Jun 24, 2008 1:58 pm
Reply with quote

NUMVAL is right choice for you...

Appreciate ur effort Robert...


Cheers! icon_smile.gif
Happy coding
Back to top
View user's profile Send private message
ssk1711

New User


Joined: 16 Jun 2008
Posts: 40
Location: bangalore

PostPosted: Tue Jun 24, 2008 2:03 pm
Reply with quote

Robert Sample wrote:
COMPUTE NUMERICVARIABLE = FUNCTION NUMVAL (XVARIABLE) .



This will meet the requirement.
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Convert HEX to Numeric DB2 3
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts Handling the numeric data in unstring... COBOL Programming 18
No new posts Numeric check on packed signed and un... COBOL Programming 4
Search our Forums:

Back to Top