×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

COBOL numberic conversion S999V99

COBOL numberic conversion S999V99

COBOL numberic conversion S999V99

(OP)
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

RE: COBOL numberic conversion S999V99

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.

RE: COBOL numberic conversion S999V99

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.

RE: COBOL numberic conversion S999V99

(OP)
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

 

RE: COBOL numberic conversion S999V99

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.

RE: COBOL numberic conversion S999V99

(OP)
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-

RE: COBOL numberic conversion S999V99

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.

RE: COBOL numberic conversion S999V99

(OP)
Yes, from a file and correctly defined.

The value of 0050{ is showing as

30 30 35 30 7B - is this what you needed?

RE: COBOL numberic conversion S999V99

(OP)
Think I found the problem.  The file is in EBCDIC, I have to convert the values to ASCII.

Thanks

RE: COBOL numberic conversion S999V99

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).

RE: COBOL numberic conversion S999V99

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}

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close