Previous Page | Next Page

Using the RFC Macros and Macro Variables

Performing Batch Operations

You can use batch operations to automate processes; for example, you can use them for overnight operations or to simplify connections for end users.

To open the connection for a batch operation, use the following:

%r3connb(profile=profile-name, libref=SAS-libref, function=OPEN);

profile-name

specifies the name of the profile that is used to save the information in the Logon to R/3 window.

SAS-libref

specifies the SAS library where the profile was saved. If this parameter is not specified, the profile is looked for in the SAS libraries WORK, SASUSER, and R3LIB (in that order).

function=OPEN

opens the connection.

To close the connection, use the following:

%r3connb(profile=profile-name, libref=SAS-libref, function=CLOSE);

or

%r3connb(id=connection-id, function=CLOSE); 

profile-name

specifies the name of the profile that is used to save the information in the Logon to R/3 window.

SAS-libref

specifies the SAS library where the profile was saved. If this parameter is not specified, the profile is looked for in the SAS libraries WORK, SASUSER, and R3LIB (in that order).

function=CLOSE

disconnects from the SAP System.

connection_id

specifies the connection ID.


Source Parameter

Previous versions of the SAS/ACCESS Interface to R/3 included a source parameter in the batch connection. For backward compatibility, use of the source parameter as described below is still supported, although not recommended.

Submit the following macro in SAS to set up the connection for batch:

%r3connb (source = libref.catalog.entry.SOURCE );

If operating in batch mode, issue the following command in SAS to disconnect before exiting:

%r3connb (source = libref.catalog.entry.SOURCE, function = close);


Passwords

In batch processing, all parameters to log on to an SAP System are generally stored in permanent SAS catalog entries. If you do not want to store all parameters (particularly the user ID, password, and client), use the following SAS code to prompt the user for this information. In this scenario, all other connection information--the function module name, the gateway host, or the gateway service--has to be entered in the Application Setup window when you create the SAS DATA step view.

/*----------------------------------------------------*/
/* This SAS program demonstrates how to prompt a user */ 
/* for the SAP user ID, password, client, and         */
/* language information.                              */
/* The remote processing is enclosed in comments.     */           
/*----------------------------------------------------*/

*--- reset password ---*;
   %let pwd=;

*--- set the message text ---*;
   %let message=Please enter the SAP logon parameter;

*--- prompt the user for the parameters ---*;
   %macro secure;
   %global usr pwd cli lng;
   %window R3 columns=80 rows=15
     #2  @5 message 50 protect=yes
     #4  @5 "User    : " usr 10 required=yes
     #6  @5 "Password: " pwd 10 display=no required=yes
     #8  @5 "Client   : " cli 3 required=yes
     #10 @5 "Language : " lng 1 required=yes;
   %display R3;
   %mend secure;
 
   %secure;

/* === for remote processing =======================  */

*--- macro to pass macro variables to ---*;
*--- a remote SAS session ---*;
   %macro syslput(macvar,macval,remote=);
   %let str=%str(rsubmit &remote ;);
   %nrstr(%let) %str(&macvar = &macval ; endrsubmit;);
   &str ;
   %mend syslput;

*--- pass macro variables to the remote SAS session ---*;
   %syslput(usr,&usr);
   %syslput(pwd,&pwd);
   %syslput(cli,&cli);
   %syslput(lng,&lng);

*--- submit the code to the remote SAS session ---*;
   rsubmit;

=== end of remote processing =========================== */

*--- a temporary catalog entry for the connection ---*;
*--- parameters ---*;
   %let source=work.r3conn.conn1.source;

*--- the connection id ---*;
*--- ATTENTION: This has to be the same connection ID ---*;
*--- as the one that was used to create the views.    ---*;
   %let cconn=conn1;

*--- the host/port where the SAS RFC server program ---*;
*--- is running, used only in z/OS operating environment ---*;
   %let tcphost=cafe7.eur.sas.com;
   %let port=6999;

*--- set the host parameter ---*;
   %let hst=hostname;

*--- save the parameters to the temporary catalog ---*;
*--- entry ---*;
   proc display c=sapr3.sr3dbi.savconnb.scl;
   run;

*--- connect to the SAP System ---*;
   %r3connb(source=&source);

*--- use the Data Step view you have created with the ---*;
*--- SAS/ACCESS Interface to R/3 ---*;

*--- close the connection to the SAP System ---*;
   %r3connb(source=&source, function=close);

/* === for remote processing 
==================================
   endrsubmit;

=== end of remote processing 

================================ */
*--- end of sample program ---*;

Previous Page | Next Page | Top of Page