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

I would like to convert the value in x(10) into 9(4)v9(3)


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

New User


Joined: 25 Oct 2007
Posts: 19
Location: hyderabad

PostPosted: Tue Jan 15, 2008 2:25 am
Reply with quote

01 SELL-COST PIC X(10)

01 NEW-COST PIC 9(4)V9(3)

guys..

i have CSV file that has sell-cost as a field.

I use unstring delimited by comma command and move the sell cost to SELL-COST. The first record has a value of 14.76. When i unstring into SELL-COST it has '14.76 ' but when i unstring into NEW-COST it has 4.76000

iam amazed to see '.' in a variable defined with pic 9(4)V9(3)

anyways.. my need is to move that 14.76 to NEW-COST and convert it as 0014760

SELL-COST wil have decimal numbers only.. it wont have any alphabets..

what should i do??? if i unstring to SELL-COST and move to NEW-COST then its showing the value '6 0000'

need some solution !!!!!!!
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Tue Jan 15, 2008 2:34 am
Reply with quote

CSV files are character files, for decimal fields they may include the decimal character and for negative amounts they may include a negative sign. The position of both the decimal character and the sign may varying depending on the number of significant digits.
Back to top
View user's profile Send private message
muhammad

New User


Joined: 25 Oct 2007
Posts: 19
Location: hyderabad

PostPosted: Tue Jan 15, 2008 2:36 am
Reply with quote

so.. no solution for this???
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Tue Jan 15, 2008 4:47 am
Reply with quote

Of course there is a solution. But it looks like you are going to have to do post processing on your own after reading into SELL-COST before moving it into the NEW-COST.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Jan 15, 2008 5:04 am
Reply with quote

Hi Muhammad,

The 1st thing you have to do is analyse your IP and determine the various forms the data can take. As Steve said they may contain minus signs: they may even contain commas (I hope not, because that opens a nasty can of worms).

Keep track of each of the formats and note the details. Once you've done that, you s/b ready to code, then show us the results of the analyses.
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: Fri Feb 15, 2008 9:45 pm
Reply with quote

Hi Muhammad,

I think you should use NUMVAL FUNCTION for this. Following is an example for this

Code:
01 SELL-COST PIC X(10).
01 NEW-COST PIC 9(4)V9(3).

      ACCEPT SELL-COST.
      COMPUTE NEW-COST = FUNCTION NUMVAL(SELL-COST).


NUMVAL is an IBM supplied FUNCTION using which we can stip numeric data from an alpha-numeric field. Moreover output will be in form of recieving field.

Hope this will resolve your poblem.

Cheers! icon_smile.gif
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 Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
No new posts Convert HEX to Numeric DB2 3
Search our Forums:

Back to Top