Sequencing of parameters defined in an array
search cancel

Sequencing of parameters defined in an array

book

Article ID: 408698

calendar_today

Updated On:

Products

CA 2E

Issue/Introduction

One key sub-system consisting of a large suite of programs (mixture of screens and external functions) pass around a large number of parameters.  These parameters are mostly defined on a single-element array (to get around the 9 parameter constraint). This array has had some of its fields defined within their file definitions (as opposed to stand-alone entries on the array definition). Difficulties are experienced when re-generating some of these functions now in that the order of the parameters generated is different for no apparent reason.

For example, if there are two parameters defined within the same file on an array, e.g. Fields A and B. 

  • Field A appears first in the sequence of fields on the file definition but has a higher field surrogate number (on YFLDDTARFP). 

  • Function C defines both of these fields as parameters, using the array to do so. 

  • When function C was generated in 2005 these parameters were generated in the sequence they appear on the file, i.e. Field A followed by Field B. 

  • When generating function C now, these parameters are generated in field surrogate sequence, i.e. Field B followed by Field A. 

It would be really good to understand what, if anything, has changed in the code generator (RPG/RPGLE) over the years.

Environment

CA 2E 8.7.x

Cause

In older versions of 2E, array items could be ordered using the Array Key sequence.  But, starting with version 8.1.2, the product changed to no longer consider the Array Key sequence for array items, choosing to use the Array Field sequence instead.  In the above-described scenario, the Array Key sequences were filled in but the Array Field sequences were not.

Resolution

Correcting the Array Field sequence will enable the correct order of the parameters.

The change can be made to the Array Field Sequence on the "EDIT ARRAY KEY ENTRIES" screen to reflect the desired order of the array fields.

The "EDIT ARRAY KEY ENTRIES" screen can be accessed by taking F7 on the "EDIT ARRAY DETAILS" screen.

Additional Information

More information on defining arrays in 2E can be found here: Defining Arrays