IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

sign in the high-order nibble of the low-order byte


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

New User


Joined: 08 Mar 2013
Posts: 30
Location: india

PostPosted: Wed May 01, 2013 9:02 pm
Reply with quote

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed May 01, 2013 9:06 pm
Reply with quote

Do you think maybe a sign (S) character is called for in the value?
Back to top
View user's profile Send private message
amarjit singh

New User


Joined: 08 Mar 2013
Posts: 30
Location: india

PostPosted: Wed May 01, 2013 9:08 pm
Reply with quote

hi,
declaring as S9(5)v99 is giving '{' in the output.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19251
Location: Inside the Matrix

PostPosted: Wed May 01, 2013 9:18 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19251
Location: Inside the Matrix

PostPosted: Wed May 01, 2013 9:19 pm
Reply with quote

Add on:

It is not clear (to me) what you are asking . . .
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed May 01, 2013 9:26 pm
Reply with quote

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
View user's profile Send private message
amarjit singh

New User


Joined: 08 Mar 2013
Posts: 30
Location: india

PostPosted: Wed May 01, 2013 9:31 pm
Reply with quote

hi..
yes we want '-' only for -ve values without altering the variable field length.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19251
Location: Inside the Matrix

PostPosted: Wed May 01, 2013 9:34 pm
Reply with quote

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed May 01, 2013 10:47 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19251
Location: Inside the Matrix

PostPosted: Thu May 02, 2013 12:21 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

PostPosted: Thu May 02, 2013 7:21 pm
Reply with quote

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
View user's profile Send private message
amarjit singh

New User


Joined: 08 Mar 2013
Posts: 30
Location: india

PostPosted: Thu May 02, 2013 10:36 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19251
Location: Inside the Matrix

PostPosted: Thu May 02, 2013 11:27 pm
Reply with quote

Hello,

If that will do, ok.

Just curious, but why does the data need to have the actual "-" sign?
Back to top
View user's profile Send private message
amarjit singh

New User


Joined: 08 Mar 2013
Posts: 30
Location: india

PostPosted: Thu May 02, 2013 11:29 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19251
Location: Inside the Matrix

PostPosted: Thu May 02, 2013 11:43 pm
Reply with quote

Understood icon_wink.gif

Thanks,

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> COBOL Programming
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts Combining more 4 files with sorted or... DFSORT/ICETOOL 3
This topic is locked: you cannot edit posts or make replies. Missing Negative sign in COBOL COBOL Programming 6
No new posts Read 4MB message and split into multi... COBOL Programming 9
No new posts how to show listing in physical locat... PL/I & Assembler 2
No new posts SUSBSCRIPT WITH SIGN IN PIC CLAUSE COBOL Programming 3

Back to Top