Rational Developer for System z, Version 7.5

Macro

The purpose of a Macro is to standardize functions common to several Programs. A called Macro is a complement to the generation possibilities of the system. Usually, a Macro. appears in a Program description as if its lines had been directly entered by a programmer.

A Macro. is not a sub-program: a sub-program can only contain consecutive statements, whereas a Macro can contain non-consecutive statements.

However, a Macro can call a sub-program.

Macro types

Generally speaking, Macros are used to describe functions that are common to several Programs, or to several procedures of the same Program.

There are six basic types of Macro-Structures:
  • A ’general program outline type’ used to give a Program a standard structure which takes into account all the Program development standard followed on your site. This type of Macro is also used to describe a body of technical (system-oriented) procedures that are linked to the use of a TP Monitor or a DBMS;
  • A ’technical (system-oriented) functions type’ used to standardize specific commands, such as the input/output procedures of a DBMS (Read, Modify, Suppress, etc.);
  • A ’complex technical functions type’ used to resolve all the complicated procedures involved in a DBMS, whether or not in an on-line environment, such as validation management, the sequential read of a file, the complete technical procedures for Database update, the particular access path used in a Database, etc. In general, this type is a combination of elementary technical functions that you must rewrite in order to minimize the task of connecting elementary Macro.’s to one another;
  • A ’general function type’ used to resolve certain procedures that are common to a set of applications, such as date validation, date transformation, or ″shop″ standards for on-line error message handling. You should keep in mind that this type of Macro is independent of the computer system, the TP Monitor and the DBMS used;
  • A ’specific function type’ used to ’harmonize’ the development of programs that make up a system. For example, to standardize the presentation of certain reports or screens by using common procedures defined in a Macro.
  • A type used to create cross-references; for example, if a Macro calls a sub-program, you can automatically find out what Programs use that sub-program.

Differences between Macros and sub-programs

You must often decide whether to use a sub-program or a Macro to consolidate all the procedures that are common to several Programs.

In order to find the answer, you must ask several questions:
  • Are the common procedures consecutive?
  • Is the position of these procedures defined?
  • Are there a lot of parameters?
  • Are these procedures executed as a general rule?
Answers to these questions will help determine which procedures should be executed in a sub-program and which should be executed in a Macro.
  • If they are not consecutive ⇒ Macro.
  • If the position is already defined ⇒ Macro.
  • If there are a lot of parameters ⇒ sub-program.
  • If the procedures are not executed as a general rule ⇒ sub-program.

Parameterizing a specific code screen key

You can parameterize the major part of the specific code screen keys (Function code, sub-Function code, and the first two characters of the line number). As a recommendation, before writing a Macro, you should try to structure the procedure to be written. Try to minimize the number of parameters in the key, so as to:
  • Facilitate usage of the Macro,
  • Obtain Programs with a homogenous structure,
  • Minimize the resolution time of a Macro.

As a general rule, it is not recommended to use a Macro. instead of a simple line or two of specific code. The latter solution may be more efficient with respect to performance at generation time and also to limit the number of necessary Macro calls.

Consistency of parameters

A Program may call several Macros. You should check that the parameters are used consistently.
Example: If two different Macros are called into the same Program, and both use a Data Structure as a parameter, both Macros would ideally have that Data Structure in the same position.
This has a twofold advantage:
  • It is easier for the programmer,
  • The same type of information is presented in the same order in a Program
While this is not always possible, it would be wise to consider the placement of parameters in existing Macros prior to designing a Macro.

Documentation of a Macro

A Macro must be well documented. It gives the developer the information needed to use the Macro properly: what each parameter means, which functions and/or sub-functions are used, etc.

Related tasks
Creating an instance
Related reference
New Macro wizard

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)