Allow fields greater than 256 characters

Date: 16 April 2001
Updated: 3 July 2007
Product/Release: LANSA for the AS/400
Abstract: Allow the definition of 256 + length fields in LANSA
Submitted By: LANSA Technical Support

The following approach can be applied for fields up to 9999 characters long and even for any non-supported data types.

The external file definition is loaded into LANSA and then virtual fields are created to allow the manipulation of the field and it's data even though it is greater than 256 characters using Virtual Field Derivation code.

  1. Create a file into LANSA as maintained by OTHER and load its definition from the external library. It has a 300 characters long field called FA300 (ie its name in the DDS).

    If you make the file operational (i.e. create the I/O module) generating the I/O Module source listing, the compilation will fail but if you see the generated RPG code, you will see that LANSA failed to convert the FA300 field into its internal field name.

    In the I specs, the original field name (i.e. FA300, brought across from the DDS) is preserved in the generated RPG code and it is located in the same buffer positions (ie positions from and to in the record format) as defined in the DDS.

    This fact allows the use of the original field name as an input field (to be worked with) for any virtual field definition. Therefore, any number of virtual fields can be created to be derived from and to this field name. (i.e. FA300).

    This example just uses two fields.
  2. Create two fields in LANSA.

    E.g. FA300A and FA300B. Both alphanumeric with a length of 150 characters.

  3. Define these virtual fields into the file loaded in step 1. (Option 23)

  4. Specify YES in Edit virtual field derivation code . . . . . .      YES, NO

  5. Select "Calculations after input from file" and type in : C* VC_USING (FA300A)
    C             MOVELFA300 FA300A             left part
    ... and :
    C* VC_USING (FA300B)
    C             MOVE FA300 FA300B             right part

    The comment lines with the VC_USING are necessary for each virtual field (between parentheses) and must not be omitted.
  6. Select "Calculations before output to file" and type in :
    C* VC_USING (FA300A)
    C             MOVELFA300A FA300             left part
    ... and :
    C* VC_USING (FA300B)
    C             MOVE FA300B FA300             right part

  7. Commit the changes and make the file operational (ie create the I/O Module).

    This time the compilation should be fine and the virtual fields FA300A and FA300B can be used within LANSA to access (ie change) the FA300 real field in the file.