Using a Data Area as a Control Specification

If a control specification is not present in your source, the RPG compiler will search for a data area containing control specification keywords. If the data area is not found, a default blank control specification will be used.

Use the CL command CRTDTAARA (Create Data Area) to create a data area defined as type *CHAR. (See the IBM® i Information Center for a description of the Create Data Area command.) Enter the keywords in the Initial Value parameter of the command.

For example, to create an RPGLEHSPEC data area that will specify a default date format of *YMD, and a default date separator /, you would enter:
CRTDTAARA DTAARA(MYLIB/RPGLEHSPEC)
          TYPE(*CHAR)
          LEN(80)
          VALUE('datfmt(*ymd) datedit(*ymd/)')

The data area can be whatever size is required to accommodate the keywords specified. The entire length of the data area can only contain keywords.

If you are using the Program Verifier in Rational® Developer for i, then a file named RPGLEHSPEC.RPGLE in the .metadata directory of your workspace will be used as the control specification data area. This file must contain valid RPG IV control statements.

Tip: Instead of using a data area to hold your keywords, consider using a copy file instead. When you use a copy file, the keywords in the copy file are used even if there are additional control statements in your source.
For example, the following source file will not use the keywords in a data area, because there is a Control statement in the source, preventing the compiler from searching for the data area.

H NOMAIN
D fld             S             10A
The following source file will use the keywords in the DFTCTLKW copy file.

 /COPY QRPGLESRC,DFTCTLKW
H NOMAIN
D fld             S             10A