Ashish
Ashish

Reputation: 9

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).

Upvotes: 0

Views: 1732

Answers (2)

Rick Smith
Rick Smith

Reputation: 4407

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).

Upvotes: 2

Brian Tiffin
Brian Tiffin

Reputation: 4116

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

PREFER-VALUE needs a subscript, it's in a group that occurs 5, inside the first preference from DATA(1). Compiler gives you the first PREFER-VALUE within the ambiguous inner field reference.

I'd rather see

MOVE DOCPREF1 TO PREFER-VALUE IN MQ82122A-DATA(1,1)
MOVE DOCPREF2 TO PREFER-VALUE(1,2)
                       *> or (2,1) depending on what you mean.

Drop the INs beyond top level and just use the two subscripts, would be the recommendation. The sample depends on the question Rick raised about the layout or PIC of the DOCPREF fields, and may be utterly incorrect.

As an aside, GnuCOBOL won't compile those field references, as is.

prompt$ cobc subs.cob
subs.cob: in paragraph 'sample-main':
subs.cob:40: error: 'PREFER-VALUE IN PREFERENCE IN MQ82122A-DATA' is not defined
subs.cob:41: error: 'PREFER-VALUE IN PREFERENCE IN MQ82122A-DATA' is not defined

That may be a deficiency, but not by much in this case, I don't think.

Upvotes: 1

Related Questions