Tip: How to Detect SAP Server Side Scripting Settings

To automize the SAP GUI for Windows it is necessary to configure the client and the server side. To query that configuration at runtime of an automation workflow on client side you can use the GUI Info for SAP activity, which is available on the UiPath Marketplace. On server side it is necessary to open manually the transaction code RZ11 and so on and so forth. Here now a solution with this also the server sided information can be queried at runtime.

To read the profile parameters the remote enabled function module SAPTUNE_PROFILE_PARAMETER is used. Only the name of the profile parameter has to be passed and the value is returned. The code is very easy to understand. An array of strings is defined with the desired profile parameters. In a loop for each profile parameter the RFC is invoked and the return value is evaluated via a switch statement. A result is returned according to the required default values.

SettingsCorrect = true;

RfcConfigParameters cfgParams = new RfcConfigParameters();
cfgParams.Add("NAME", "GetSAPGUIScriptParams");
cfgParams.Add("ASHOST", ASHost);
cfgParams.Add("CLIENT", Client);
cfgParams.Add("USER", User);
String strPassword = new System.Net.NetworkCredential(string.Empty, Password).Password;
cfgParams.Add("PASSWD", strPassword);

RfcDestination destination = 
  RfcDestinationManager.GetDestination(cfgParams);

IRfcFunction rfcFunction = 
  destination.Repository.CreateFunction("SAPTUNE_PROFILE_PARAMETER");

//-SAP GUI Scripting Profile Parameters-
string[] Params = {
  "sapgui/user_scripting",
  "sapgui/user_scripting_disable_recording",
  "sapgui/user_scripting_force_notification",
  "sapgui/user_scripting_per_user",
  "sapgui/user_scripting_set_readonly"
};

foreach(string Param in Params) {

  rfcFunction.SetValue("NAME", Param);
  rfcFunction.Invoke(destination);
  string Value = rfcFunction.GetString("VALUE");

  switch(Param) {

    case "sapgui/user_scripting" :
      if(Value != "TRUE") {
        SettingsCorrect = false;
        WrongSetting += "sapgui/user_scripting" + Environment.NewLine;
      }
      break;

    case "sapgui/user_scripting_disable_recording" :
      if(Value != "FALSE") {
        SettingsCorrect = false;
        WrongSetting += "sapgui/user_scripting_disable_recording"
          + Environment.NewLine;
      }
      break;

    case "sapgui/user_scripting_force_notification" :
      if(Value != "FALSE") {
        SettingsCorrect = false;
        WrongSetting += "sapgui/user_scripting_force_notification"
          + Environment.NewLine;
      }
      break;

    case "sapgui/user_scripting_per_user" :
      if(Value != "FALSE") {
        SettingsCorrect = false;
        WrongSetting += "sapgui/user_scripting_per_user"
          + Environment.NewLine;
      }
      break;

    case "sapgui/user_scripting_set_readonly" :
      if(Value != "FALSE") {
        SettingsCorrect = false;
        WrongSetting += "sapgui/user_scripting_set_readonly"
          + Environment.NewLine;
      }
      break;

  }

}

Here is an exemplary use.

The variable SettingsCorrect is set to true if all settings meet the expectations.

image

GetSAPGUIScriptingParameters.xaml (8.7 KB)

This approach closes the circle. This makes it possible to check completely, in an automation workflow at runtime, whether all prerequisites for executing SAP GUI scripting are met. If this is not the case, it can be reacted with explanatory messages and this error can be quickly corrected.

1 Like

HI @StefanSchnell

Good overview and easy of use. Thanks!

Let me suggest one more improvement.

Would it be possible to incorporate one more check for SAP authorisation?

I have seen a lot of cases, when the server side settings were OK, but missing authorization was an issue.

Best regards, Lev

1 Like

@LevKushnir

Hello Lev,
thank you very much for your post.
Hmmm, interesting perspective and requirement, I will take a look at it.
Best regards
Stefan