Using the REPLACE statement to replace sections and named common areas

The REPLACE statement is used to replace sections and named common areas (also called common sections) by providing old and new section names. The name of the old section appears first, followed by the name of the new section in parentheses.

The scope of the REPLACE statement is the immediately following module, unless the -IMMED option is used. The REPLACE statement must precede either the input module that contains the section to be replaced, or the INCLUDE statement that specifies the input module. The replacing section can be either before or after the replaced section in the binder input. If a REPLACE statement appears in a data set included from an automatic call library and is not immediately followed by an object module in the same data set, the request is ignored.

If the -IMMED option is used with REPLACE, then the REPLACE operates against any sections that have already been included as part of the current bind operation. The module being built is searched immediately for a section name matching the specified old section name.

An external reference to the old section (or area) from within the same input module is resolved to the new section. An external reference to the old section from any other module becomes an unresolved external reference unless one of the following occurs:
In the following example, the REPLACE statement is used to replace one section with another of a different name. Assume that the old section SEARCH is in library member TBLESRCH, and that the new section BINSRCH is in the data set &&OBJECT, which was passed from a previous step as shown in Figure 1.
Figure 1. Replacing a section with the REPLACE control statement

ieab1o04

The output module contains BINSRCH instead of SEARCH; any references to SEARCH within the module refer to BINSRCH. Any external references to SEARCH from other modules will not be resolved to BINSRCH.

See REPLACE statement for more information on using the REPLACE statement.