View previous topic :: View next topic
|
Author |
Message |
amarjit singh
New User
Joined: 08 Mar 2013 Posts: 30 Location: india
|
|
|
|
hello,
i need your suggestion onthe following issue.
my program is reading input data into a copybook and
the copybook have field declared as:
05 PRICE OCCURS 80 PIC 9(5)V99.
earlier the price range was from 0 to 10000.00 (only +ve value)
but now the range varies from -1000.00 to 10000.00.
please suggest the change in picture clause for the price fileld to accomodate the negative value starting from -1000.00 to value 10000.00.
thanks. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Do you think maybe a sign (S) character is called for in the value? |
|
Back to top |
|
|
amarjit singh
New User
Joined: 08 Mar 2013 Posts: 30 Location: india
|
|
|
|
hi,
declaring as S9(5)v99 is giving '{' in the output. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Yes, that is correct . . . A pic 9 signed value contains the sign in the high-order nibble of the low-order byte. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Add on:
It is not clear (to me) what you are asking . . . |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
amarjit singh wrote: |
hi,
declaring as S9(5)v99 is giving '{' in the output. |
Exactly; "{" is the glyph in EBCDIC for X'C0'; i.e., positive zero. You are seeing signed zoned decimal.
Now, assuming you want "+" and/or "-" glyphs to be used, I recommend that you consider fixed or floating insertion editing, or the use of the SIGN clause. Note that these thing will change the size of variables. |
|
Back to top |
|
|
amarjit singh
New User
Joined: 08 Mar 2013 Posts: 30 Location: india
|
|
|
|
hi..
yes we want '-' only for -ve values without altering the variable field length. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Sorry, but you can only have one or the other. If you have 7 digits, it will take 8 to hold all 7 + the "-". |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
dick scherrer wrote: |
Hello,
Sorry, but you can only have one or the other. If you have 7 digits, it will take 8 to hold all 7 + the "-". |
Now that I think about it, in this special case, the value can be accommodated if a floating minus sign is used, since Amarjit assures us that -1000 is the smallest value that will be stored in the variable.
Of course, as soon as he comes back and says, "Well, my requirement is really...", all bets are off. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Or if the current maximum negative becomes larger, there would probably be problems later. . .
I'd recommend an implementation that could not come back to "bite" me. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If you have PIC 9(5)V99 and you want it "signed", then you make it PIC S9(5)V99, as was first suggested.
You mention it is a copybook, with an OCCURS 80. What is using the data which the copybook represents? If it is only a/some Cobol programs on the mainframe, they can fully understand what appears to you as {, } or a "letter of the alphabet".
So, what is reading the data you create? |
|
Back to top |
|
|
amarjit singh
New User
Joined: 08 Mar 2013 Posts: 30 Location: india
|
|
|
|
thanks all for your suggestion.
i did the following changes in copy book and it works fine..
01 price.
05 A OCCURS 80 TIMES.
10 B PIC 9(5)V99.
10 C REDEFINES B.
15 D PIC -9(4)V99.
in logic, when -ve amount, move amount to D
else move value to B.
after this in output file i am getting the required '-' sign for price less than 0. thanks. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If that will do, ok.
Just curious, but why does the data need to have the actual "-" sign? |
|
Back to top |
|
|
amarjit singh
New User
Joined: 08 Mar 2013 Posts: 30 Location: india
|
|
|
|
hi..
the output will be send as text file to server..
an the price range is from -1000 to 10000 . thats why . |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Understood
Thanks,
d |
|
Back to top |
|
|
|