Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Getting soc4 on internal table in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 135
Location: Coimbatore

PostPosted: Fri May 06, 2016 3:39 pm    Post subject: Getting soc4 on internal table in cobol
Reply with quote

Hi,

I am using the below table,

Code:
01  WS-REQCODE-TABLE.                                           
    05 WS-REQCODE-VALUE OCCURS 16 TIMES INDEXED BY WS-RCODE-IDX.
       10 WS-REQ-ACCY-CD      PIC X(02).                         

2205-STRIP-SPACES.                                               
                                                                 
     MOVE ZEROS   TO WS-COUNT1                                   
                                                                 
     MOVE WS-REQ-ACCY-CD-TEMP(WS-COUNTER) TO WS-REQ-CODE         
     DISPLAY 'WS-REQ-CODE:' WS-REQ-CODE                         
                                                                 
     IF WS-REQ-CODE(1:1) = SPACES                               
        INSPECT WS-REQ-CODE TALLYING WS-COUNT1 FOR LEADING SPACES
                                                                 
        COMPUTE WS-LENGTH = LENGTH OF WS-REQ-CODE - WS-COUNT1   
        MOVE WS-REQ-CODE(WS-COUNT1 + 1 : WS-LENGTH)             
                  TO WS-REQ-ACCY-CD(WS-COUNTER)                 
                                                                 
     ELSE                                                       
        MOVE WS-REQ-CODE(1:2) TO WS-REQ-ACCY-CD(WS-COUNTER)     
     END-IF                                                     
     DISPLAY 'WS-REQ-ACCY-CD:' WS-REQ-ACCY-CD(WS-COUNTER)       
                                                                 
     ADD +1       TO WS-COUNTER                                 


Here WS-REQ-ACCY-CD-TEMP is of 3 bytes and WS-REQ-ACCY-CD is of 2 bytes.

I am moving correctly but I am getting soc4 abend.

The COBOL source code for data fields involved in the failure:

Source
Line #
------
000233 01 WS-REQCODE-TABLE.

Data field values at time of abend:

WS-REQCODE-TABLE =

The system detected a protection exception (System Completion Code=0C4).
From compile unit VIC999 at entry point VIC999 at statement 1319 at compile unit
offset +0000357C at address 2E0A9AEC.
ENTERED (LEVEL 05/14/2013 AT 15.14)
PROCESSING COMPLETE. RC=4


Can you please help me to resolve this ?.
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri May 06, 2016 4:42 pm    Post subject: Reply to: Getting soc4 on internal table in cobol
Reply with quote

I don't see WS-RCODE-IDX being set anywhere (there isn't any default in COBOL) and it could contain any value causing unpredictable addressing of any of these table elements.

HTH....
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Fri May 06, 2016 4:42 pm    Post subject:
Reply with quote

Not really. You posted a bunch of junk instead of merely asking for help. So let's start with some basics:
1 What is the line of code referenced in the abend?
2 What is the value of WS-COUNTER in the dump?
3 What is the PERFORM statement that is executing the code you did post?
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 135
Location: Coimbatore

PostPosted: Fri May 06, 2016 5:06 pm    Post subject:
Reply with quote

Hi,

I actually gave some displays now to check where I went wrong. But again its showing some errors after writing only one display on the spool.

Here is a piece of code and this is the first para.

Code:
  1000-INITIALIZATION.                                         
                                                               
      DISPLAY 'I AM IN INIT'                                   
 *    MOVE SPACES TO WS-REQCODE-TABLE-TEMP                     
 *                   WS-LOCCODE-TABLE                         
      MOVE SPACES TO SUCCESS-RECORD                           
                     ERROR-RECORD                             
      DISPLAY 'GOING TO OPEN FILES'                           
      OPEN INPUT CSV-FILE                                     
      IF NOT FS-CSVFILE-OK                                     
          DISPLAY '*********************************'         
          DISPLAY '** ERROR OPENING INPUT FILE    **'         
          DISPLAY '** FILE STATUS :' FS-CSVFILE               
          DISPLAY '*********************************'         
          MOVE FS-CSVFILE     TO FS-FILE-STATUS               
          PERFORM 9998-CALL-LUU205                             
          PERFORM 9999-CALL-CANCEL                             
      END-IF                                                   


Spool message:
Code:
I AM IN INIT                                                                   
CEE3204S The system detected a protection exception (System Completion Code=0C4)
         From compile unit VIC999 at entry point VIC999 at statement 1317 at com
         offset +000035FA at address 2E0A9FCA.                                 
<> LEAID ENTERED (LEVEL 05/14/2013 AT 15.14)                                   
<> LEAID PROCESSING COMPLETE. RC=4                                             


I don't think my program proceeded after this.

BTW as you asked, I have defined the table just as below thinking problem with the index.

Code:

01  WS-REQCODE-TABLE-TEMP.                             
    05 WS-REQCODE-VALUE-TEMP OCCURS 16 TIMES.         
       10 WS-REQ-ACCY-CD-TEMP PIC X(03).               
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri May 06, 2016 5:35 pm    Post subject: Reply to: Getting soc4 on internal table in cobol
Reply with quote

I'd guess SUCCESS-RECORD is a record in the file which you OPEN fairly shortly afterwards. Before an OPEN the record-area has no address, so referencing it will get you a S0C4.

It is usually fruitless to initialise record-areas anyway: you're going to put data in them, aren't you?

If you remove the MOVE for the SUCCESS-RECORD, or, if you don't trust things, relocate it after the OPEN, that problem will go away.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Fri May 06, 2016 5:37 pm    Post subject:
Reply with quote

Sigh. You again posted stuff that is pretty much useless for debugging your problem. I reiterate:
1 What is the line of code referenced in the abend?
2 What is the value of WS-COUNTER in the dump?
3 What is the PERFORM statement that is executing the code you did post?

If your compile has OFFSET instead of LIST, change the compile options to LIST,NOOFFSET so you get a complete pseudo-assembler listing of your code. That will tell you what the computer considers to be statement 1319 (or 1317 or wherever the ABEND moved when you changed your code) by comparing the compiler offsets to the ABEND offset. That tells you EXACTLY where the problem showed up (not where it happened -- storage exceptions tend to show up in places NOT where they start).

If you don't know how to find the value of WS-COUNTER in the dump, or you didn't get a dump at all, you could at least put a DISPLAY every time the value of WS-COUNTER is changed and hence know the last value it had before the ABEND.

You still haven't showed up the PERFORM statement for the code that you posted.
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 135
Location: Coimbatore

PostPosted: Fri May 06, 2016 5:43 pm    Post subject:
Reply with quote

Yes. If I remove the move statement and submit it I am able to get maxx = 0. But I would like to initialize my local tables. How can I do it ?.

Success record is a output file. Once input has been processed successfully this success file will be written with that data.
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 135
Location: Coimbatore

PostPosted: Fri May 06, 2016 5:46 pm    Post subject:
Reply with quote

Hi Robert,

Please find the code which you asked for,

Code:
                                                   
      MOVE 1      TO WS-COUNTER                     
      PERFORM 2205-STRIP-SPACES THRU 2205-EXIT     
         UNTIL WS-COUNTER > 16                     


Currently I am putting displays to track it.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Fri May 06, 2016 6:39 pm    Post subject:
Reply with quote

I would not be surprised to find that you're falling through code into that 2205-STRIP-SPACES paragraph and hence WS-COUNTER may be something well beyond 16.
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 135
Location: Coimbatore

PostPosted: Fri May 06, 2016 6:49 pm    Post subject:
Reply with quote

I too checked the same but when it comes to 17 it shall come out of the loop.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri May 06, 2016 7:09 pm    Post subject: Reply to: Getting soc4 on internal table in cobol
Reply with quote

I can't emphasize this enough, to ensure you don't go beyond table addressability. Add a second index to the table, name it (for example) WS-RCODE-IDX-MAX and issue the following code in housekeeping -

Code:

DIVIDE LENGTH OF WS-REQCODE-TABLE                           
                            BY LENGTH OF WS-REQCODE-VALUE (1)
                            GIVING TALLY                     
SET  WS-RCODE-IDX-MAX       TO TALLY                         
MOVE ZERO                   TO TALLY

I used the TALLY special-register as the quotient (binary fullword), but you can substitute it with whatever you like, but it's best to make it a binary field.

Then, instead of a hard-code max, always use WS-RCODE-IDX-MAX. You can't go wrong.

HTH....
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Fri May 06, 2016 7:49 pm    Post subject:
Reply with quote

Use Bill's perfect way that should work.
Quote:

But I would like to initialize my local tables. How can I do it ?.

search on the forum, hint is to loop through and move spaces to the variable and increment the ctr till the max occurrence.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Fri May 06, 2016 8:14 pm    Post subject:
Reply with quote

Quote:
I am moving correctly but I am getting soc4 abend.
The MOVE is not likely to have anything to do with the ABEND.
Quote:
But I would like to initialize my local tables. How can I do it ?.
With the INITIALIZE or MOVE statement in COBOL.

You might do better on the Beginner's and Students Forum as this forum is for professionals and you're asking some pretty basic questions and showing an almost complete lack of understanding of COBOL.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sat May 07, 2016 3:20 am    Post subject: Reply to: Getting soc4 on internal table in cobol
Reply with quote

It does not matter whether SUCCESS-RECORD is an input or an output file. If you do anything with SUCCESS-RECORD or any part of it before a file is correctly OPENed, you will get a S0C4 (unless it is a variable-length blocked file and you are using compiler option AWO or using APPLY WRITE ONLY).

You have shown that it is the problem you are getting, by removing the MOVE statement (or you seem to have said that). You have got it into your head that something is wrong the table. This is not so. If you keep trying to fix the wrong thing, you will keep going nowhere.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us