Search code examples
arrayscobolsubscript

Getting Error - Not Enough subscripts or indices were specified in COBOL


I am getting an error while compiling COBOL module - 'Not enough subscripts or indices were specified for PREFER-VALUE of PREFERENCE of MQ82122A-DATA. A subscript or Index value of 1 was assumed for each missing subscript or index.'

Code

01 MQ82122A-DATA.
 03 UPDATE-PREFRENCES.
   05 UPDATE-AGREEMENT-PREF.
      07 PREFRENCES.
         10 PREFRENCE            OCCURS 10.
            13 CATEGORY                    PIC X(10).
            13 PREFRENCE-TYPE    OCCURS 5.
               15 PREFER-VALUE             PIC X(100).

MOVE DOCPREF1     TO PREFER-VALUE IN PREFERENCE IN MQ82122A-DATA(1).
MOVE DOCPREF2     TO PREFER-VALUE IN PREFERENCE IN MQ82122A-DATA(2).

Solution

  • The use of PREFERENCE as a qualifier is confusing and may be unnecessary.

    If DOCPREF1 and DOCPREF2 are defined as PIC X(100) then PREFERENCE as a qualifier is unnecessary and two subscripts must be used, the first for PREFERENCE, the second for PREFERENCE-TYPE.

    If DOCPREF1 and DOCPREF2 are defined identically to a single occurrence of PREFERENCE then IN PREFER-VALUE should be removed from the MOVE statement and a single subscript for PREFERENCE should be used.


    With spelling corrections and based on OP's "comment" as an answer (flagged and deleted), the solution was to add a second subscript similar to that given below in the MOVE statements.

       DATA DIVISION.
       01 DOCPREF1 PIC X(100).
       01 DOCPREF2 PIC X(100).
       01 MQ82122A-DATA.
        03 UPDATE-PREFERENCES.
          05 UPDATE-AGREEMENT-PREF.
             07 PREFERENCES.
                10 PREFERENCE            OCCURS 10.
                   13 CATEGORY                    PIC X(10).
                   13 PREFERENCE-TYPE    OCCURS 5.
                      15 PREFER-VALUE             PIC X(100).
       PROCEDURE DIVISION.
           MOVE DOCPREF1
               TO PREFER-VALUE IN PREFERENCE IN MQ82122A-DATA(1, 1).
           MOVE DOCPREF2
               TO PREFER-VALUE IN PREFERENCE IN MQ82122A-DATA(1, 2).