Search code examples
rpgle

Is Static Dynamic Array not allowed in RPGLE sub-procedure


SEQ is throwing a RNF3772 error if I try to declare a Static Dynamic array in a RPGLE sub-procedure. Is static dynamic array not allowed in sub-procedure?

Below is an example of what I entered in SEQ. The error that I got is "The keyword is not allowed following keyword STATIC; keyword is ignored."

P proc1           B                                                    
D                 pi                                                   
D myArray         s             10    dim(1000) static based(myArray_p)

P                 E                                                    

Solution

  • To define your array as based, but have it retain its values between calls, you have to define the basing pointer as static. It will probably be impossible to free the allocated storage except by reclaiming the activation group, unless your procedure has a way of knowing the array is no longer needed for future calls.