RPG IV currently lacks a clean, safe, and expressive way in free-form RPG to treat an array (or a contiguous subset of an array) as a character string. This gap is most visible when attempting to replicate the behavior of the legacy MOVEA opcode, which can move character data into an array or array slice with predictable padding and truncation behavior.
In fully free-form RPG, there is no direct equivalent to MOVEA. While workarounds exist (loops, %SUBST, overlays, pointer-based techniques, or data structures), they are verbose, error-prone, and discourage adoption. As a result, many developers either avoid these patterns entirely or retain legacy fixed-form code solely to preserve MOVEA functionality.
Proposed Enhancement
Enhance the %CHAR built-in function to allow an RPG array (or a range of its elements) to be treated as a contiguous character string target.
Proposed syntax:
%CHAR( myArray [: startElem [: nbrElems ] ] )
myArray - An array of character elements.
startElem (optional) - The starting array element (1-based).
nbrElems (optional) - The number of array elements to include.
This form of %CHAR would present the specified array elements as a single character variable for assignment and manipulation. It should work on the left or right side of the Equals sign on an assignment statement.
In this example:
The string on the right-hand side is copied into myArray, beginning at element 3.
Characters are assigned sequentially across array elements.
Any remaining elements in the referenced range are automatically cleared or padded according to standard RPG character assignment rules.
If the source string exceeds the available array space, normal truncation rules apply.
This mirrors the behavior of MOVEA in this context, but in a modern, free-form, function-based construct.
Behavioral Expectations:
Assignment behaves like a character move, not an element-by-element loop.
Padding and truncation follow existing RPG character semantics.
No undefined behavior or reliance on overlays, pointers, or compiler-dependent tricks.
The feature is additive and backward-compatible.
Benefits
Enables clean, readable free-form RPG code without reverting to legacy opcodes.
Provides a safe and expressive replacement for MOVEA.
Reduces boilerplate loops and error-prone "manual" logic.
Encourages modernization of existing RPG applications.
Aligns with IBM’s ongoing efforts to evolve RPG while preserving its strengths.
Summary
Extending %CHAR to support arrays as contiguous character strings fills a long-standing functional gap in free-format RPG IV. It offers a natural, modern replacement for MOVEA, improves code clarity, and lowers the barrier to fully free-form RPG without introducing new opcodes or breaking existing behavior.
The reason that IBM decided not to add MOVEA to the list of operation codes to be used in free-form calculations was that almost every usage of MOVEA was to perform some string manipulation. For example, a common pattern was to use MOVEA from a string to an array, process the array, and then use MOVEA from the array back to the string. This entire pattern could be replaced by a single statement with one or more string built-in functions.
IBM believes that instead of changing an individual MOVEA operation to a free-form equivalent, it is better to evaluate why the MOVEA operation was being used and replace the MOVEA operation and any related code together, possibly removing the array entirely.
- IBM Power Systems Development
CONCATARR doesn't apply as it doesn't work on the left-side of the assignment
You almost have what you want using %CONCATARR() and if you need a fragment of the array you could use %SUBARR() to get that