View previous topic :: View next topic
|
Author |
Message |
muhammad
New User
Joined: 25 Oct 2007 Posts: 19 Location: hyderabad
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
muhammad
New User
Joined: 25 Oct 2007 Posts: 19 Location: hyderabad
|
|
|
|
so.. no solution for this??? |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
star_dhruv2000
New User
Joined: 03 Nov 2006 Posts: 87 Location: Plymouth, MN USA
|
|
|
|
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! |
|
Back to top |
|
|
|