View previous topic :: View next topic
|
Author |
Message |
Amb
New User
Joined: 12 Mar 2010 Posts: 64 Location: India
|
|
|
|
Hi Guys,
I want to know this out of curosity.
I have the following code:
Code: |
01 VAR4 PIC X(4) VALUE 'ABCD'.
01 VAR5 PIC 9(4) VALUE ZEROES.
MOVE VAR4 TO VAR5
DISPLAY 'VAR5:' VAR5
ADD 1 TO VAR5
DISPLAY 'VAR5:' VAR5 |
The program is compiling and executing without any error
The output that I am getting is:
Code: |
VAR5:ABC4
VAR5:1235 |
What I am trying to understand is that VAR5 is a numeric variable that contains non numeric data.
When I add one to this variable 'var5', why am I not getting a SOC7 error |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
What I am trying to understand is that VAR5 is a numeric variable that contains non numeric data.
When I add one to this variable 'var5', why am I not getting a SOC7 error
|
Nothing in COBOL prevents you from doing what you did -- it is allowed by COBOL.
S0C7 abends are caused when you have non-numeric data in a COMP-3 variable and you have no COMP-3 variables. When you add 1 to your vairable, the variable is packed (so the first four bits of each byte are removed -- in which case an A is the same as a J is the same as a 1 since they have the same last 4 bits -- and unpacked after the addition.
Study the manual! |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Compile the code (program) using compile options LIST,NOOFFSET,NOOPT and review the Assembler instructions, especially what's generated from the ADD and review what occurs during a PACK instruction.
You'll then see why (using the data provided) all runs OK and why a S0C7 is not raised.
Familiarization with Assembler would be helpful.
Bill |
|
Back to top |
|
|
Amb
New User
Joined: 12 Mar 2010 Posts: 64 Location: India
|
|
|
|
Thanks Robert.
Apologies. I was under the impression that SOC 7 abend can also occur if you try to do an arithmatic operation on a numeric variable that contains non numeric data. I was not aware that this is true only for COMP-3 variables. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
numeric variable
and
display numeric variable
are two very, very different things. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
SOC 7 abend can also occur if you try to do an arithmatic operation on a numeric variable that contains non numeric data. |
This is a true statement -- and it tells me you need to read the manual to find out what a numeric variable is (hint: as Dick alluded, USAGE DISPLAY isn't what you think it is). |
|
Back to top |
|
|
|