How are Table INDEX values properly initialized in UniKix TPE environment with isCOBOL ?


UNIKIX TPE INDEX INITIALIZATION

The Developer’s Guide of UNIKIX TPE Documentation states:

“Before UniKix TPE runs a COBOL application program, it initializes the contents of working storage. Using a copy of working storage that was saved before executing the COBOL program for the first time, UniKix TPE saves everything from DFH-START (which is included by kixclt as the first working-storage item) to DFHEIV (which is the last item before the linkage section). However, because COBOL indexes are not stored within these boundaries, UniKix TPE is unable to initialize the COBOL indexes for every execution of a COBOL program. Therefore, these index values must be initialized by the application.”

UniKix™ Transaction Processing
Environment Software Developer’s Guide
Release 11.2.1

The General Rule for an INDEXED BY data name used in a table SEARCH, is defined by the ANSI COBOL Standard as:

  1. The value of a subscript shall be a positive integer.
  2. The lowest possible occurrence number represented by a subscript is 1, which identifies the first element of any given dimension of a table.
  3. The highest permissible occurrence number for any given dimension of the table is the maximum number of occurrences of the item as specified in the associated occurs clause.

The Sample code below shows an example of initializing the table INDEX value: Note: The isCOBOL compiler option “-di” does not automatically initialize a table’s INDEX value when running in the UniKix TPE environment. A COBOL “SET” statement is required to properly initialize INDEX items using the above General Rule.



00562              25  CA-FUNC-DESC  OCCURS  27 TIMES INDEXED              CL210
00563                                             BY  CA-INDEX.            CL210
00564                  30  CA-FUNC          PIC X(02).                     CL210
00565                  30  CA-TRAN-ID       PIC X(04).                     CL210
00566              25  CA-ORDER-FUNC-DESC  OCCURS 7 TIMES INDEXED          CL210
00567                                             BY  CA-ORDER-INDEX.      CL210
00568                  30  CA-ORDER-FUNC    PIC X(02).                     CL210
00569                  30  CA-ORD-TRAN-ID   PIC X(04).                     CL210
 
 
01277        IF  88-OTHER-FUNC-CD                                          CL210
               display '88-other-func-cd'
01283        ELSE                                                          CL210
               display 'search ca-ord-func-desc' 


+++++ instruction inserted here ++++++ 


01298            SET CA-INDEX     TO  1                                    CL235


+++++ end of insertion ++++++ 


01284          SEARCH CA-ORDER-FUNC-DESC VARYING CA-ORDER-INDEX            CL210
01285            AT END                                                    CL210
01286             CONTINUE                                                 CL210
01287          WHEN  CA-ORDER-FUNC(CA-ORDER-INDEX) EQUAL CA-FUNC-CD        CL210
                 display 'setting 88-valid-func'
01288            SET  88-VALID-FUNC         TO TRUE                        CL210
01289            MOVE CA-ORD-TRAN-ID(CA-ORDER-INDEX)                       CL210
01290                                       TO CA-TARGET-TRAN              CL210
01291                                          WS-TEMP-TRAN                CL210
01292                                                                      CL210
01293          END-SEARCH                                                  CL210




Article ID: 132
Created: June 12, 2010
Last Updated: June 14, 2010
Author: Support KB Author

Online URL: https://support.veryant.com/phpkb/article.php?id=132