Overwriting tables in Working Storage



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Overwriting tables in Working Storage

Postby moski » Wed Nov 07, 2007 3:25 pm

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
moski
 
Posts: 2
Joined: Wed Nov 07, 2007 3:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Overwriting tables in Working Storage

Postby CICS Guy » Wed Nov 07, 2007 3:56 pm

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.
CICS Guy
 
Posts: 246
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time

Re: Overwriting tables in Working Storage

Postby moski » Thu Nov 08, 2007 9:02 pm

CICS Guy,
thank you very much. I'll check this out.


Regards, Marek
moski
 
Posts: 2
Joined: Wed Nov 07, 2007 3:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Overwriting tables in Working Storage

Postby Tzadik Vanderhoof » Fri Nov 16, 2007 3:24 am

But be aware that this will make your program run slower.
Tzadik Vanderhoof
 
Posts: 21
Joined: Tue Nov 13, 2007 11:53 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post