Storing and Accessing an External Function

In this section:

Internal functions are built in and do not require additional work to access. External functions are stored in load libraries from which they must be retrieved. The way these external functions are accessed is determined by your platform. These techniques may not have to be used every time a function is accessed. Access to a load library may be set only once at the time of installation.

You can also access private user-written subroutines. If you have a private collection of subroutines (that is, you created your own or use customized subroutines), do not store them in the function library. Store them separately to avoid overwriting them whenever your site installs a new release. For more information on creating a subroutine, see Creating a Subroutine.


Top of page

x
Storing and Accessing a Function on z/OS

How to:

On z/OS, load libraries are partitioned data sets containing link-edited modules. These libraries are stored as EDALIB.LOAD or FUSELIB.LOAD. In addition, your site may have private subroutine collections stored in separate load libraries. If so, you must allocate those libraries.



x
Procedure: How to Allocate a Load Library in z/OS Batch

To use a function stored as a load library, allocate the load library to ddname USERLIB in your JCL or CLIST.

The search order is USERLIB, STEPLIB, JOBLIB, link pack area, and linklist.



Example: Allocating the Load Library BIGLIB.LOAD in z/OS Batch (JCL)
//USERLIB DD DISP=SHR,DSN=BIGLIB.LOAD


x
Procedure: How to Allocate a Load Library in TSO

Allocate the load library to ddname USERLIB using the ALLOCATE command. You can issue the ALLOCATE command:

If you are in a FOCUS session, you can also use the DYNAM ALLOCATE command.

If you are in a FOCUS session, you can also use the DYNAM ALLOCATE command.



x
Syntax: How to Allocate a Load Library
{MVS|TSO} ALLOCATE FILE(USERLIB) DSN(lib1 lib2 lib3 ...) SHR

or

DYNAM ALLOC FILE USERLIB DA lib SHR

where:

MVS|TSO

Is the prefix if you issue the ALLOCATE command from your application or include it in your PROFILE FOCEXEC.

USERLIB

Is the ddname to which you allocate a load library.

lib1 lib2 lib3...

Are the names of the load libraries, concatenated to ddname USERLIB.



Example: Allocating the FUSELIB.LOAD Load Library
TSO ALLOC FILE(USERLIB) DSN('MVS.FUSELIB.LOAD') SHR

or

DYNAM ALLOC FILE USERLIB DA MVS.FUSELIB.LOAD SHR 


Example: Concatenating a Load Library to USERLIB In TSO

Suppose a report request calls two functions: BENEFIT stored in library SUBLIB.LOAD, and EXCHANGE stored in library BIGLIB.LOAD. To concatenate the BIGLIB and SUBLIB load libraries in the allocation for ddname USERLIB, issue the following commands:

DYNAM ALLOC FILE USERLIB DA SUBLIB.LOAD SHR
DYNAM ALLOC FILE BIGLIB  DA BIGLIB.LOAD SHR
DYNAM CONCAT FILE USERLIB BIGLIB 

The load libraries are searched in the order in which they are specified in the ALLOCATE command.



Example: Concatenating a Load Library to STEPLIB in Batch (JCL)

Concatenate the load library to the ddname STEPLIB in your JCL:

//FOCUS EXEC PGM=FOCUS
//STEPLIB     DD DSN=FOCUS.FOCLIB.LOAD,DISP=SHR
//            DD DSN=FOCUS.FUSELIB.LOAD,DISP=SHR
                           .
                           .
                           .

Top of page

x
Storing and Accessing a Function on UNIX

No extra work is required.


Top of page

x
Storing and Accessing a Function on VM/CMS

In this section:

Reference:

On VM/CMS, supplied functions are stored as one of the following:

EXCHANGE TEXT

In addition to the preceding libraries and files, your site may have private collections of subroutines stored in separate libraries or text files.



x
Reference: Search Sequence on VM/CMS

The standard VM/CMS search sequence applies to functions:

  1. Load libraries, searched in the order that you specified them in the GLOBAL LOADLIB command.
  2. Text files, searched on attached disks in alphabetical order.
  3. Text libraries, searched in the order that you specified them in the GLOBAL TXTLIB command.


x
Searching a Function Library in VM/CMS

To search for a function stored in a load or text library, issue the CMS GLOBAL command. You can issue the GLOBAL command:

You must also specify a system library for a function written in a language such as COBOL or PL/I, and for a function that calls a system function. FUSELIB functions do not require any other system libraries.

If you issue two GLOBAL commands of the same type, the second command replaces the first. Once a library is opened (as a result of referencing one of its members), the library cannot be changed until you exit.

If you have a private subroutine collection, specify the function library or libraries in the GLOBAL command in addition to the FUSELIB library.

Note: FUSELIB functions now reside in FUSELIB LOADLIB (rather than in a TXTLIB). Issuing GLOBAL TXTLIB FUSELIB still works because the TXTLIB still exists. However, VM/CMS loads supplied functions from the LOADLIB before searching the TXTLIB.



x
Syntax: How to Search a Function Library
CMS GLOBAL {LOADLIB|TXTLIB} library1 library2 library3 ...

where:

CMS

Is required if you issue the GLOBAL command from a procedure.

LOADLIB

Indicates the library is a load library.

TXTLIB

Indicates the library is a text library.

library1 library2 library3...

Are the names of the libraries containing the functions. The maximum number of libraries is 63.



x
Syntax: How to List Function Libraries Specified by the GLOBAL Command
CMS QUERY {LOADLIB|TXTLIB}

where:

LOADLIB

Indicates the library is a load library.

TXTLIB

Indicates the library is a text library.



Example: Searching a Function Library

The following command, issued in the global profile, accesses the FUSELIB load library:

CMS GLOBAL LOADLIB FUSELIB


Example: Searching Multiple Function Libraries

The following command, issued in a procedure, accesses the SUBLIB and BIGLIB libraries:

CMS GLOBAL TXTLIB SUBLIB BIGLIB


x
Adding or Deleting a Function Library

The GLOBAL library list automatically contains the FUSELIB function library. To add or delete private subroutine libraries, use two CMS EXECs, FOCADLIB or FOCDELIB.

Before you add LOADLIBs to the GLOBAL library list, the existing list is saved. Then the required and optional LOADLIBs are added in front of any libraries you may have specified. After a request, the prior GLOBAL environment is restored.

Prior entries can be retained in the GLOBAL library list and new entries added by using the FOCADLIB EXEC. To delete entries while maintaining others in the list, use the FOCDELIB EXEC. For both FOCADLIB and FOCDELIB, the output from the EXEC is the return code of the GLOBAL command. FOCADLIB and FOCDELIB must be found in the VM/CMS search sequence (A–Z).



x
Syntax: How to Add or Delete a Function Library
CMS EX {FOCADLIB|FOCDELIB} libtype lib1 [lib2 lib3...] [(QUIET ]

where:

FOCADLIB

Adds libraries to the beginning of the GLOBAL library list.

FOCDELIB

Deletes libraries from the GLOBAL library list.

libtype

Is the library type, for example, LOADLIB or TXTLIB.

lib1 lib2 lib3...

Are the names of the libraries to be added or deleted.

QUIET

Suppresses messages from the GLOBAL command. The open parenthesis is required.


Information Builders