%GEN (generator {: options})
%GEN is used as the third operand of the DATA-GEN operation code to specify the program or procedure to generate the document, and any options supported by the generator. %GEN does not return a value, and it cannot be specified anywhere other than for the DATA-GEN operation code.
- A procedure pointer expression
- The %PADDR built-in function
- A character expression identifying a program. It must be in one of the following forms
- MYPGM
- MYLIB/MYPGM
- *LIBL/MYPGM
- A character expression identifying a procedure in a service program. It must be in one of the following forms
- MYSRVPGM(myProcedure)
- MYLIB/MYSRVPGM(myProcedure)
- *LIBL/MYSRVPGM(myProcedure)
The second operand specifies options that are passed directly to the generator. The generator determines the nature of the options that it supports.
If the second operand is the name of a variable which can be modified, the address of the variable is passed directly to the generator.
If the second operand is a character expression, including the name of a character variable that cannot be modified, a pointer to a null-terminated string containing the content of the expression is passed to the generator.
The generator receives information that indicates whether the pointer the pointer is a null-terminated string.
Examples of %GEN
DATA-GEN myfld %DATA(document) %GEN('MYGEN');
DCL-DS genOptions LIKEDS(myGenOpts_T);
DATA-GEN myDs %DATA('myData.txt' : 'doc=file')
%GEN('MYGENPROCS(myProcedure)' : genOptions);
DCL-S p POINTER(*PROC);
DCL-S sep CHAR(1) INZ(',');
DATA-GEN myds %DATA('myData.txt' : 'doc=file')
%GEN(p : 'sep=' + sep);
DCL-PI *N;
constParm VARCHAR(20) CONST;
END-PI;
DATA-GEN myds %DATA('myData.txt' : 'doc=file')
%GEN(%PADDR(myProc) : constParm);
For more examples of %GEN, and more information about the DATA-GEN operation, see DATA-GEN (Generate a Document from a Variable).
See the Rational Open Access: RPG Edition topic for information on writing a generator.