Forming data set names with LSEARCH | SEARCH options

When the filename specified in the #include directive is not in absolute form, the compiler combines it with different types of libraries to form complete data set specifications. These libraries may be specified by the LSEARCH or SEARCH compiler options. When the LSEARCH or SEARCH option indicates a data set then, depending on whether it is a ddname, sequential data set, or PDS, different parts of filename are used to form the ddname or data set name.

Forming DDname

Example: The leftmost qualifier of the filename in the #include directive is used when the filename is to be a ddname:
Invocation:
SEARCH(DD:SYSLIB)
Include directive:
#include "sys/afile.g.h"
Resulting ddname:
DD:SYSLIB(AFILE)

In this example, if your header file includes an underscore (_), for example, #include "sys/afile_1.g.h", the resulting ddname is DD:SYSLIB(AFILE@1).

Forming sequential data set names

Example: You specify libraries in the SEARCH | LSEARCH options as sequential data sets by using a trailing period followed by an asterisk (.*), or by a single asterisk (*). See LSEARCH | NOLSEARCH to understand how to specify sequential data sets. All qualifiers and periods (.) in filename are used for sequential data set specification.
Invocation:
SEARCH(AA.*)
Include directive:
#include "sys/afile.g.h"
Resulting fully qualified data set name:
userid.AA.AFILE.G.H

Forming PDS name with LSEARCH | SEARCH + specification

Example: To specify libraries in the SEARCH and LSEARCH options as PDSs, use a period that is followed by a plus sign (.+), or a single plus sign (+). See LSEARCH | NOLSEARCH to understand how PDSs are specified. When this is the case then all the paths, slashes (replaced by periods), and any qualifiers following the leftmost qualifier of the filename are appended to form the data set name. The leftmost qualifier is then used as the member name.
Invocation:
SEARCH('AA.+')
Include directive:
#include "sys/afile.g.h"
Resulting fully qualified data set name:
AA.SYS.G.H(AFILE)
and
Invocation:
SEARCH('AA.+')
Include directive:
#include "sys/bfile"
Resulting fully qualified data set name:
AA.SYS(BFILE)

Forming PDS with LSEARCH | SEARCH Options with No +

Example: When the LSEARCH or SEARCH option specifies a library but it neither ends with an asterisk (*) nor a plus sign (+), it is treated as a PDS. The leftmost qualifier of the filename in the #include directive is used as the member name.
Invocation:
SEARCH('AA')
Include directive:
#include "sys/afile.g.h"
Resulting fully qualified data set name:
AA(AFILE)

Examples of forming data set names

The following table gives the original format of the filename and the resulting converted name when you specify the NOOE option:

Table 1. Include filename conversions when NOOE is specified
#include Directive Converted Name
Example 1. This filename is absolute because single quotation marks (') are used. It is a sequential data set. A library search is not performed. LSEARCH is ignored.
#include "'USER1.SRC.MYINCS'" USER1.SRC.MYINCS
Example 2. This filename is absolute because single quotation marks (') are used. The compiler attempts to open data set COMIC/BOOK.OLDIES.K and fails because it is not a valid data set name. A library search is not performed when filename is in absolute form. SEARCH is ignored.
#include <'COMIC/BOOK.OLDIES.K'> COMIC/BOOK.OLDIES.K
Example 3.
SEARCH(LIB1.*,LIB2.+,LIB3) #include "sys/abc/xx"
  • first opt in SEARCH SEQUENTIAL FILE = userid.LIB1.XX
  • second opt in SEARCH PDS = userid.LIB2.SYS.ABC(XX)
  • third opt in SEARCH PDS = userid.LIB3(XX)
Example 4.
SEARCH(LIB1.*,LIB2.+,LIB3) #include "Sys/ABC/xx.x"
  • first opt in SEARCH SEQUENTIAL FILE = userid.LIB1.XX.X
  • second opt in SEARCH PDS = userid.LIB2.SYS.ABC.X(XX)
  • third opt in SEARCH PDS = userid.LIB3(XX)
Example 5.
SEARCH(LIB1.*,LIB2.+,LIB3) #include <sys/name_1>
  • first opt in SEARCH SEQUENTIAL FILE = userid.LIB1.NAME@1
  • second opt in SEARCH PDS = userid.LIB2.SYS(NAME@1)
  • third opt in SEARCH PDS = userid.LIB3(NAME@1)
Example 6.
SEARCH(LIB1.*,LIB2.+,LIB3) #include <Name2/App1.App2.H>
  • first opt in SEARCH SEQUENTIAL FILE = userid.LIB1.APP1.APP2.H
  • second opt in SEARCH PDS = userid.LIB2.NAME2.APP2.H(APP1)
  • third opt in SEARCH PDS = userid.LIB3(APP1)
Example 7. The PDS member named YEAREND of the library associated with the ddname PLANLIB is used. A library search is not performed when filename in the #include directive is in absolute form (ddname is used). SEARCH is ignored.
#include <dd:planlib(YEAREND)> DD:PLANLIB(YEAREND)