Handling dynamic array

Hello,

I’m having a dynamic array fields defined in a PDA and in turn used by a Subprogram.

PDA fields:

1 #param
2 #IN1 (A1)
2 #IN2 (A15/1:50)
2 #OUTPUT
3 #PARAM3 (A15/1:,1:)
3 #PARAM4 (N10/1:,1:)
4 #PARAM5 (N2)

Now that, we have a list of programs (all in Reporting mode) wherein we have to call that subprogram, process the input data and retrieve back the results (in dynamic array).

In Reporting mode, field definition expects the total size of the param’s to be entered which I cant provide.

Is there a way to handle dynamic arrays from a reporting mode program.

Kindly help.

Thanks in advance, muthu

X-array is defined in a DEFINE DATA statement (same holds true for dynamic variables). In reporting mode you can use a DEFINE DATA statement (known as “structured data mode”).

If this doesn’t help, please post a sample piece of code demonstrating what you have so far and what you are actually trying to do.

Thanks for your reply.

Just to elaborate more on the issue…

Part 1:
I have a subprogram in Structured mode using a PDA which is having group variable and dynamic array in it.

PDA as below
1 #param
2 #IN1 (A1)
2 #IN2 (A750)
2 REDEFINE #IN2
3 #IN2-ARR (A15/1:50)
2 #OUTPUT
3 #PARAM3 (A15/1:,1:)
3 #PARAM4 (N10/1:,1:)
4 #PARAM5 (N2)

Part 2:
I have a list of programs (all in Reporting mode) where I have to call the above said subprogram and get the output back. How to achieve this.

Can we add the above PDA directly into a reporting mode program or
How to define the above PDA fields into the Reporting mode program (I’m interested to hear on how to define a Group variable, dynamic array in reporting mode program)

Now that, what I have been tried so far is,

  1. Add the PDA into the report mode program as below

DEFINE DATA LOCAL
LOCAL USING
END-DEFINE

However getting an error saying that I have to include all the existing fields into the DEFINE DATA structure which I cant.

  1. Tried adding group variable as in PDA but Natural throwing error saying I have to define the length of it which I dont know (as we have dynamic array into it).

Hope you’re able to get the issue?

  1. Your PDA has a typo: #PARAM5 must be at level 3 (not 4)
  2. As Douglas says, in Structured Data Mode programs “ALL variables must be defined with the DEFINE DATA statement”.
  3. Perhaps you could write a “front end” Structured Mode program (or subprogram) whose sole purpose is to call the X-Array subprogram and repackage the result X-Arrays into “normal” arrays and pass those back to your Reporting Mode program(s).
    .
    Questions about the X-Array subprogram:
    Q1. Do the arrays REALLY have to be X-Arrays?
    Q2. Couldn’t you make do with Variable arrays (ie. using the 1:V notation)?

To avoid the manual effort of moving all local variables in all your reporting mode programs to the DEFINE DATA area, you can use AIVs. Copy the following lines to all your programs and the subprogram.

INDEPENDENT
1 +IN1 (A1)
1 +IN2 (A750)       1 REDEFINE +IN2
  2 #IN2-ARR (A15/1:50)
1 +PARAM3 (A15/1:*,1:*)
1 +PARAM4 (N10/1:*,1:*)
1 +PARAM5 (N2)

Then adjust the subprogram to use the AIVs instead of the PDA.