Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: sign in the high-order nibble of the low-order byte
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: 1738
Location: Bloomington, IL

PostPosted: Wed May 01, 2013 9:06 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed May 01, 2013 9:18 pm    Post subject:
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

Site Director


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

PostPosted: Wed May 01, 2013 9:19 pm    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Wed May 01, 2013 9:26 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed May 01, 2013 9:34 pm    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Wed May 01, 2013 10:47 pm    Post subject:
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

Site Director


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

PostPosted: Thu May 02, 2013 12:21 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Thu May 02, 2013 7:21 pm    Post subject: Reply to: need suggestion for picture clause
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    Post subject:
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

Site Director


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

PostPosted: Thu May 02, 2013 11:27 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu May 02, 2013 11:43 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am
No new posts Need Help to Define 36 Input Fields (... satish.ms10 CLIST & REXX 2 Sat May 07, 2016 3:08 pm
No new posts SQL Order By related question Joseph K Thomas DB2 8 Fri Mar 18, 2016 12:53 pm
No new posts DFSORT control statements in any order ? ronald masters DFSORT/ICETOOL 2 Tue Dec 15, 2015 11:22 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us