The VC_COPY Command
In Writing Virtual Field Derivation Code, a duplication problem was described that can occur when virtual derivation code from multiple files is copied into an RDML function that uses the *DBOPTIMISE facilities.
The VC_COPY command can be used in virtual field derivation code to indicate that a block of code only be copied if it has not already been copied.
The syntax diagram for the VC_COPY command looks like this:
VC_COPY ------ SRCFILE ------ file name . library name ------->
>----- SRCMBR ------- source member name -------------|
Specifies the name and library of the IBM i source physical file containing the source member specified by the SRCMBR parameter.
*LIBL is acceptable and preferable as the library name, but of course, the correct library must be in the library list of any I/O module or RDML compile job attempting to access the member.
Specifies the name of the source member in the source file specified by the SRCFILE parameter that contains the code block to be copied.
Some points to note about using VC_COPY commands are:
- The nominated source member is not copied if a previously processed VC_COPY command nominated the same source file, library and source member.
- The nominated source member cannot contain VC_COPY or VC_USING commands. If they are encountered they are totally ignored and treated like comments.
- The nominated source member cannot contain RPG compiler directive /COPY commands. If they are used, they will cause RDML functions to fail to compile.
- VC_COPY commands are usually only used to copy code blocks that may be common or shared between different file definitions. It would be unusual to use this facility to include "Before output" or "After input" C specification code blocks.
- The command and its parameters should only ever be coded between columns 8 -> 80 of the source program line. LANSA ignores columns 1 -> 7 of the line when processing a VC_COPY command and its parameters.
- Where a command and its parameters will not fit on one line use a "+" sign as the last character on the line and continue the command in column 8 (or beyond) on the next line. This method is identical to that used when continuing IBM i operating system commands over multiple lines. Note that the "-" sign continuation character supported by the IBM i is NOT supported by LANSA in this context.