View previous topic :: View next topic
|
Author |
Message |
Kmr.deepakcs
New User
Joined: 11 Oct 2013 Posts: 37 Location: India
|
|
|
|
Dear Experts:
This code showing soc-7 but when i exclude s from b. it does not show any abend...please give me info about this....
Code: |
ID DIVISION.
PROGRAM-ID. "DEEPAK".
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC X(3).
01 B REDEFINES A PIC S9(3).
PROCEDURE DIVISION.
MOVE '-1' TO A.
ADD 1 TO B.
DISPLAY "VALUE OF A ",A.
DISPLAY "VALUE OF B ",B.
STOP RUN. |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You know the code is never going to give a useful answer? Have you gone through the other posts on similar subjects in this forum? Have a look at the code the compiler has generated (compiler options LIST,NOOFFSET). |
|
Back to top |
|
|
Naish
New User
Joined: 07 Dec 2006 Posts: 82 Location: UK
|
|
|
|
When I was young (very young) I would ask such questions on variuos sites/forums to irritate people.. Now I know how it feels.. and the reply I would get from the experts would be to to read the manual which would irritate me but, I think that was the best advice I got and now I visit this site to write such comments.
Hope that answers your questions.
Yay! Feels good to be back. |
|
Back to top |
|
|
Kmr.deepakcs
New User
Joined: 11 Oct 2013 Posts: 37 Location: India
|
|
|
|
well THanks bill and naish,
I fully satisfied what you said, that these code irritate..But it also a question.
I need explantaion . |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Quote: |
I need explanation |
which, as stated, can be found by searching the forum or reading the manual. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Do you know what a S0C7 abend is, and what conditions cause this. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
do not forget, that a display numeric field is handled
(when there is no sign)
the same as x-type.
when a display-numeric field has a sign,
it then adheres to appropriate signed numeric format,
and is stored as such in memory.
start with, what will A contain after moving '-1' to the field?
'202DF1'
I leave it to you to determine the appropriate hex for an S9(3) display field.
since the SEPARATE CHARACTER phrase is not specified
The operational sign is presumed to be associated with the LEADING or TRAILING digit position, whichever is specified, of the elementary numeric data item. (In this instance, specification of SIGN IS TRAILING is the equivalent of the standard action of the compiler.)
for display-numeric data items,
this is termed (old school) as overprint |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1049 Location: Richmond, Virginia
|
|
|
|
Have you looked at the generated code? I think the option is PMAP (procedure map).
The signed field may be forcing a convert to packed decimal and back, whereas the unsigned field's code does not need that. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
We're getting a little lost on this one.
Kmr.deepakcs,
You are using compiler option NUMPROC(NOPFD).
If you add
as the first line of your program and recompile, you will discover that you get the abend whether the S is present or not.
Your MOVE of '-1' is just a "string" of value X'60F140'. The 40 appears because the "string" is shorter than the receiving field, so is right-padded with space(s).
When you REDEFINES it as PIC 9(3), if any calculation is done (like ADD 1) then it is absolutely necessary that the left-most low-order half-byte contains one of A-F inclusive.
In the example, said half-byte contains 4. So, abend.
That is, abend with NUMPROC(NOPFD) and S999 or NUMPROC(PFD) and either 999 or S999.
Because you have NUMPROC(NOPFD) the compiler generates code to ensure you have a sign in your unsigned B field before it is used. It is dumb, and it is an easy way to allow rubbish data into your system, but that is the way that it works.
Moral, on input, check that all numeric fields are NUMERIC. If not, reject them. If you don't, with you run the danger of making rubbish look like ordinary data.
NUMPROC(NOPFD) makes this slightly worse by also doing that for data which would otherwise cause an abend, like your example.
PMAP is pre-Enterprise COBOL (Mr Bill may tell us exactly). With Enterprise COBOL, specify LIST,NOOFFSET to get the generated pseudo-assembler listing. |
|
Back to top |
|
|
Kmr.deepakcs
New User
Joined: 11 Oct 2013 Posts: 37 Location: India
|
|
|
|
Thanks, bill |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
signed display numeric without the SEPARATE clause is also called a
zoned decimal. the following chart showing how zoned decimals are stored can be of help.
so, moving '00J' to your x-type field would have been the same as moving -1 (no single quote to form a string [x-type] literal) to the signed display numeric.
as an aside,
i apologize for my error in the earlier post which bill pointed out,
'202DF1'
should have been
'60F140'
20 is an ascii space, 40 is an ebcdic
2D is an ascii subtract, 60 is an ebcdic
managed to get an F1 for an ebcdic 1. |
|
Back to top |
|
|
|