Page 1 of 1

Overwriting tables in Working Storage

PostPosted: Wed Nov 07, 2007 3:25 pm
by moski
Hi. I have two tables defined in Working Storage:

WORKING-STORAGE SECTION.

01 WS.

05 W-CTE-BG4CPTST PIC X(8) VALUE 'BG4CPTST'.

05 W-RETURN-CODE PIC 99 VALUE ZEROES.

05 W-CNT PIC 9999 VALUE ZERO.

05 TABLA-A.
15 TABLA-A-ITEM OCCURS 100 TIMES.
20 T-A-FIELD PIC XX VALUE SPACES.

05 TABLA-B.
15 TABLA-B-ITEM OCCURS 100 TIMES.
20 T-B-FIELD PIC X VALUE SPACE.

I want to put some data to these tables, in this way:
MOVE 1 TO W-CNT
PERFORM UNTIL W-CNT > 100
MOVE 'B' TO TABLA-B-ITEM(W-CNT)
ADD 1 TO W-CNT
END-PERFORM

MOVE 1 TO W-CNT
PERFORM UNTIL W-CNT > 150
MOVE 'A' TO TABLA-A-ITEM(W-CNT)
ADD 1 TO W-CNT
END-PERFORM

As you see table TABLA-A isn't big enough for 150 items that I want to put in it.
My question is:
Is it normal that 50 'A's will go to TABLA-B? In this way I loose data in TABLA-B (they are overwriten).
I think I should get an ABEND.
What to do to avoid overwritting table TABLA-B?
Mayby it is about some compiler options?

TIA, Marek

Re: Overwriting tables in Working Storage

PostPosted: Wed Nov 07, 2007 3:56 pm
by CICS Guy
moski wrote:What to do to avoid overwritting table TABLA-B?
Mayby it is about some compiler options?
You got it, there is a compiler option: Use SSRANGE to generate code that checks if subscripts or indexes try to reference an area outside the region of the table.

Re: Overwriting tables in Working Storage

PostPosted: Thu Nov 08, 2007 9:02 pm
by moski
CICS Guy,
thank you very much. I'll check this out.


Regards, Marek

Re: Overwriting tables in Working Storage

PostPosted: Fri Nov 16, 2007 3:24 am
by Tzadik Vanderhoof
But be aware that this will make your program run slower.