IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Getting S0C4 when Writing a Record


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
thesumitk

Active User


Joined: 24 May 2013
Posts: 156
Location: INDIA

PostPosted: Wed Feb 04, 2015 3:26 pm
Reply with quote

Hi All,

I have changed an existing program due to a business requirement, But I am facing a S0C4 issue with it .. It blows up at below Machine Instrunction
at address 00FBD2 .. Can some one please put some more light on this as I dont know assembler langauage

Code:

06210  *9100-PROCESS-ERROR                                                     
06217  MOVE                                                                     
P 5655-S71 IBM Enterprise COBOL for z/OS  4.2.0               RMP02000  Date 02/
  00FB7A  5820 9134               L     2,308(0,9)              BLW=2           
  00FB7E  5830 9138               L     3,312(0,9)              BLW=3           
  00FB82  D203 2798 33B9          MVC   1944(4,2),953(3)        DT-MIO         
06218  MOVE                                                                     
  00FB88  D201 2880 279C          MVC   2176(2,2),1948(2)       WS-REJ-CODE-1-HO
06219  MOVE                                                                     
  00FB8E  D201 2888 279E          MVC   2184(2,2),1950(2)       WS-REJ-CODE-2-HO
06221  IF                                                                       
  00FB94  95E8 3271               CLI   625(3),X'E8'            APPL-CODE-ERROR
  00FB98  4770 BB06               BC    7,2822(0,11)            GN=528(00FBAA) 
06222  MOVE                                                                     
  00FB9C  5840 912C               L     4,300(0,9)              BLW=0           
  00FBA0  D202 27A0 40A6          MVC   1952(3,2),166(4)        DT-APPL-ID     
  00FBA6  47F0 BB20               BC    15,2848(0,11)           GN=529(00FBC4) 
  00FBAA                 GN=528   EQU   *                                       
06224  MOVE                                                                     
  00FBAA  F271 D960 2FAA          PACK  2400(8,13),4010(2,2)    TS2=0           
  00FBB0  960F D967               OI    2407(13),X'0F'          TS2=7           
  00FBB4  4F40 D960               CVB   4,2400(0,13)            TS2=0           
  00FBB8  4C40 A128               MH    4,296(0,10)             PGMLIT AT +56   
  00FBBC  1A42                    AR    4,2                                     
  00FBBE  D202 27A0 489C          MVC   1952(3,2),2204(4)       DT-APPL-ID     
  00FBC4                 GN=529   EQU   *                                       
06225  MOVE                                                                     
  00FBC4  5840 912C               L     4,300(0,9)              BLW=0           
  00FBC8  D213 27A3 40A9          MVC   1955(20,2),169(4)       DT-ACCT-NBR                                                                       
006226  WRITE                                                                   
   00FBCE  5850 9170               L     5,368(0,9)              BLF=11         
   00FBD2  D26D 5000 2798          MVC   0(110,5),1944(2)        RPT-SEQ-RECORD
   00FBD8  5840 91C4               L     4,452(0,9)              RPT-SEQ-FILE   
   00FBDC  9200 40C9               MVI   201(4),X'00'            FCB=12         
   00FBE0  9200 40B3               MVI   179(4),X'00'            FCB=12         
   00FBE4  5860 C044               L     6,68(0,12)              CBL=3         
   00FBE8  D203 4074 6197          MVC   116(4,4),407(6)         FCB=12         
   00FBEE  58F0 4040               L     15,64(0,4)              FCB=12         
   00FBF2  0D5F                    BASR  5,15                                   
   00FBF4  9500 40C9               CLI   201(4),X'00'            FCB=12         
   00FBF8  4770 BB5C               BC    7,2908(0,11)            GN=1285(00FC00)
   00FBFC  5010 9170               ST    1,368(0,9)              BLF=11         
   00FC00                 GN=1285  EQU   *                 


Below is the sysout form job

Code:
RMP02000 I ATTN9999 06.07.31     02/03/15 STARTED.                             
RMP02000 MESSAGE:                                                               
   PROGRAM EXECUTION COMPLETE                                                   
   *** PROGRAM TERMINATING ***                                                 
CEE3204S The system detected a protection exception (System Completion Code=0C4) From compile unit RMP02000 at entry point RMP02000 at compile unit offset +0000FBD2 at entry offset +0000FBD2 at address 4840FBD2.


below is my code in the program
Code:

IF  RMPREC-DT-1ST-DELINQ EQUAL SPACES         
AND RMPREC-REC-TYPE      EQUAL '01'           
    MOVE 'DOFD IS BLANK' TO REJECT-MSG2       
    MOVE '10'  TO DT-REJECT-CODE-2           
    MOVE '81'  TO DT-REJECT-CODE-2           
    PERFORM 9200-REJECT-TRAN THRU 9200-EXIT   
    GO TO 3100-EXIT.   


By looking at the compile listing and sysout it looks like it went down on the statement number 06226 which is a write statement like below
Code:
WRITE RPT-SEQ-RECORD FROM DETAIL-TOTRPT. 

 


Below is the definition of RPT-SEQ-RECORD and DETAIL-TOTRPT respectively


Code:
01  RPT-SEQ-RECORD.                       
    05    FILLER                PIC X(110)
.

Code:
01  DETAIL-TOTRPT.                                       
    05  DT-MIO                 PIC X(04)    VALUE SPACES.
    05  DT-REJECT-CODE-1       PIC X(02)    VALUE SPACES.
    05  DT-REJECT-CODE-2       PIC X(02)    VALUE SPACES.
    05  DT-APPL-ID             PIC X(03)    VALUE SPACES.
    05  DT-ACCT-NBR            PIC X(20)    VALUE SPACES.
    05  DT-VALUE               PIC X(40)    VALUE SPACES.
    05  DT-AMT-CHAR            PIC X(07)    VALUE SPACES.
    05  DT-VALUE-DLRS  REDEFINES DT-AMT-CHAR             
                               PIC S9(11)V99  COMP-3.   
    05  DT-DESC                PIC X(32)    VALUE SPACES.
                                                         


Note:- This program is running fine in production without my change .


Please help to understand this issue and its resolution..

Many Thanks in Advance !!

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 04, 2015 4:15 pm
Reply with quote

I assume you are coding in the style of the existing program.

Code:

IF  RMPREC-DT-1ST-DELINQ EQUAL SPACES         
AND RMPREC-REC-TYPE      EQUAL '01'           
    MOVE 'DOFD IS BLANK' TO REJECT-MSG2       
    MOVE '10'  TO DT-REJECT-CODE-2           
    MOVE '81'  TO DT-REJECT-CODE-2           
    PERFORM 9200-REJECT-TRAN THRU 9200-EXIT   
    GO TO 3100-EXIT.


Look at the fourth and fifth lines. Something wrong there, but won't cause S0C4.

88s, END-IF missing, and has the THRU and GO TO. Makes the program more open to failure.

Is the instruction which failed as part of the WRITE in 9200-REJECT-TRAN (THRU 9200-EXIT)? Probably.

Is this perhaps the first time something has been written to that file?

Most likely cause is the file not being open, either at all, or at the time that you use it (may not have been opened, may have been closed).

Confirm that the existing Production program runs with your test data.

Confirm that there are no messages in file three of the sysout (like DD missing).

Confirm that the program uses FILE STATUS fields for each file and checks them after each IO (I bet it doesn't).
Back to top
View user's profile Send private message
thesumitk

Active User


Joined: 24 May 2013
Posts: 156
Location: INDIA

PostPosted: Wed Feb 04, 2015 5:35 pm
Reply with quote

Thanks Bill for your response !!

The IF condition is ending with a dot(.) after GO TO 3100-EXIT statement in last line, I changed it in the same style this program has written hence didn't use END-IF, However we have so many condition coded in same manner pointing to 3100-EXIT with a GO TO Statement

The instruction which is failing is under the 9200- Para which performs 9120-ERROR - para for each line of report ..


Code:
9200-REJECT-TRAN.
IF RMPREC-REC-TYPE NOT = SPACES                       
    MOVE RMPREC-REC-TYPE                    TO DT-VALUE
    MOVE 'REC TYPE                        ' TO DT-DESC
    PERFORM 9100-PROCESS-ERROR THRU 910
0-EXIT.

Code:
9100-PROCESS-ERROR. 
MOVE WS-MIO              TO   DT-MIO             
MOVE DT-REJECT-CODE-1    TO   WS-REJ-CODE-1-HOLD
MOVE DT-REJECT-CODE-2    TO   WS-REJ-CODE-2-HOLD
                                                 
IF APPL-CODE-ERROR = 'Y'                         
    MOVE RMPREC-APPLICATION-CODE TO DT-APPL-ID   
ELSE                                             
    MOVE APPLID-CODE(A-SUB) TO DT-APPL-ID.       
MOVE RMPREC-ACCT-NBR TO DT-ACCT-NBR.             
[color=red]WRITE RPT-SEQ-RECORD FROM DETAIL-TOTRPT[/color].



The last line I believe is causing the issue

The report/file is written every day this program runs but when it goes inside my code for any record then it blows up

Production program runs well with test/prod data

File status is not coded after each IO .. but it is running fine without my changes
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 04, 2015 6:01 pm
Reply with quote

I agree that is the line causing the problem.

When the implicit MOVE of the WRITE ... FROM ... is being done, one of the items has "lost" addressability. Since your source field is in WORKING-STORAGE (probably, from the name) it is most likely the file area.

The first likely cause is that the file has been CLOSEd already before your code. That's the simple one.

Is your code executing, at any point, after the report file has been closed?
Back to top
View user's profile Send private message
thesumitk

Active User


Joined: 24 May 2013
Posts: 156
Location: INDIA

PostPosted: Thu Feb 05, 2015 11:42 am
Reply with quote

Thank you so much Bill for all your help and time..

The issue was resolved by placing this code in the right paragraph.. you were correct this was not working because we did not have the file open.. Actually this code came from one of my colleague and I was testing it without doubting on code because he also tested it months back(was working fine) and there after he left the organization , So I suspected the data only .. Any way you made me to focus on the code instead of data .. Thanks a lot again !! icon_smile.gif
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Feb 05, 2015 7:30 pm
Reply with quote

Quote:
File status is not coded after each IO

File status should ALWAYS be checked after ANY I-O. That would have pointed you to the problem right away.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 05, 2015 7:55 pm
Reply with quote

Yes, it should, but it doesn't help in situations like this. Helps in plenty of others.

The S0C4 would come before the WRITE went off to the IO-routines. Access the data under the FD after a file is CLOSEd, or before it is OPENed, and S0C4 will result.

Unless the file is using APPLY WRITE ONLY, or the program has compiler option AWO.

In that case, the S0C4 will be avoided (can never happen) and the FILE STATUS field will save the day for sure. If coded. Only if coded.

Do use APPLY WRITE ONLY for VB output files. Don't use compiler option AWO. Do use FILE STATUS checking after each IO, regardless of file type (do use extended FILE STATUS for VSAM).
Back to top
View user's profile Send private message
thesumitk

Active User


Joined: 24 May 2013
Posts: 156
Location: INDIA

PostPosted: Thu Feb 05, 2015 8:58 pm
Reply with quote

Noted.. Thanks Much !!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top