The APPLSYS Macro Library

Overview of the APPLSYS Macro Library

The data that is used by the macros is stored in tables in another macro library that you maintain as you add and delete libraries, servers, and application systems. This library is called the APPLSYS (an acronym for application system) macro library.
The tasks to customize macros are explained in the following sections.
See SAS/SHARE Macros for complete information about the syntax of the SAS/SHARE autocall macro library and how to use it.

Specifying the APPLSYS Macro Library

The default name of the APPLSYS macro library depends on the operating environment. Here are the default macro library names:
z/OS Specifics: SAS.SASSAML
UNIX Specifics: !sasroot/saspgm/sassaml
Windows Specifics: !SASROOT\SHARE\SASMACRO
Files in the APPLSYS macro library are called members, and they must have a .SAS extension.
To use the default library table, do not include the APPLSYS= argument in the SHRMACS macro. For example,
%shrmacs(user);
To specify an alternate library-alias table, include the APPLSYS= argument in the SHRMACS macro. For example,
%shrmacs(user, applsys=purchas);
It might be more convenient to allow different users or departments to maintain their own APPLSYS macro libraries. To use an alternate APPLSYS macro library instead of the default library, specify the SASSAML= argument in the SHRMACS macro.
The value for the SASSAML argument can be the operating environment-specific physical name of the alternate library or the string _DEFINED_, which indicates that the fileref SASSAML has already been assigned to the alternate library. For example:
%shrmacs(user,applsys=purchas,sassaml=library-path); 
%shrmacs(user,applsys=_DEFINED_);
Here are some operating environment-specific examples to specify an alternate APPLSYS macro library:
UNIX Specifics: %shrmacs(user,applsys,sassaml=/dept/mis/applsys);
Windows Specifics: %shrmacs(user,applsys,sassaml=c:\dept\mis\applsys);

Defining Server Aliases (SERVID)

Server aliases can help you do the following tasks:
  • use your existing SAS programs with new releases of SAS/SHARE without having to change them. This is accomplished by using the name of the existing SAS/SHARE server as an alias for the name of a SAS/SHARE server that is executing the new release of SAS/SHARE.
  • shift server traffic easily. When you begin using SAS/SHARE, you might create many aliases for a single server, with each alias used by only one or a small number of applications. As server use increases, you'll want to add a second server and move some of your applications to that server. You can do this by changing the entry in the SERVERID member to point to the new server for the applications that you want to move.
To define server aliases, create a member named SERVERID in the APPLSYS macro library. The member name must be SERVERID because the SHRMACS macro looks for that specific name.
Define a server alias in the SERVERID member by using the following syntax:
%SERVID(alias,server-ID);
The following code shows an example of a SERVERID member.
Server-Alias Table
/***************************************************/
/*                                                 */
/*  NAME: SERVERID                                 */
/*                                                 */
/*  SERVER ALIAS TABLE ENTRIES                     */
/*                                                 */
/*  This member defines aliases for server names.  */
/*  The entries in this member are loaded into     */
/*  the server-alias table by the SHRMACS macro.   */
/*  This server-alias table is used by the         */
/*  SERVERID macro to translate an alias to an     */
/*  actual server ID.                               */
/*                                                 */
/*  To add aliases to the table, specify each      */
/*  alias and its real server ID in a SERVID call  */
/*  at the end of this member.                     */
/*                                                 */
/***************************************************/
%servid(shr7,shrserv7)
%servid(share1,shrserv3)
%servid(pubserv,shrserv7)

Associating SAS Libraries with Server Aliases (SERVLIB)

Create a member in the APPLSYS macro library for each application system that is specified by the APPLSYS= argument in the SHRMACS macro. Doing this defines library-server pairs that a specific application will probably use. For example, you can specify an APPLSYS library named PURCH in the SHRMACS macro as follows:
%SHRMACS(user,APPLSYS=purch);
If you do this, you also create a member in the APPLSYS library of the same name (in this example, PURCH).
In a selected member, use the following syntax to specify the library and server name pairs.
%SERVLIB(SAS-library, server-name);
SAS-library is specific to the operating environment. server-name can be a server ID or its alias.
The following code contains a member named PURCH, which references operating environment-specific SAS library names.
Library-Alias Table
/**********************************************************************/
/*                                                                    */
/*  NAME: PURCH                                                       */
/*                                                                    */
/*  LIBRARY TABLE ENTRIES - SPECIFIC APPLICATION                      */
/*                                                                    */
/*  This member associates server names with libraries. The entries   */
/*     in this member are loaded into the library table if the        */
/*     SHRMACS macro is called by using the argument APPLSYS=APPLSAMP.*/
/*     If APPLSYS=APPLSAMP is specified, the entries can also be      */
/*     loaded by using a call to the LIBDEF.                          */
/*                                                                    */
/*  To add libraries to the definition table, add a SERVLIB call      */
/*    for each library at the end of this member. Specify the         */
/*    physical name for the library and the name of the server to be  */
/*    associated with the library. The name can be an alias or an     */
/*    actual server ID.                                                */
/*                                                                    */
/**********************************************************************/

%servlib(shrtest.appljan.lib1, testserv);                 # z/OS
%servlib(/shrtest/appljan/lib1, testserv);                # UNIX
%servlib(d:\shrtest\appljan\lib1, testserv);              # Windows
To add aliases to the table, use a SERVLIB call for each library-server pair.
Additionally, create a member in the APPLSYS macro library named DEFAULTS. This member can be empty but must be created to avoid having error messages generated from the SHRMACS macro.
The DEFAULTS member is used when the APPLSYS= argument is omitted in a call to the SHRMACS and LIBDEF macros. The syntax of the PURCH and the DEFAULTS members is identical.

Creating the Server Information Table (SERVINFO)

A server information table is created to store information about the servers at your site. You can use this information in a program, or you can display it. By default, the table contains the following information:
  • a default value for the RMTVIEW= option in the REMOTE engine's LIBNAME statement
  • a network node name that is represented in the two-level server name format: node.server-id.
You can use the server information table to store other attributes of the server, its users, or its administrators, such as server access passwords, PROC SERVER statement options, and the SAS release that the server runs under.
To add an entry to the server information table, use the SERVINFO macro as follows:
%SERVINFO (node.server-id, netnode=fully-qualified-node-name, RMTVIEW=NO);
Usually, the SERVINFO macro is used to cause the SERVERID macro to generate an alias for a node name that is not a valid SAS name. For example, you can specify the two-level server name and the netnode in the server information table as follows:
%servinfo (hp.shrserv,netnode=hp103.dom2.acme.com);
When you do this, the server SHRSERV runs on HP103.DOM2.ACME.COM.
In resolving an alias for HP.SHRSERV, the SERVERID macro generates the following:
%let hp=hp103.dom2.acme.com;

Customizing a Server Information Table

The following example shows how to customize your server information table to include the SAS software release number for the SAS/SHARE server. The tasks in this example do the following:
  • account for a new parameter in the SERVINFO macro
  • reformat the table's appearance
  • add the new information to the table
  • view the server information table with the LISTSRVI macro
The following eight steps show how to alter the server information table for display only.
  1. Add the new parameter SASREL= to the SERVINFO macro statement.
    %macro servinfo(servid,version=,rmtview=,netnode=,sasrel=);
  2. Add the new variable ISREL&SRVINUM to the %GLOBAL statement to account for the new parameter SASREL.
    %GLOBAL isrvr&srvinum irmtv&srvinum inode&srvinum isrel&srvinum;
  3. Because the table is implemented as sets of macro variables, assign the value &SASREL to the macro variable ISREL&SRVINUM.
    %LET isrel&srvinum = &sasrel;
  4. In the LISTSRVI macro, modify the line that prints the headers for the table.
    %put &pline RMTVIEW %shrrpt(-,3) 
       NETWORK NODE %shrrpt(-,20) RELEASE %shrrpt(-,3);
  5. You might want to change the %PUT statement in the LISTSRVI macro to extend the dashed line following the table to match the length of the modified header line.
    %put %shrrpt(-,78);
  6. Change the loop that prints the table so that it looks like this:
    %do i=1 %to &srvinum;
      %let pline=%shrrpt(&blank,3)   
         %shrfmt(&&isrvr&i,16);
      %let pline=&pline   
         %shrfmt(&&irmtv&i,11) 
         %shrfmt(&&inode&i,36);
      %let pline=&pline &&isrel&i;
      %put &pline;
    %end; 
  7. If you want to be able to access and use the information in the table for a macro or a program, you would have to use the SERVIIDX macro.
    %let i=%serviidx(&new_id);
    %if (&&isrel&i^=) %then
      %do;
       /* some use of &&isrel&i here */
      %end;
  8. After you have accounted for the new parameter and modified the format of the server information table, you can add entries to the table for all parameters.
    %servinfo(rmthost.share1,netnode=.acme.com,
      rmtview=no,sasrel=6.12);
    %servinfo(rmthost.share2,netnode=smith.acme.com,
      rmtview=yes,sasrel=7);
When you invoke the LISTSRVI macro, the server information table is displayed in the SAS log.
%listsrvi;
              SERVER INFORMATION TABLE
--- SERVERID --- RMTVIEW -- NETWORK NODE --- RELEASE
RMTHOST.SHARE1   NO        rmthost.acme.com   6.12
RMTHOST.SHARE2   YES       smith.acme.com     7  
----------------------------------------------------

Generating a LIBNAME Statement By Using the LIBDEF Macro

If your SAS application accesses a server library, use the LIBDEF macro instead of a LIBNAME statement. Use the syntax that follows.
Note: Before you invoke the LIBDEF macro, you must first invoke the SHRMACS macro.
%LIBDEF(libref,SAS-library-name) <,APPLSYS=app-sys-lib-tab>;
CAUTION:
Do not enclose the SAS library name in quotation marks. Using quotation marks will cause the generation of the LIBNAME statement to fail.
The LIBDEF macro generates a LIBNAME statement by searching the library table for the library name. Then it invokes the SERVERID macro to convert the server alias into a server ID. Here are some operating environment-specific examples for using the LIBDEF macro.
z/OS Specifics: %libdef(mylib,shrtest.appljan.lib1);
UNIX Specifics: %libdef(mylib/shrtest/appljan/lib1);
Windows Specifics: %libdef(mylib,d:\shrtest\appljan\lib1);
Each macro invocation defines the library to the libref MYLIB. You can define additional libraries without invoking the SHRMACS macro again.
If you want to use server aliases but you have not created the library- and server-name pairs in the APPLSYS macro library yet, you can use a LIBNAME statement and invoke the SERVERID macro in place of the SERVER= argument. For more information, see SAS/SHARE Macros.

Using APPLSYS= to Call the SHRMACS and LIBDEF Macros

You can specify the APPLSYS= argument in either the SHRMACS or the LIBDEF macro. The following example contains application excerpts that show how to access libraries from three applications systems (PURCH, MAINT, and FACIL) by using the APPLSYS= argument.
Operating Environment Information: For SAS-library, use the syntax convention that is appropriate for your operating environment.
Using the APPLSYS= Argument to Call the SHRMACS and LIBDEF Macros
/* Most libraries will come from purchasing appl sys.*/
%shrmacs(user,nomsg,applsys=purch);

/* Access purchase order library.*/
%libdef(polib,SAS-data-library1);
            .
            .
            .
            .
/* Access vendor service library from maintenance appl sys.*/
%libdef(vndsvc,SAS-data-library2,applsys=maint);
            .
            .
            .
            .
/* Access vendor account library from purchasing appl sys. */
/* (Note: It is not necessary to specify APPLSYS= for this */
/* application system because it was specified above.)     */
%libdef(vndacct,SAS-data-library3);

/* Access vendor contact library from maintenance appl sys.*/
/* (Note: It is not necessary to specify APPLSYS= for this */
/* application system because it was specified above.)     */
%libdef(vndcon,SAS-data-library4);
            .
            .
            .
            .
/* Access inventory library from facilities appl sys.      */
%libdef(invlib,SAS-data-library5,applsys=facil);

/* Access invoice library from purchasing appl sys.        */
%libdef(invoice,SAS-data-library6);