Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 8057
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 find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us