View previous topic :: View next topic
|
Author |
Message |
jsnair
New User
Joined: 26 Sep 2006 Posts: 38 Location: India
|
|
|
|
Hello,
I have one internal table as below. I would like to store new record in to this table if sapce is available in this. For checking the space availability I was doing the below steps.
Code: |
01 TAX-TABLE.
10 TAB-TAX-REC OCCURS 3.
15 TAX-DATE.
20 TAX-DATE-J PIC S9(04) COMP-3.
20 TAX-DATE-M PIC S9(02) COMP-3.
20 TAX-DATE-T PIC S9(02) COMP-3.
15 TAX-VALUE PIC S9(16)V9(2) COMP-3.
MOVE 03 TO MAX-I.
PERFORM VARYING I FROM 1 BY 1 UNTIL
I > MAX-I OR END-I
IF TAX-DATE-J (I) = ' ' AND
TAX-VALUE (I) = ' '
SET END-I TO TRUE
END-IF
END-PERFORM.
IF I <= MAX-I
Moving values in to internal-table
END-IF. |
But I am getting an error saying "IGYPA3022-S " (PACKED NON-INTEGER)" was compared with "' '". for both the array elements.
Could anybody please suggest how to find out whether the internal table will have space to hold new record, if so the postion in the table. |
|
Back to top |
|
|
Mathiv Anan
Active User
Joined: 23 Jul 2008 Posts: 106 Location: USA
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You need to add a flag variable to your table to denote whether or not that set of elements has been used. Set it when loading a row into the array, and then test it to determine how many active elements the table has. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Another method is to set a variable with the element count of elements that have a value.
This method is only applicable if you populate the elements in sequence from the start or end of the array.
The loop testing for values should not go beyond that number. If you are inserting new elements, you should use this value to determine the next empty element, and update the count accordingly.
The count value field should be communicated with the array to all programs accessing the array. |
|
Back to top |
|
|
|