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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to handle a signed numeric filed with dot and decimals?
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    Post subject:
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: 7999
Location: Bellevue, IA

PostPosted: Fri Jun 20, 2008 5:56 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    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 Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How can we have the varying lenth of ... Gunapala CN DFSORT/ICETOOL 6 Fri Oct 14, 2016 7:31 pm
No new posts hot to get details when "EXEC CI... Andi1982 CICS 11 Tue Sep 20, 2016 5:01 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm


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