Deltazor
Deltazor

Reputation: 66

How do I pass an array data structure as a parameter?

I'm trying to pass an array DS as a parameter but when compiling I get an "RNF5343 Array has too many omitted indexes" error.

The Array Data Structure is defined the same in both programs as

D ResponseData    DS                  Dim(100) Qualified
D  Field1                        3  0
D  Field2                       26  
    ...
D  Field45                      26  

Simple definitions of called program "PGM1"

D PGM1            PI
D  ReceiveVar                         LikeDS(ResponseData) Dim(100)
D  ReceiveCount                 10U 0 Const

D PGM1            PR
D  ReceiveVar                         LikeDS(ResponseData) Dim(100)
D  ReceiveCount                 10U 0 Const

...
Multiple row fetch using embedded SQL into RecieveVar
...

Simple definition of calling program "PGM2"

D PGM2            PR                  ExtPgm('PGM1')
D  ReceiveVar                         LikeDS(ResponseData) Dim(100)
D  ReceiveCount                 10U 0 Const

PGM1(RecieveVar: RecieveCount);

When compiling the calling program "PGM2" the RNF5343 Array has too many omitted indexes occurs. I don't want to pass only one instance of the array but the entire thing.

What should I do to be able to pass an array data structure as a parameter between two programs?

Upvotes: 0

Views: 6163

Answers (2)

Barbara Morris
Barbara Morris

Reputation: 3674

If you really have the PGM1 prototype defined in PGM1 and another definition of the PGM1 prototype in PGM2, then I recommend you move the prototype with the EXTPGM keyword into a copy file, and copy it into both PGM1 and PGM2. Having two separate prototypes defeats the ability of the compiler to ensure that parameters are passed correctly. It's too easy to change the prototype in the program itself and forget to change all the prototypes in the callers.

Upvotes: 2

Charles
Charles

Reputation: 23793

I think you've got some typos in your example...possibly in your actual code.

The following (PGM2) compiles fine for me:

 H option(*nodebugio) debug(*INPUT) cvtopt(*datetime)

 D ResponseData    DS                  Dim(100) Qualified
 D  Field1                        3  0
 D  Field2                       26
 D  Field45                      26

 D PGM1            PR                  ExtPgm('PGM1')
 D  ReceiveVar                         LikeDS(ResponseData) Dim(100)
 D  ReceiveCount                 10U 0 Const

  /FREE

   pgm1(ResponseData:10);

   *INLR=*ON;
   return;
  /END-FREE        

Though I'd recommend making use of the TEMPLATE keyword

 H option(*nodebugio) debug(*INPUT) cvtopt(*datetime)

 D ResponseData_t  DS                  template
 D  Field1                        3  0
 D  Field2                       26
 D  Field45                      26

 d myData          ds                  likeds(ResponseData_t) dim(100)

 D PGM1            PR                  ExtPgm('PGM1')
 D  ReceiveVar                         LikeDS(ResponseData_t) Dim(100)
 D  ReceiveCount                 10U 0 Const

  /FREE

   pgm1(myData:10);

   *INLR=*ON;
   return;
  /END-FREE       

Upvotes: 0

Related Questions