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, user ID, password, and
client—use the following SAS code to prompt the user for this
information. In this scenario, you must enter all other connection
information—the function module name, the gateway host, or
the gateway service—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 ---*;