SOC4 Abend in COBOL



Get solution for your ABEND Codes & System Error Messages, SQL Codes, File Status etc...

Re: SOC4 Error

Postby Ravi Teja » Thu Feb 10, 2011 7:19 pm

hi, Rayster

Here is an example for SOC4 error
ex:

77 A PIC 9(2) VALUE 89.
77 B PIC 9(2) VALUE 80.
77 C PIC 9(2).
ADD A TO B GIVING C.

//result will be 169 but C can store only 2 values, in this case SOC4 error will occur

i faced this error lot of time, and i corrected it successfully..


if i am incorrect,correct me

Thank You
Thank You
Ravi Teja
 
Posts: 15
Joined: Fri Dec 03, 2010 11:22 am
Has thanked: 0 time
Been thanked: 0 time

Re: SOC4 Error

Postby Robert Sample » Thu Feb 10, 2011 8:16 pm

Ravi Teja, which compiler were you using? Under Enterprise COBOL for z/OS, that behavior does not occur.
Code:
       77  A                           PIC 9(2) VALUE 89.
       77  B                           PIC 9(2) VALUE 80.
       77  C                           PIC 9(2).
       PROCEDURE DIVISION.
           ADD A TO B GIVING C.
           DISPLAY 'A = ' A.
           DISPLAY 'B = ' B.
           DISPLAY 'C = ' C.
produces results of
 A = 89
 B = 80
 C = 69
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: SOC4 Error

Postby dick scherrer » Fri Feb 11, 2011 2:58 am

Hello,

//result will be 169 but C can store only 2 values, in this case SOC4 error will occur
Please test before posting. . .

Why do you believe this could cause an 0c4?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: SOC4 Error

Postby steve-myers » Fri Feb 11, 2011 6:06 am

Whether something like this will create an S0C4 depends on how the compiler and run time library layout storage and exactly how that storage is allocated. There is quite a good chance the sample code will not create an S0C4 ABEND.

A personal library function I use quite a lot in my work has a similar issue, though the odds are it will get the S0C4 in an input field rather than an output field. The documentation for it warns it can get an S0C4, but while I was testing it I attempted to create the S0C4 it could theoretically get. Nothing. Then, months later, an S0C4 completely out of, I thought, nowhere. After more analysis I realized, "Oops!"
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: SOC4 Error

Postby dick scherrer » Fri Feb 11, 2011 9:43 am

Hello,

There is quite a good chance the sample code will not create an S0C4 ABEND.
Quite the understatement, i believe :)

Having worked with every mainframe/mv-whatever COBOL compiler IBM ever released across more than 100 mainframe centers, i have not yet seen the code Robert posted cause an 0c4. I'd be interested to hear which exception within the 0c4 occurred.

If there is a way to predictably cause this abend with the posted code (using 77 level entries and an add), i'll surely add this to my "treasure trove".
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: SOC4 Error

Postby BillyBoyo » Wed Feb 16, 2011 5:02 am

       77  A                           PIC 9(2) VALUE 89.
       77  B                           PIC 9(2) VALUE 80.
       77  C                           PIC 9(2).
       PROCEDURE DIVISION.
           ADD A TO B GIVING C.
           DISPLAY 'A = ' A.
           DISPLAY 'B = ' B.
           DISPLAY 'C = ' C.


There is no way the above code can cause an 0C4. Try making it a real program, doesn't take much, and compile with "list" option, or whatever it is these days to get generated assembler for you code. The high-order truncation that is alleged to 0C4 is carried out entirely by code that is not even using these storage locations at the time the truncation occurs. Look at the generated code. To do the ADD, code is generated to convert both A and B to packed decimal (unsigned in this case, extra code generated to ensure (OK, these days it seems there may be extended options for that)) in the program's "work area". The calculation will be done, with the result in another chunk of work area. The result will be converted to a two-digit zoned decimal (unsigned) field. Can't remember if that is in the work area followed by an MVC, or if it is directly to the 77, but doesn't matter.

The point is, everything is within your program. I can't see you getting any sort of addressing exception when everything is within the program. Don't see compiler or link-editor arrangements can come into it either, dynamic, non-dynamic, I don't care, it is all within the same program. If the ADD were to cause an 0C4, then I would say it had nothing to do with C, because it would fail as soon as it referenced A (they are not very far apart, so I don't see how one would be addressable and the other not).

To get an 0C4 in this sort of situation (everything in working storage or the work area) then you have to have screwed-up in a program that you have called which has trashed your save area. Or, with several modules linked together, one of the others has to have gone a wild and trashed your code in the load module, which can give you unexpected sorts of abends.

If you have this type of code (not this basic, but without files to access after EOF, ie everything you access is within the module) and you get an 0C4, then the problem is not with the module that failed, but with another module that is linked together.

Even with all this modern COBOL that is around these days, I can't imagine they've made a compiler that would allow a progam not to be able to address itself.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: SOC4 Error

Postby pmartyn » Thu Feb 28, 2013 9:10 pm

The replies above are correct. An OC7 does not turn into a OC4. There are multiple issues.
Easy answer; Search for the missing dataset. This could be a lib not concatenated properly, or underlying IMS DL1 Database missing from JCL or just missing(look for the VSAM, OSAM name), or something else you are trying to reference/use and it is not there. (like reading after it is closed)
pmartyn
 
Posts: 42
Joined: Thu Feb 28, 2013 7:11 pm
Has thanked: 5 times
Been thanked: 3 times

Re: SOC4 Error

Postby Peter_Mann » Thu Feb 28, 2013 9:56 pm

Why are you replying to posts that are over 3 years old?, so far all seven of your posts have been to issues that have been solved or ignored :evil:
Peter
Peter_Mann
 
Posts: 145
Joined: Fri Jun 24, 2011 7:37 pm
Location: Lowell,AR
Has thanked: 15 times
Been thanked: 3 times

Previous

Return to ABENDS & SQL Codes

 


  • Related topics
    Replies
    Views
    Last post