View previous topic :: View next topic
|
Author |
Message |
raveendra_ibm Currently Banned New User
Joined: 07 Jan 2006 Posts: 31
|
|
|
|
Hi All,
I was testing this piece of code and am hit with a S0C7 ABEND.
I was trying to justify the same but failed to do so. My understanding is that S0C7 occurs ONLY when Packed Decimal values are involved.
Code: |
01 WS-VAR1.
05 WS-VAR2 PIC X(2).
05 WS-VAR3 REDEFINES WS-VAR2.
10 WS-VAR4 PIC 99.
MOVE SPACES TO WS-VAR2
EVALUATE TRUE
WHEN WS-VAR4 = 14
DISPLAY "OK"
WHEN OTHER
DISPLAY "NOT OK"
END-EVALUATE |
Help me out Please !!!
Thanks,
Raveendra.[/code] |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Not being a programmer, I'd hazard a guess that the field WS-VAR4 does not contain numeric data. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
'Program attempting to do math on illegal data'. This is the reason why you got s0c7. |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi There,
You have niether initialized WS-VAR4 nor move any numeric value to WS-VAR4 that why it's contain junk data & giving SOC7 |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Since you compare a numeric field against a numeric literial, the compiler generated a compare packed instruction for the test. That required a pack instruction for the data.
Possibly if you did "WS-VAR4 = '14'" instead, the compiler might generate a simpler character compare..... |
|
Back to top |
|
|
raveendra_ibm Currently Banned New User
Joined: 07 Jan 2006 Posts: 31
|
|
|
|
Thanks "expat", Abhijit and Ekta for your replies....
And thank you William, you could identify the area of my concern.
Does the compiler generate a packed instruction for all the "compare" operations ? i.e, numeric field against numeric literal, numeric field against another numeric field..etc.
I tried replacing the numeric literal with a numeric field and again got a S0C7... On the other hand changing the numeric literal to a character ( '14' ), was successful ....
Could you please explain what are all the scenarios wherein the compiler generates a packed instruction for compare...
Thanks.
Raveendra. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
raveendra_ibm wrote: |
Does the compiler generate a packed instruction for all the "compare" operations ? i.e, numeric field against numeric literal, numeric field against another numeric field..etc. |
Yes
Quote: |
I tried replacing the numeric literal with a numeric field and again got a S0C7... |
Of course. "numeric field against another numeric field"
Quote: |
On the other hand changing the numeric literal to a character ( '14' ), was successful .... |
Since the variable was zoned decimal (display), comparing characters was the only way to go against an alpha-numeric literal
Quote: |
Could you please explain what are all the scenarios wherein the compiler generates a packed instruction for compare... |
Anytime numeric operations go against comp-3 or display numeric, it will be done with packed instructions |
|
Back to top |
|
|
raveendra_ibm Currently Banned New User
Joined: 07 Jan 2006 Posts: 31
|
|
|
|
Thanks a lot William !!!
It was indeed helpful .....
Regards,
Raveendra. |
|
Back to top |
|
|
|