Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COBOL numberic conversion S999V99

Status
Not open for further replies.

nixie21

Programmer
Jul 19, 2005
16
US
I have a input file with values defined as S999V99. In the input file one field shows as

0050{

I move this to a field defined as S999V99
I display this field in my program and it looks like 00511-

If I say sign is trailing, I get the same result. How do I deal with this?

Thanks
 
What's the issue? Are you wanting it to display with the decimal point (move it to ZZ9.99)? Or the position of the sign?

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Or ++9.99 if you want the sign to show.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Ok, I am working on a HP-UX machine (if that matters)

I read the record and for a test did this:

i-fine-amt pic S999V99
sum-amt-vl pic 9(3)v99

move i-fine-amt to sum-amt-vl.

display i-fine-amt " " sum-amt-vl.

The display is:
00511- 00511

How can i-fine-amt = 00511- if defined as S999V99 and in the input file shows as 0050{

Thanks

 
Okay, you have the field defined as S9(3)v99 (basically), which in COBOL is saying that you want to store a sign. The V is an IMPLIED decimal point, which means it won't show unless you explicitly move it to a field which directs it to be displayed. I gave two examples of that.

As for the input file, viewing it in hex would yield more insight into what you are looking at and would help us more. But it seems you are doing something to place a negative value into this field.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Doing a straight display without moving or changing the field at all shows 00511- which means that the file is not being read correctly by COBOL? I cant get mediafire to display my screenshot of the file, but the value in the file looks like - 0050{

Cobol does a read and then a display without changing anything as 00511-
 
Do you know what "viewing it in hex" means? "0050{" is not hex.

We established now that the value comes from a file. Correct? Are you sure you got the file format defined correctly within your program?

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Yes, from a file and correctly defined.

The value of 0050{ is showing as

30 30 35 30 7B - is this what you needed?
 
Think I found the problem. The file is in EBCDIC, I have to convert the values to ASCII.

Thanks
 
The hex values you showed are ascii, not EBCDIC. This is the correct hex value for -5.07 per the PICture you are using. To get the decimal point to show with a leading appended sign you need to move the data to a field with a PICture of --9.99 or ++9.99 (per your needs. the former will not show a + for positive, the latter will show a + or a -, depending on the sign).
 
some idea about the last byte with a sign....

Code:
+10  =  1{       +01  =  0A         +0  =  {
+09  =  0I       +02  =  0B         +1  =  A
+08  =  0H       +03  =  0C         +2  =  B
+07  =  0G       +04  =  0D         +3  =  C                +    -/-
+06  =  0F       +05  =  0E         +4  =  D              ------------
+05  =  0E       +06  =  0F         +5  =  E                {  0  }
+04  =  0D       +07  =  0G         +6  =  F                A  1  J
+03  =  0C       +08  =  0H         +7  =  G                B  2  K
+02  =  0B       +09  =  0I         +8  =  H                C  3  L
+01  =  0A       -01  =  0J         +9  =  I                D  4  M
+00  =  0{       -02  =  0K         -1  =  J                E  5  N
-01  =  0J       -03  =  0L         -2  =  K                F  6  O
-02  =  0K       -04  =  0M         -3  =  L                G  7  P
-03  =  0L       -05  =  0N         -4  =  M                H  8  Q
-04  =  0M       -06  =  0O         -5  =  N                I  9  R
-05  =  0N       -07  =  0P         -6  =  O
-06  =  0O       -08  =  0Q         -7  =  P
-07  =  0P       -09  =  0R         -8  =  Q
-08  =  0Q       +00  =  0{         -9  =  R
-09  =  0R       +10  =  1{         -0  =  }
-10  =  1}       -10  =  1}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top