Free cookie consent management tool by TermsFeed Invoke SAP BAPI Smart Service (a!sapInvokeWithCommit)
Invoke SAP BAPI Smart Service

Overview

The Invoke SAP BAPI Smart Service allows designers to safely invoke BAPIs with side effects in process. See Functions and Side Effects for more information.

The two main benefits of using this smart service are:

  1. The ability to make unattended write calls to SAP.
  2. The ability to process return values from the BAPI. Return values allow you to verify that the invocation was successful.

For making BAPI calls to SAP servers outside of a process (for example, on an interface), see:

Properties

  • Category: Integrations & APIs

  • Icon: Invokek SAP BAPI

  • Assignment Options: Unattended/Attended

Configuration options

This section contains tab configuration details specific to this smart service. For more information about common configurations see the Process Node Properties page.

Data tab

Node inputs

Input Data Type Description Required Multiple
Scs External System Key Text The key from the Third Party Credentials admin console page that corresponds to the set of credentials that should be used to authenticate. Y N
Use Per User Credentials Boolean If true the credentials set in the Third-Party Credentials settings page by the current user running the expression will be used. If false the site-wide credential values will be used. N N
Hostname Text The application server host of the SAP server (ASHOST). The value can be an IP address, a fully-qualified domain name, or SAP's router string format. For example, "/H/sap_router/W/password/H/app_host/S/service_port". Y N
Clientnumber Text The SAP client number. Y N
System Number Text The SAP system number. Y N
Bapi Text The name of the SAP BAPI to invoke. Y N
Import Parameters Any Type The import parameters to send to the BAPI function, given as a dictionary. The dictionary fields are the import parameter names, and the values are the parameter values to send. Y N
Table Parameters Any Type The table parameters to send to the BAPI function, given as a dictionary. The dictionary values can also be given as dictionaries, allowing for the requisite table structure to be defined. Y N
Connection Properties Any Type The connection properties to use when creating the connection to the SAP instance, given as a dictionary. The dictionary fields are the camel-cased names of the properties with '.'s removed, and the values are the properties values to use. N N
Commit Transaction Boolean Flag used to execute a standard BAPI Transaction Commit. Set to true (the default) to execute the commit. Set to false when implementing a BAPI with a built in commit. N N

Node outputs

Output Data Type Description
Success Boolean A boolean set to true if the call was successful or false if it was unsuccessful
Result Any Type If success was true, a dictionary or list of dictionaries containing the data returned by the BAPI, otherwise, null
Error Any Type If success was false, a dictionary with the 'title' field and a 'message' field, otherwise null. The dictionary's fields contain the title and message of the error, respectively.

Because the response from a SAP server instance is a dictionary or list of dictionaries, the result output must be stored into custom data type process variable or the data field of a DataSubset process variable using a!dataSubset(). If saving the values into a DataSubset, you will need to view the values from the "Variables" tab of the process details dialog.

Once you understand the SAP return value's structure, you can access and manipulate the values in a custom output. For example, the BAPI return value may not map directly to your data types and may require some manipulation. Imagine the BAPI returns a value similar to this:

1
2
3
4
5
6
{
  Customers: {
    {id: 1, name: "Alliance Marketing", industry: "Marketing"},
    {id: 2, name: "Global Firm", industry: "Insurance"
  }
}

If you have a Customer data type and therefore want only the values contained in the "Customers" field, you could create a custom output that indexes the result of the BAPI call and saves it to a List of Customer process variable: index(ac!result, "Customers", {}).

a!sapInvokeWithCommit()

The Invoke SAP BAPI Smart Service is available as a smart service function that can be executed inside a saveInto on a Interface Component or as part of a Web API.

Syntax

a!sapInvokeWithCommit( scsExternalSystemKey, usePerUserCredentials, hostname, clientNumber, systemNumber, bapi, importParameters, tableParameters, connectionProperties, commitTransaction, onSuccess, onError )

Parameters

Keyword Type Description

scsExternalSystemKey

Text

The authentication credentials key from the Third Party Credentials admin console page.

usePerUserCredentials

Boolean

Determines if the current user’s credentials are used instead of system-wide credentials. Default is false.

hostname

Text

The hostname of the SAP server.

clientNumber

Text

The SAP client number used to access the system.

systemNumber

Text

The system number of the SAP application server.

bapi

Text

The name of the SAP BAPI function to invoke.

importParameters

Any Type

The import parameters to send to the BAPI function, given as a dictionary.

tableParameters

Any Type

The table parameters to send to the BAPI function, given as a dictionary.

connectionProperties

Dictionary

The connection properties to use when creating the connection to the SAP instance, given as a dictionary. The dictionary fields are the camel-cased names of the properties with ’.’s removed, and the values are the properties values to use.

commitTransaction

Boolean

Flag indicating if a commit transaction should be automatically executed at the end.

onSuccess

Any Type

A list of saves or an HTTP response to execute after the smart service executes successfully. Created with a!save() or a!httpResponse(). When configuring this input, the fv!result function variable (Any Type) is available to specify a dictionary or list of dictionaries by the SAP server. For more information, see Function Variables.

onError

Any Type

A list of saves or an HTTP response to execute when the smart service does not execute successfully. Created with a!save() or a!httpResponse(). When configuring this input, the fv!errorTitle function variable (Text) is available to specify the error title, and the fv!errorMessage function variable (Text) is available to specify the error message. For more information, see Function Variables.

Connection properties

The table below lists the dictionary keys and their associated connection property.

Dictionary Key SAP Connection Property Description
jcoClientClient jco.client.client SAP client
jcoClientUser jco.client.user Logon user
jcoClientAlias_user jco.client.alias_user Alias user name
jcoClientPasswd jco.client.passwd Logon password
jcoClientLang jco.client.lang Logon language
jcoClientSysnr jco.client.sysnr SAP system number
jcoClientAshost jco.client.ashost SAP application server
jcoClientMshost jco.client.mshost SAP message server
jcoClientGwhost jco.client.gwhost Gateway host
jcoClientGwserv jco.client.gwserv Gateway service
jcoClientR3name jco.client.r3name R/3 name
jcoClientGroup jco.client.group Group of SAP application servers
jcoClientTpname jco.client.tpname Program ID of external server program
jcoClientTphost jco.client.tphost Host of external server program
jcoClientType jco.client.type Type of remote host 2 = R/2, 3 = R/3, E = External
jcoClientTrace jco.client.trace Enable/disable RFC trace (0 or 1)
jcoClientCodepage jco.client.codepage Initial codepage in SAP notation
jcoClientabap_debug jco.client.abap_debug Enable ABAP debugging 0 or 1
jcoClientUse_sapgui jco.client.use_sapgui Use remote SAP graphical user interface (0/1/2)
jcoClientGetsso2 jco.client.getsso2 Get/Don't get a SSO ticket after logon (1 or 0)
jcoClientMysapsso2 jco.client.mysapsso2 Use the specified SAP Cookie Version 2 as logon ticket
jcoClientX509cert jco.client.x509cert Use the specified X509 certificate as logon ticket
jcoClientLcheck jco.client.lcheck Enable/Disable logon check at open time, 1 (enable) or 0 (disable)
jcoClientGrt_data jco.client.grt_data Additional data for GUI
jcoClientUse_guihost jco.client.use_guihost Host to which to redirect the remote GUI
jcoClientUse_guiserv jco.client.use_guiserv Service to which to redirect of the remote GUI
jcoClientUse_guiprogid jco.client.use_guiprogid Program ID of the server which starts the remote GUI
jcoClient.Snc_mode jco.client.snc_mode Secure network connection (SNC) mode, 0 (off) or 1 (on)
jcoClientSnc_partnername jco.client.snc_partnername SNC partner, e.g. p:CN=R3, O=XYZ-INC, C=EN
jcoClientSnc_qop jco.client.snc_qop SNC level of security, 1 to 9
jcoClientSnc_myname jco.client.snc_myname SNC name. Overrides default SNC partner
jcoClientSnc_lib jco.client.snc_lib Path to library which provides SNC service
jcoClientDest jco.client.dest R/2 destination
jcoClientSaplogon_id jco.client.saplogon_id String defined for SAPLOGON on 32-bit Windows
jcoClientExtiddata jco.client.extiddata Data for external authentication (PAS)
jcoClientExtidtype jco.client.extidtype Type of external authentication (PAS)
jcoClientIdle_timeout jco.client.idle_timeout Idle timeout (in seconds) for the connection after which it will be closed by R/3.
Only positive values are allowed.
jcoClientDsr jco.client.dsr Enable/Disable dsr support (0 or 1)

Best Practices

Example Interface Expression

In this example, the BAPI_ACC_GL_POSTING_POST is called to create an accounting document on a SAP server from sales data in the Appian system. This BAPI requires the commit flag to be set to true().

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
=a!localVariables(
  local!sapPostResult,
  a!formLayout(
    label: "Account Posting",
    instructions: "BAPI_ACC_GL_POSTING_POST is a standard SAP function module that performs Accounting: General G/L Account Posting functionality. This is available within standard R/3 SAP systems depending on version and release level.",
    contents: {
      a!textField(
        label: "Result",
        value: local!sapPostResult,
        readOnly: true()
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Post",
          style: "SOLID",
          saveInto: a!sapInvokeWithCommit(
            scsExternalSystemKey: cons!SAP_SCS_KEY,
            usePerUserCredentials: false(),
            hostname: cons!SAP_HOSTNAME,
            clientNumber: cons!SAP_CLIENT_NUMBER,
            systemNumber: cons!SAP_SYSTEM_NUMBER,
            bapi: "BAPI_ACC_GL_POSTING_POST",
            importParameters:{
              DOCUMENTHEADER:{
                OBJ_TYPE:"BKPFF",
                OBJ_KEY:"1",
                OBJ_SYS:"T90CLNT090",
                USERNAME:"SAPUSER",
                HEADER_TXT:"BAPI TEST",
                COMP_CODE:"3000",
                DOC_DATE:date(2016, 11, 02),
                FIS_PERIOD:"11"
              }
            },
            tableParameters:{
              ACCOUNTGL:{
                {
                  ITEMNO_ACC:"0000000003",
                  GL_ACCOUNT:"474210",
                  COMP_CODE:"3000",
                  PSTNG_DATE:date(2016, 11, 02),
                  DOC_TYPE:"SA",
                  FISC_YEAR:"2016",
                  FIS_PERIOD:"11",
                },
                {
                  ITEMNO_ACC:"0000000002",
                  GL_ACCOUNT:"113100",
                  COMP_CODE:"3000",
                  PSTNG_DATE:date(2016, 11, 02),
                  DOC_TYPE:"SA",
                  FISC_YEAR:"2016",
                  FIS_PERIOD:"11"
                }
              },
              CURRENCYAMOUNT:{
                {
                  ITEMNO_ACC:"0000000003",
                  CURRENCY:"USD",
                  AMT_DOCCUR:"5000",
                  EXCH_RATE_V:"0"
                },
                {
                 ITEMNO_ACC:"0000000002",
                 CURRENCY:"USD",
                 AMT_DOCCUR:"-5000",
                 EXCH_RATE_V:"0"
                }
              }
            },
            commitTransaction: true(),
            onSuccess: {
              a!save(
                local!sapPostResult,
                fv!result
              )
            },
            onError: {
              a!save(
                local!sapPostResult,
                fv!errorTitle
              )
            }
          ),
          submit: true
        )
      }
    )
  )
)

Feature compatibility

The table below lists this smart service function's compatibility with various features in Appian.
Feature Compatibility Note
Portals Partially compatible

Can be used with Appian Portals if it is connected using an integration and web API.

Offline Mobile Partially compatible

Can be used with offline mobile if it is loaded at the top of the form.

Sync-Time Custom Record Fields Incompatible
Real-Time Custom Record Fields Incompatible

Custom record fields that evaluate in real time must be configured using one or more Custom Field functions.

Process Reports Incompatible

Cannot be used to configure a process report.

Process Events Incompatible

Cannot be used to configure a process event node, such as a start event or timer event.

Invoke SAP BAPI Smart Service

FEEDBACK