Skip to main content

RFC Calls

This section outlines the details of the mapping parameter used to invoke SAP function modules through RFC calls. It describes how to map the Import and Export parameters of an SAP function module to content repository properties and how to handle errors or success cases.

warning

To use RFC calls to invoke any SAP function module, make sure to have the SAP NetWeaver RFC SDK installed and mapped into the running container.

tip

It is only possible to call SAP function modules that are marked as Remote Enabled in their definition.

Parameter Overview

The main parameter to specify the RFC mapping.

ParameterMandatoryTypeDescription
typeYesstringThe connection type to be used for invoking SAP. Since this chapter describes RFC calls, use the value rfc.
sapFunctionsYesObjectThe object containing the property assignments such as SAP function module name and its import parameter, export parameter and mapping to the content repository properties.
Refer below to section Parameter sapFunctions.
successYesObjectHandle the success case of the SAP return.
Refer below to section Parameter success.
failureYesObjectHandle the error case of the SAP return.
Refer below to section Parameter failure.

Parameter sapFunctions

This parameter, a subset of the mapping parameter, includes the assignments of all properties from the repository that must be mapped to the import parameters of the SAP function module. It also manages the return mapping, which involves determining which properties from the result should be mapped to specific properties of the document in the repository.

ParameterMandatoryTypeDescription
nameYesstringThe name of the remote-enabled SAP function module that should be invoked. The sapFunctions parameter allows you to invoke multiple SAP function modules.
importParamsYesContent PropertyHandles the mapping of all import parameters of the SAP function module.
Refer below to section Parameter importParams.
exportParamsYesContent PropertyHandles the mapping of all import parameters of the SAP function module.
Refer below to section Parameter exportParams.

Parameter importParams

This parameter defines the mapping between repository properties and import parameter of the SAP Function Module using a list of Content Properties. In case of importParams, the source is a property from the repository and the target is a name of an import parameter of the SAP function module.
The example below is split by repository, as each repository requires its own syntax to access its properties.

Invoke the SAP function module ARCHIV_GET_CONNECTIONS and set the import parameter ARCHIV_ID to the value of the Nuxeo property archiveId, and ARC_DOC_ID to the value of docId from the current document. Assumption: both Nuxeo properties are part of the fct_sap facet.

tip

If you need to store a value in a property belonging to a facet not yet applied to the current document, enter the facet name followed by a colon and the property name. This action adds the facet and stores the value.For example, archiveId is a property on the fct_sap facet that is not yet available on the document. In this case, the correct syntax for the source is fct_sap:archiveId, as shown below.

Example
mapping:
type: rfc
sapFunctions:
- name: ARCHIV_GET_CONNECTIONS
importParams:
- target: ARCHIV_ID
source: fct_sap:archiveId
- target: ARC_DOC_ID
source: fct_sap:docId

Parameter exportParams

This parameter defines the mapping between repository properties and export parameters of the SAP Function Module using a list of Content Properties. In case of exportParams, the source is a name of an export parameter from the SAP function module return and the target is a property in the repository.

tip

If the export parameter of the SAP function module is a table or structure, access the required property within it using JSON syntax.

The example below retrieves the result from the SAP function module ARCHIV_GET_CONNECTIONS and sets the values OBJECT_ID and SAP_OBJECT to the content repository. Since SAP returns the required values within a table called CONNECTIONS, it must be accessed by JSON syntax as followed: CONNECTIONS.0.OBJECT_ID.

warning

Be sure to always specify the facet name to which the desired property belongs.
Syntax must be facetName:propertyName for target.

Example
mapping:
type: rfc
sapFunctions:
- name: ARCHIV_GET_CONNECTIONS
importParams:
...
exportParams:
- source: CONNECTIONS.0.OBJECT_ID
target: fct_sapInfo:sapObjectId
- source: CONNECTIONS.0.SAP_OBJECT
target: fct_sapInfo:sapObject

Content Property

Specification of the available content properties used for importParams, exportParams, success and failure above.

ParameterMandatoryTypeDefaultDescription
sourceYesStringFor exportParams it must be a list property in the YAML syntax (requires a hyphen as prefix). For importParams, depending on the constant or script setting below, the value can either be a hardcoded or parsed/formatted by Javascript.
targetYesStringSame explanation as above - but reversed: For importParams it must be a list property in the YAML syntax (requires a hyphen as prefix) and for exportParams the constant or script has effect.
constantNoBooleanfalseSet true to return a constant value in source (for importParams, success or failure) or target (for exportParams, success or failure). Set false to return a value based on the return of the SAP function module.
scriptNoStringModify the value using JavaScript functionality before sending or after retrieving it, for instance, by parsing (for exportParams) or formatting (for importParams) the value.
Refer to section Using script parameter below.
metricLabelNoStringAvailable only for exportParams! Set the label that can be evaluated by Prometheus. It must contain only lowercase letters and cannot contain whitespaces. Refer to the Metrics chapter in the installation section.

Using script parameter

Use the script parameter to modify the value using JavaScript functionality. This is beneficial when the value requires parsing and formatting to meet a specific format. Handling Date objects and Boolean values are examples of situations where this parameter can be effectively utilized.

The following properties will be passed to the script, allowing them to be accessed within it.

danger

Do not override the properties below!

ParameterDescription
loggerThe logger instance. Can be used to log various activities within the script.
propsThe properties of the current document being processed by the function module.
nowThe current time.
nowUtcThe current time in UTC.
ParseFunction to parse the value to a date object.
Example: Parse("2006-01-02T15:04:05Z07:00", value). Refer to Reference Template section.
FormatFunction to format the value to match the target format.
Example: Format("20060102", value). Refer to Reference Template section.
contentThe content of the currently processed property in the configuration includes target, content, and, if present, script and constant.
valueThe value from the target parameter when used in the context of importParams, or from the source parameter in the context of exportParams.
Example 1: Mapping a Date to SAP.

In SAP ABAP, the type for date fields is DATS, which is designed for calendar dates in the format YYYYMMDD. This means that the value from the storage system must often be parsed and formatted before it's possible to pass it to SAP.

Nuxeo example which maps the dc:created value to the AR_DATE import parameter via the script parameter using Parse() and Format() from the table above.

Example
...
sapFunctions:
- name: ARCHIV_CONNECTION_INSERT
importParams:
- target: AR_DATE
source: dc:created
script: |
var d = Parse("2006-01-02T15:04:05Z07:00", value);
Format("20060102", d);
...
Example 2: Mapping to send a Boolean value to SAP.

In SAP ABAP, the concept of a Boolean data type does not exist. Instead, ABAP uses integer types or character types to represent boolean values. Typically, a single character type CHAR(1) is used, with 'X' representing true and a space ' ' representing false.

Nuxeo example to pass a Boolean value as a string, where true = X and false = empty, to the import parameter LATE of structure DOCUMENT_ENTRY:

Example
...
sapFunctions:
- name: ARCHIV_PROCESS_RFCINPUT
importParams:
- target: DOCUMENT_ENTRY.LATE
source: sapStartWorkflow:sapLateArchiving
script: 'value === true ? "X" : ""'
...

Handling Results in Success or Error Cases

To handle the result of the SAP function module call, the success and failure parameters are available. For example, in the case of success, it can be used to establish an exclusion criterion that prevents subsequent task runs from reprocessing the same document. In the case of error, it can store a detailed error message from SAP (if provided).

tip

Always use two properties in the content model of the connected storage system to handle results for both success and failure cases. Use one of the properties to store a status value, such as Success or Connected to SAP and the other property to store any additional detailed message.

Parameter success

This property can be utilized to manage the return of the SAP function module call in case it was successful. For instance, it can be employed to establish an exclusion criterion that prevents subsequent task runs from reprocessing the same document. The generic example below sets the value of the existing property cmProp_TaskStatus in the content model to Success and the value of property cmProp_TaskMessage to No Error. Because both values are fixed, you must add constant: true (refer the section above on Content Property).

Example
success:
- source: 'Success'
constant: true
target: 'cmProp_TaskStatus'
- source: 'No Error'
constant: true
target: 'cmProp_TaskMessage'

Parameter failure

Similar to the success parameter mentioned above, but it is used to handle any errors returned by the SAP function module. The example below sets the value of the existing property cmProp_TaskStatus in the content model to Error and the value of property cmProp_TaskMessage to the error message provided by the return of the SAP NWRFC SDK.

Example
failure:
- source: 'Error'
constant: true
target: 'cmProp_TaskStatus'
- source: ErrorInfo.Message // See 'RfcError Specification' -> 'Reference Path' below.
constant: false
target: 'cmProp_TaskMessage'

RfcError Specification

In case of any error, the SAP NWRFC SDK returns a structure with properteries defined as followed. You can access each of the properties by specifying the Reference Path in property source.

ParameterReference PathDescription
MessageErrorInfo.MessageThis is the general error message describing what went wrong.
CodeErrorInfo.CodeA unique identifier for the error type, often numeric or alphanumeric, e.g. ECONN001.
KeyErrorInfo.KeyA key that uniquely identifies the error, typically used for grouping similar types of errors.
AbapMsgClassErrorInfo.AbapMsgClassIdentifies the class of the message in ABAP which groups messages that share a context, e.g. 00 (General Messages)
AbapMsgTypeErrorInfo.AbapMsgTypeSpecifies the type of ABAP message, indicating its nature, e.g., error, warning, success, e.g. E (Error), A or X.
AbapMsgNumberErrorInfo.AbapMsgNumberThe specific number of the ABAP message within its class, identifying the exact message, e.g. 001, 344.
AbapMsgV1ErrorInfo.AbapMsgV1The first variable part of the ABAP message that can be inserted dynamically into the message text to provide specific details, corresponds to SY-MSGV1.
AbapMsgV2ErrorInfo.AbapMsgV2The second variable part of the ABAP message, used similarly to AbapMsgV1 for dynamic content insertion. Corresponds to SY-MSGV2.
AbapMsgV3ErrorInfo.AbapMsgV3The third variable component of the ABAP message, further detailing the message as needed. Corresponds to SY-MSGV3.
AbapMsgV4ErrorInfo.AbapMsgV4The fourth and typically final variable component of the ABAP message, completing the dynamic information required to understand the context or specifics of the issue. Corresponds to SY-MSGV4.