SAP (Collection)

Know the Capsules available in this Collection.

Micaella Mazoni avatar
Written by Micaella Mazoni
Updated over a week ago

IMPORTANT: This documentation has been discontinued. Read the updated SAP documentation on our new documentation portal.

The SAP Collection Capsules were all designed to abstract calls to SAP, encapsulating the capacity to call remote functions (RFC) to the SAP system.

To use the RFC Capsules, it’s necessary to configure them with the parameters required by SAP (as SID, LANGUAGE, CLIENT ID, etc.) and define the parameters expected by SAP.

After the Capsule execution, it’s possible to control the message flow, analyze the success and failure cases and handle the response message to the JSON format to ease the data work in the pipeline flow.

What’s SAP?

SAP is one of the world leaders in software development for business process management, which creates solutions to make information flow among companies easier. Click here to have more information.

Preconditions

1) Establish VPN

The SAP Capsules are always used for the information flow dispatch to SAP. Therefore, a Site-to-Site VPN in the SAP setup must be defined.

2) 33XX Port and SAP Hostname Release

The SAP standard connection is established. Given that, 33XX ports (XX is the SAP instance number) must be released inside the VPN. Without this action the SAP information can’t be accessed. Besides, the connection demands the SAP hostname, easily accessed via SMGW transaction.

Example:

If the Instance Number is 20, then the port to be released in the VPN tunnel will be 3320.

3) SAP Gui Information

As it happens for SAP GUI, the Capsules need the connection information to enable the flow. See below the necessary information:

  • Instance Number and System Id

  • Logon Language and Client ID (Principal)

4) Credentials

Both user and SAP access password must be registered in the Digibee Platform. A Basic type account must be used.

SAP Capsules

  • SAP RFC - Connectivity test

This Capsule enables a connectivity test to be run without the functions and SAP parameters to be known. The Capsule abstracts the call to a standard RFC (RFC_READ_TABLE) with the minimum parameters already defined.

If there’s an error in the response after the Capsule execution, it’s necessary to check if the preconditions have been met. But if the response is equal to “success” : true, you can move on with the integration and call other SAP functions.

  • SAP RFC - Connector (JSON Input)

Generic Capsule, used for any operation with the SAP remote functions. It’s possible to read table data and registers in a more complete way, include new registers (Suppliers, Clients, Addresses, etc.) and also update registers.

For being a generic Capsule, all the SAP native functions are available and the custom ABAP functions in the SAP environment can also be executed. For example, RFC for invoice inclusion, with the taxes calculation.

Have a better understanding of how to work with such dynamism and what the relation with the RFC parameters is:

1. Import Parameters Attributes

Are the input parameters (optional) that must be filled in the function call. The field doesn’t support structural parameters.

{
"BUSINESSPARTNER": "",
"VALID_DATE": ""
}

2. Object Params

Are the input parameters (optional) that must be filled in the function call. Structural parameters are supported.

{
"OBJ1": {
"ATTR1": "V1"
},
"OBJ2": {
"ATTR2": "V2",
"ATTR3": "V3"
}
}

3. Table and Fields

Model to send parameters in table format. To send more than one item to the same table, add a new JSON object inside the array, as displayed in the example below:

[
{
"TABLE1": [{
"ATTR1": "VALUE1",
"ATTR2": "VALUE2"
},
{
"ATTR1": "VALUE1",
"ATTR2": "VALUE2"
}],
"TABLE2": [{
"ATTR1": "VALUE1",
"ATTR2": "VALUE2"
}]
}
]

IMPORTANT: according to the SAP good practices, it’s recommended for table parameters not to be sent as Import Parameters.

4. Getting to know the parameters of a RFC function

Check how it’s possible to identify the expected parameters by a RFC to fill the SAP RFC Capsule (JSON Input).

Example

  • SAP RFC standard, native in the SAP environment

  • Function: BAPI_BUPA_ADDRESS_CHANGE

Firstly, access the SE37 transaction (Function Builder) in your SAP:

Fill the function name (BAPI_BUPA_ADDRESS_CHANGE) and press F8 on your keyboard.

All the parameters expected by RFC and its respective types are displayed in your SAP GUI Business Client.

As shown in the example above, the Import Parameters Attributes type fields are: BUSINESSPARTNER and ADDRESSGUID (they’re not structural parameters).

For the other fields, click on the icon displayed in the “Value” column. Afterwards, access the structure editor through the Shift + F7 keyboard shortcut.

In the image above, ADDRESDATA_X represents the object name. The other fields are the object attributes.

Now see a table-type structural parameter, through which it’s possible to send a list and its respective attribute one by one.

Based on the parameter examples shown above, take a look at a JSON example that simulates the format expected by the SAP Capsule.

Import Parameters Attributes

{
"BUSINESSPARTNER": "0000000003"
}

Object Params

{
"ADDRESSDATA": {
"STANDARDADDRESS": "X",
"C_O_NAME": "",
"CITY": "Barueri",
"POSTL_COD1": "19970000",
"STREET": "Rua adriano augusto teste",
"HOUSE_NO": "1",
"COUNTRY": "BR",
"REGION": "SP",
"LANGU": "PT",
"VALIDFROMDATE": {{FORMATDATE(NOW(), "timestamp", "yyyy-MM-dd", null , "GMT-3") }},
"VALIDTODATE": "2999-12-31"
},
"ADDRESSDATA_X": {
"STANDARDADDRESS": "X",
"C_O_NAME": "X",
"POSTL_COD1": "X",
"STREET": "X",
"HOUSE_NO": "X",
"COUNTRY": "X",
"REGION": "X",
"LANGU": "X"
}
}

Table and Fields

{
"BAPIADTEL": [
{
"COUNTRY": "",
"TELEPHONE": "",
"TEL_NO": ""
},
{
"COUNTRY": "",
"TELEPHONE": "",
"TEL_NO": ""
}
],
"BAPIADFAX": [
{
"COUNTRY": "",
"FAX": ""
}
]
}

  • SAP RFC - Read Nota Fiscal

Capsule designed to make data inquiries of any invoices in SAP by using the DOCNUM field.

The RFC used for the inquiry is BAPI_J_1B_NF_GETDETAIL. To obtain the details of an invoice, fill the “DOCNUM” field value, inside Import Parameters.

Reminder: use Double Braces expressions to dynamically provide the value. See an example:

{             "attributes":{             " DOCNUM": {{message.docnum}}  }}

IMPORTANT: the "SAP RFC - Read Nota Fiscal" Capsule was specially designed to attend Brazilian market needs.

  • SAP RFC - Read Table

Capsule designed to make inquiries directly on SAP tables. Inside the standard parameters that exist in the “Preconditions” item, these stand out:

1. TABLE: name of the table for data inquiry.

2. Skip & Limit: parameters to control the inquiry pagination and limit the amount of returned registers. That way, the inquiries are made in blocks and the process becomes more efficient.

3. FIELDS: fields to be returned in the inquiry. It’s mandatory to inform at least one field to start the inquiry.

To identify which fields exist in the SAP table, use the SE11 () transaction. Example for the KNA1 table:

4. Options Filters: optional parameter, enables the specification of additional data for the SAP table inquiry. The parameter is commonly used to define the data cut, which means, to reduce the information scope and avoid the full table reading.

See some examples of filter options:

MATNR IN (10000,1000001,1000002,100003,100004)

ERDAT = '19990101'

BUKRS EQ '{{ message.company_code_sap }}'

IMPORTANT: to identify the suggested filter for your inquiry, check the SAP Table fields. The SE37 transaction allows inquiry tests to be run through RFC (READ_TABLE) and the definition of the parameters suitable for the inquiry.

Did this answer your question?