Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to find out last element in an internal table

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

New User


Joined: 26 Sep 2006
Posts: 38
Location: India

PostPosted: Mon Feb 15, 2010 4:16 pm    Post subject: How to find out last element in an internal table
Reply with quote

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
View user's profile Send private message

Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Mon Feb 15, 2010 4:33 pm    Post subject: Reply to: How to find out last element in an internal table
Reply with quote

You cannot check for spaces in comp variables.

Please see the Bill's post on using dynamic array.

http://www.ibmmainframes.com/viewtopic.php?t=46547
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Mon Feb 15, 2010 5:56 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Mon Feb 15, 2010 8:14 pm    Post subject:
Reply with quote

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
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
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us