Page 1 of 1

Mysterious S0C7

PostPosted: Sat Apr 26, 2008 1:49 am
by yurad
I have the simple program:
FILE FILEIN                                                       
  REC-IN  1 390 A                                                 
    REC-ACC-NMBR  1 16 N   
                                                                   
BYTE-CNTR W 9 P                                                   
FILE-CNTR W 6 N                                                   
* DUMMY-VAR W 1 A                                                       
                                                                   
FIVE-ACCNTS W  85 A                                               
   ACCNT-LINE FIVE-ACCNTS 17 A OCCURS 5 INDEX IND                 
   ACCNT ACCNT-LINE +1 16 A                                       
                                                                   
NUMBER-OF-STORED-ACC W 1 P   

RECORD-NUMBER W 1 P VALUE 6
                                                                   
JOB INPUT FILEIN                                                   
  DISPLAY 'TRACE 1'                                               
  BYTE-CNTR = BYTE-CNTR + FILEIN:RECORD-LENGTH
  DISPLAY 'TRACE 2'                                               
                                                                   
  DISPLAY 'NUMBER-OF-STORED-ACC' NUMBER-OF-STORED-ACC           
                                                               
  IF NUMBER-OF-STORED-ACC LT RECORD-NUMBER
    NUMBER-OF-STORED-ACC = NUMBER-OF-STORED-ACC + 1             
     IND = NUMBER-OF-STORED-ACC                                 
     ACCNT(IND) = REC-ACC-NMBR                               
  END-IF           


The program reads file and counts bytes.
On the record number "RECORD-NUMBER + 1" I have S0C7 in the statement:
BYTE-CNTR = BYTE-CNTR + FILEIN:RECORD-LENGTH
If I define any variable like DUMMY-VAR ( You could see it commented out) or I will comment out any of statements in IF block the ABEND disappears. There are many another code changes when it not abended.
My question is what causes S0C7 here.

Thanks!

Re: Mysterious S0C7

PostPosted: Sat Apr 26, 2008 5:36 am
by dick scherrer
Hello,

On the record number "RECORD-NUMBER + 1"
I don't see "RECORD-NUMBER + 1"?

I have S0C7 in the statement:
BYTE-CNTR = BYTE-CNTR + FILEIN:RECORD-LENGTH
How many records are successfully processed before the 0c7 or is the abend on the first record?

If you post the problem record (in hex, using the "Code" tag for readability), it will help us diagnose the problem.

If you are not familiar with using the tags (the row above where text is typed), you can "practice" by using "Preview". When you Preview, you can see your post the same way it will appear to the forum.

Without dong any de-bugging, i'd suggest that this
BYTE-CNTR W 9 P
could be a problem. It has no initial value and should probably be initialized to zero. The other numeric variables also should be initialized (again probably to zero).

Re: Mysterious S0C7

PostPosted: Tue Apr 29, 2008 1:31 am
by yurad
Hello, Dick.
BYTE-CNTR W 9 P shouldn't be a problem. In the documentation it's explicitly described:
Working Storage Initialization
CA-Easytrieve/Plus initializes numeric work fields to zeros and alphabetic work
fields to blanks. To initialize these fields to other values, use the VALUE option

What's about "RECORD-NUMBER + 1" I was not cleat enough. Sorry for it. Really the problem is too mysterious for me.
I mean that S0C7 occurs on the record with the number equivalent to RECORD-NUMBER + 1.
If I have in the code RECORD-NUMBER = 6 the abend happens on the record 7:
FIVE-ACCNTS W 85 A
ACCNT-LINE FIVE-ACCNTS 17 A OCCURS 5 INDEX IND
ACCNT ACCNT-LINE +1 16 A

NUMBER-OF-STORED-ACC W 1 P
RECORD-NUMBER W 1 P VALUE 6

The program abends on the record #7
(From the job output:
TRACE 1
TRACE 2
NUMBER-OF-STORED-ACC4
6
TRACE 1
TRACE 2
NUMBER-OF-STORED-ACC5
7
TRACE 1
16 *******A006 PROGRAM INTERRUPT - CODE 7 (DATA EXCP) )

If I have in the code RECORD-NUMBER = 7 the abend happens on the record 8:
FIVE-ACCNTS W 102 A
ACCNT-LINE FIVE-ACCNTS 17 A OCCURS 6 INDEX IND
ACCNT ACCNT-LINE +1 16 A

NUMBER-OF-STORED-ACC W 1 P
RECORD-NUMBER W 1 P VALUE 7

The program abends on the record #8
(From the job output:
TRACE 1
TRACE 2
NUMBER-OF-STORED-ACC5
7
TRACE 1
TRACE 2
NUMBER-OF-STORED-ACC6
8
TRACE 1
16 *******A006 PROGRAM INTERRUPT - CODE 7 (DATA EXCP) )

and so on.
If I will add the variable definition like this DUMMY-VAR or comment out any of statements in IF/END-IF block the abend doesn't happen. Or if I will extand FIVE-ACCNTS length.
Isn't it strange?

I believe at this time I explained better what I mean. And I don't have to deal much with HTML formatting using tags.

Re: Mysterious S0C7

PostPosted: Tue Apr 29, 2008 9:11 pm
by CICS Guy
If RECORD-NUMBER is the max recs in the input, then FILEIN:RECORD-LENGTH after the EOF would be 'unpredictable', i.e., garbage......
Try getting out of the loop when record count exceeds the expected number of records......

Re: Mysterious S0C7

PostPosted: Tue Apr 29, 2008 10:13 pm
by yurad
No, the file has 56 records and I play with RECORD-NUMBER from 5 to 8.
Again if I uncomment
* DUMMY-VAR W 1 A
everything is fine. Or if I comment out any of statements into the block
IF NUMBER-OF-STORED-ACC LT RECORD-NUMBER
   NUMBER-OF-STORED-ACC = NUMBER-OF-STORED-ACC + 1             
   IND = NUMBER-OF-STORED-ACC                                 
   ACCNT(IND) = REC-ACC-NMBR                               
END-IF

Re: Mysterious S0C7

PostPosted: Tue Apr 29, 2008 10:34 pm
by dick scherrer
Hello yurad,

In your initial post, is that the complete code for your program?

If it is, i'll try to run it on a system and see what happens.

Re: Mysterious S0C7

PostPosted: Wed Apr 30, 2008 7:54 pm
by yurad
Yes, please!
This is the working test program.
Just in case DCB of FILEIN THAT i HAVE HERE is :
FB 390 27690

THE VALUE COULD BE JUST ALL 9 (9999999999999....)

Re: Mysterious S0C7

PostPosted: Thu May 01, 2008 12:28 am
by dick scherrer
Hello,

The problem is that an entry into the array is being made after the end of the array. What is happening is that IND is being set to 6 but the array has only 5 occurs.

Re: Mysterious S0C7

PostPosted: Thu May 01, 2008 11:38 pm
by yurad
You're right. It's just occasional behaviour when I overlap memory.
Thank you!

Re: Mysterious S0C7

PostPosted: Thu May 01, 2008 11:47 pm
by dick scherrer
You're welcome :)

d