When defining prototypes in a /COPY file, you may want to define return values or parameters LIKE some of the fields in an externally described file. This works fine if all the programs using the /COPY file also define that file and don't use any PREFIX on the file. To ensure that all programs can use the /COPY file even if they don't define the file, use an externally described data structure in your /COPY file. Use a prefix to keep your names different from any names in the program itself.
D E DS BASED(TYPE_DEFINITION_POINTER)
D EXTNAME(somefile)
D PREFIX(SOMEFILE_TYPES_)
D proc PR
D parm LIKE(SOMEFILE_TYPES_FLD1)
If you are on V5R1 or later, you could use QUALIFIED instead of PREFIX:
D somefileTypes...
D E DS BASED(TYPE_DEFINITION_POINTER)
D EXTNAME(somefile)
D QUALIFIED
D proc PR
D parm LIKE(somefileTypes.FLD1)
Note: BASED(TYPE_DEFINITION_POINTER) is used to avoid having any storage assigned to the data structure. Sixteen bytes of storage will be assigned to the pointer itself, so you should always use the same pointer for this kind of "type definition."
--Barbara Morris
This email address is being protected from spambots. You need JavaScript enabled to view it.
LATEST COMMENTS
MC Press Online