Application Engine | Using App Engine system variables in your programs
A. Meta-SQL v Meta-Variables
A standard App Engine program gives you access to a large number of predefined system variables. The full list of these variables can be seen by consulting the PeopleBooks called ‘Using Application Engine Meta SQL’.
However, there is something slightly confusing about this reference. App Engine recognises two types of system variables: meta-SQL (which are specific to SQL statements) and meta-variables (which can be referred to anywhere in the App Engine program). Because the aforementioned PeopleBooks mixes up both types in the one section, pay particular attention to whether the variable is listed as a meta-SQL or a meta-variable. This will determine how you can use the variable. As an example, %CurrentDateIn and %CurrentDateOut are meta-SQL, while %AsOfDate is a meta-variable. This tip will consider meta variables only.
B. List of Commonly Used Meta-Variables
The main meta-variables are as follows:
- %AsOfDate – display the current date and time
- %SQLRows – display the number of rows affected by the most recent SQL insert, update or delete statement
- %AEProgram – display the name of the current App Engine program
- %AESection – display the name of the current App Engine Section
- %AEStep – display the name of the current App Engine Step
- %JobInstance – the process ID of the current Job instance
- %ProcessInstance – the process ID of the current Process instance
C. Meta-Variables in Action
The easiest way to see the most useful meta-variables is to insert an SQL step into your App Engine, one that performs an insert, delete or update operation. Then immediately after the SQL step, insert a Log Message step. You can refer to message 18030 / 3, as this is a generic message that allows four parameters to be passed into the message. Then, in the parameters section you can list the parameters one after the other, separated by a comma:
%AESECTION,%AESTEP,%SQLROWS, %ASOFDATE
The App Engine Step should end appearing as follows:

On running the App Engine, you should see a line produced in the log file:

Alternatively, you can refer to the meta variables in PeopleCode. In the case of %SQLRows, an SQL insert, delete or update must have been performed already in that step:

A similar message appears in the log file:

See Also