Space announcement This documentation space provides the same content as before, but the organization of the content has changed. The content is now organized based on logical branches instead of legacy book titles. We hope that the new structure will help you quickly find the content that you need.

Determining Index and Indexed Field Values


The following tasks tell how to determine an indexed occurrence within a table using a basic language report.

Task 1: Enterprise Cobol 5.1 and later

Starting in Cobol 5.1, indexes defined with INDEXED BY clause are in the Initial Heap area for the program. Indexes are listed in the order that they were defined at the beginning of the “Initial Heap Storage Map” section of the compile listing. Indexes are 4 bytes long. Note the offset of the index you want to use.

Initial Heap Storage Map

                     * * * * *   I N I T I A L   H E A P     S T O R A G E     M A P   * * * * *   
                                                                                                     
OFFSET (HEX)   LENGTH (HEX)   NAME                                                                       
                                                                                                          
          0              4       MGMT-IX                                                                  
          4              C       BLT_Ptrs                                                                       
         10              8       VNI_cells                                                                      
         18             74       GPCB                                                                           
         8C              4       WS-BASE-ADDRESS                                                                
                                                                                                                
                                                                                                                
                   * * * * *   E N D     O F    I N I T I A L   H E A P     S T O R A G E     M A P   * * * * *

Select Working Storage from the Cobol Storage Areas screen. The screen will look like this:

Abend-AID ----------------- COBOL Storage Area -------- Row 000001 of 000002
COMMAND ===>                                                SCROLL ===> CSR  
                                                                        ==>  
Working Storage Section for program: PAYROLL2                                
                                                                             
Name                   Address   Length                                      
*********************  ********  ********  *********************************
C_WSA WRITABLE STATIC  3E109070  000006A8  Total Bytes=0001704               
WSA31-BASE-ADDRESS     3E109768  00000335  Total Bytes=0000821               
***************************** BOTTOM OF DATA *******************************

Select the C_WSA WRITABLE STATIC address and use the offset for the desired index to find the index value. Locate the data item as described in 1.7. Find the data in the report. Then advance the display by the index value to see the indexed field with the + command. For example, if the desired index is at offset C,

COMMAND ===> +C

Task 2: Cobol version 4.2 and earlier

The data division map includes the index cells, as on lines 91 and 102 in the following example.

Source   Hierarchy and                                    Base       Hex-Displacement  Asmblr Data                    Data Def  
LineID   Data Name                                        Locator    Blk   Structure   Definition      Data Type      Attributes
   88   1  WORK-TABLE. . . . . . . . . . . . . . . . . . BLW=00000  2A0               DS 0CL224       Group                    
   89     2  WT-FIXED. . . . . . . . . . . . . . . . . . BLW=00000  2A0   0 000 000   DS 24C          Display                  
   90     2  WT-WHOLE-ARRAY. . . . . . . . . . . . . . . BLW=00000  2B8   0 000 018   DS 0CL8         Group          O         
   91        WT-INDX . . . . . . . . . . . . . . . . . . IDX=00001  000                               Index-Name               
   92       3  WT-ELEMENT. . . . . . . . . . . . . . . . BLW=00000  2B8   0 000 018   DS 0CL8         Group                    
   93         4  WT-A. . . . . . . . . . . . . . . . . . BLW=00000  2B8   0 000 018   DS 4C           Display                  
   94         4  WT-B. . . . . . . . . . . . . . . . . . BLW=00000  2BC   0 000 01C   DS 3P           Packed-Dec               
   95         4  WT-C. . . . . . . . . . . . . . . . . . BLW=00000  2BF   0 000 01F   DS 1C           Display                  
   98   1  PARM-INPUT. . . . . . . . . . . . . . . . . . BLL=00001  000               DS 0CL102       Group                    
   99     2  PARM-LENGTH . . . . . . . . . . . . . . . . BLL=00001  000   0 000 000   DS 2C           Binary                   
  100     2  PARM-DATA . . . . . . . . . . . . . . . . . BLL=00001  002   0 000 002   DS 0CL100       Group                    
  101       3  PARM-CHAR . . . . . . . . . . . . . . . . BLL=00001  002   0 000 002   DS 1C           Display        O         
  102          PARM-INDX . . . . . . . . . . . . . . . . IDX=00002  000                               Index-Name               

Each index cell is four bytes long and they are numbered starting with 1. The starting location of the index cells in the TGT is shown in the TGT MEMORY MAP in the compile listing.

Select Program Storage for the program on the Program Summary screen in the viewer. On the Program Storage screen, select TGT. Find the offset in the TGT for the index that you want to see and note the index value.

Task 3: Find the data

Find the data name in question as in 1.7 above. This will get you to the first occurrence. To find the occurrence pointed to by the index, simply add the value in the index to the address of the first occurrence.

The index value is an offset to the desired occurrence in the array. To determine which occurrence the index is pointing to, divide the index value by the length of the field with the OCCURS clause and add 1.


 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*