If you're a software vendor or a regular IBM i programmer that supports back-releases of the OS along with the current release, you may be coding for the LCD (lowest common denominator) when you declare variables.
With conditional compiling, I've been able to (A) avoid LCD and (B) automatically have my code use the current features when compiling for a newer release. here's how:
D pXMLStmt S * /IF DEFINED(*V7R1M0) D xmlStmt S A Len(2048000) D/ELSE D xmlStmt S 65535A D/ENDIF D Based(pXMLStmt) /free pXMLStmt = %alloc( %size(xmlStmt) ); ... Do more normal stuff here. dealloc pXMLStmt;
You do NOT need to use %ALLOC. I used it here to give a more complex example. Using normal (non-based) field declarations works just as well. The key here are the two features that some people overlook.
Other than that you can pretty much do whatever you want.
Note that on v7.1 the max length of an RPG field is 16mb. Prior limits (in reverse order) were:
A cooler way to do the above would be the use the D spec continuation symbols and avoid redundant field name usage. As I illustrate below:
D xmlStmt... /IF DEFINED(*V7R1M0) D S A Len(2048000) D/ELSE D S 65535A D/ENDIF