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
 

 

Question on numeric variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Nagendran

New User


Joined: 24 Jan 2007
Posts: 89
Location: USA

PostPosted: Mon Apr 11, 2011 1:45 am    Post subject: Question on numeric variable
Reply with quote

Hi,

I have below statement in the COBOL Program.

01 WS-VAR-01.
05 WS-VAL PIC 9(011).
WS-VAL = '2222211AA'

System is not abending while executing the below code.
IF WS-VAL > 0
END-ID

System is abending with S0C7 when we have below values in the variable.
WS-VAL='V__________.'

Could some one clarify below questions?
1. Why system is not abending when we have alphanumeric values in the variable?
2. Why system abends when we have special characters in the variable?

Thanks,
Nagu
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Apr 11, 2011 2:11 am    Post subject: Reply to: Question on numeric variable
Reply with quote

That's probably because WS-VAR is packed by the compiler and a "CP" instruction is issued against the packed value.

In a PACK, CL10'2222211AA' is packed into an intermediate compiler field as PL5'222221111' and you probably ask WHY?

PACK instructions discard the zone-nibble (except for the last byte, where the byte is flip flopped). The letter 'A' is a X'C1', so the sign-byte is equal to either X'1C' or X'1F' (after a possible OR-immediate).

Check your compiler option as it might equal NUMPROC(NOPFD), which is the default.

However, if it's NUMPROC(PFD), then the compiler may NOT pack WS-VAR and issue a "CLC" against the data with the result of the compare being not greater than zero, in order word, not true.

If after a PACK, if any 4-Bit Nibble exceeds X'9'/B'1001' (except for the sign-nibble), then a S0C7 is raised when a decimal instruction is issued against it.

Bill
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Mon Apr 11, 2011 5:06 am    Post subject: Re: Question on numeric variable
Reply with quote

Nagendran wrote:
05 WS-VAL PIC 9(011).
WS-VAL = '2222211AA'

System is not abending while executing the below code.
IF WS-VAL > 0
END-ID


Firstly, you have an 11-byte field, but only 9 bytes of data you are showing. Do you have leading blanks, or trailing blanks? Or did you leave a little bit out when you posted? Doesn't matter. Blank or A in you last character, then.

Quote:

System is abending with S0C7 when we have below values in the variable.
WS-VAL='V__________.'


This time you have 12 characters at my count. OK, so last character is underscore or period.


1. When testing against zero, WS-VAL is "packed". This involves tossing away all the "zones" (the left-most half byte - nibble - of each byte) apart from the right-most byte, which instead of being a "zone" is the "sign" for the field, so this swaps places with the right nibble of the rightmost byte to complete the packed field.

Since all your individual values have numerics in the number nibble, the pack instruction will form a valid number, subject to the sign being valid.
You are not receiving an S0C7, so we can deduce that you have NUMPROC(NOPFD) if you have a space as the final character or you end up with a "valid" sign anyway if you have "A" as the final character.

2. Now, with either a period or an underscore (4B or 6D) with NUMPROC(PFD) you would get an S0C7, as neither 4 nor 6 are valid signs. With NUMPROC(NOPFD) you'd get your sign fixed, but still get an S0C7 because all the other 6D's would give you a "D" in the number nibble, which isn't valid.

We already know you have NUMPROC(NOPFD) (or possibly NUMPROC(MIG) and code you are not showing us) so you'd be abending for the non-numerics in the number, not the numerics in the sign.

If you change your compile option to NUMPROC(PFD) you can get your first example to S0C7 if it has trailing spaces.

Basically, not a good idea to put non-numeric data in a numeric field. To me, it is better if it S0C7's, otherwise there is some weird value entering the system which you have just made "valid".
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Mon Apr 11, 2011 12:08 pm    Post subject:
Reply with quote

This is another thread started by someone with a poor or non-existant skill set,
who expects us to believe that:
Quote:
WS-VAL = '2222211AA'
is a COBOL statement.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Mon Apr 11, 2011 1:06 pm    Post subject:
Reply with quote

also,
this concerns display numeric,
which everyone has been repeatedly reminded,
that display numeric is not numeric class.

display numeric should only be used for
output streams
input streams
USING parms to non-cobol modules.

other usage indicates the inability of the user to read hex representation of data values in memory.
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am


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