# Macros

Updated: 11/30/2021, 7:00:45 PM
Created: 11/30/2021, 7:00:45 PM
Last Updated By: Jake Tuttle
Read Time: 1 minute(s)

Macros contain predefined or often used elements of a jQL sentence, stored on the system like data definition records and are specified in the command sentence in a similar way.

When submitting a command containing one or more macros for execution it expands and includes the macro references in the sentence. You can substitute macros for any element of the command sentence except the command itself and the filename.

The search for macro definition records is in the same way as data definition records. Do not use a jQL keyword for a Data Definition record.

The first field of a macro definition must contain the letter M. The remaining fields are either command elements or comment lines (indicated by a leading asterisk ‘*’ and a space).

You can nest macros - a macro can refer to another macro - but the resulting command sentence must still follow the same rules as a normal jQL sentence. When nesting macros, beware of infinite loops where for example, macro A calls macro B that calls macro A that calls macro B.

# Example

SORT SALES BY S.CODE STD.HEADING
1

In this example, STD.HEADING is a macro which contains a standard heading clause:

STD.HEADING

M
* Standard heading for sales reports
Heading “SALES - COMPANY PRIVATE’LL’PAGE ‘PL’”
LPTR
1
2
3
4

When the sentence expands it will look like this:

SORT SALES BY S.CODE HEADING “SALES - COMPANY PRIVATE’LL’PAGE ‘” LPTR
1

Back to jQL Keywords and Connectives