Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WBRIDGE and version 1.0.1

...

The E2E RESTifier provides a REST interface. The supported content type for results and requests is JSON (application/json).

Execute BAPI function

Code Block
languagejs
GET /sap/:functionName?parameter1=value1[&...][&callback=clientCallback]
POST /sap/:functionName?[callback=clientCallback]

...

ParameterDescription
functionNameBAPI function name. Slash (/) must be encoded as tilde (~).
parameter1BAPI function parameters with value. The parameters names and types can be explored with /sap/:functionName/metadata.
callbackJSON-P callback

Example for executing a BAPI

The BAPI function is called with GET.

...

Code Block
languagetext
curl -X POST -H "Content-Type: application/json" -d '{"PARTNERNUMBER":"0000008889"}' 'http://localhost:3000/sap/ZGETCUSTOMERDETAILS'

Response

Code Block
languagejs
{
  "result": {
    "CITY": "SPRINGFIELD  07081",
    "COUNTRY": "US",
    "DISTRICT": "UNION",
    "HOUSENUMBERSTREET": "12 BROADWAY",
    "NAME": "John Taylor",
    "POSTALCODE": "07081",
    "PARTNERNUMBER": "0000008889"
  },
  "self_url": "http://localhost:3000/sap/ZGETCUSTOMERDETAILS?PARTNERNUMBER=0000008889"
}

...

Code Block
languagetext
curl -X POST -H "Content-Type: application/json" -d '{"PARTNERNUMBER":"0000008889"}' 'http://localhost:3000/sap/ZGETCUSTOMERDETAILS?~noclean=whitespace,empty-values'

Exception

If you call a RFC function instead of a BAPI, an exception on the SAP server can happen. In this case you get HTTP status 502 and the following response:

...

Code Block
{
  "error": 502,
  "message": " Number:000",
  "rfcErrorInfo": {
    "code": 5,
    "group": 1,
    "key": "DIV_BY_ZERO",
    "abapMsgType": "",
    "abapMsgNumber": "000"
  },
  "self_url": "http://sap.e2e.ch/sap/Z_TEST_EXCEPTION"
}

Get BAPI function signature 

Code Block
languagejs
GET /sap/:functionName/metadata

...

PropertyJavaScript TypeDescription
titleStringName of the object or property.
typeStringJavaScript type.
lengthNumberLength of a simple type or structure.
descriptionStringDescription of parameters from SAP. Can be empty.
sapTypeStringNative SAP type.
sapDirectionStringInput or output parameter. RFC_IMPORT | RFC_EXPORT | RFC_CHANGING | RFC_TABLES
sapTypeNameStringName of a structure or name of a structure of a table.
dbTableStringName of the SAP database table
dbTableFieldStringField of the SAP database table
labelStringShort description

Example for getting metadata

Get description of BAPI function STFC_STRING.

...

Code Block
languagejs
{
  "error": null,
  "metadata": {
    "title": "Signature of SAP RFC function ZGETCUSTOMERDETAILS",
    "type": "object",
    "properties": {
      "PARTNERNUMBER": {
        "type": "string",
        "length": "10",
        "sapType": "RFCTYPE_CHAR",
        "description": "Character Field Length = 10",
        "sapDirection": "RFC_IMPORT",
        "label": "Character Field Length = 10",
        "title": "PARTNERNUMBER"
      }
    }
  },
  "functionName": "ZGETCUSTOMERDETAILS",
  "exec_url": "http://localhost:3000/sap/ZGETCUSTOMERDETAILS{?callback}",
  "self_url": "http://localhost:3000/sap/ZGETCUSTOMERDETAILS/metadata"
}

Find BAPI function /sap/functions

Code Block
languagejs
GET /sap/functions/:searchTerms[/:pageNumber]&[description=1]

...

PropertyJavaScript TypeDescription
FUNCNAMEStringFunction name
GROUPNAMEStringGroup name
APPLStringApplication to which function module is assigned
HOSTStringRemote host (CPIC)
STEXTStringFunction description

Example /sap/functions

Search for customer and get the first 25 functions.

...

Code Block
jstext
{
  "functionList": [
    {
      "FUNCNAME": "BAPI_CUSTOMEREXPINV_GETLIST",
      "GROUPNAME": "2144",
      "APPL": "W",
      "HOST": "",
      "STEXT": "Agency Business: BAPI - Determine Detailed Data for Expenses Settlement"
    },
// ... cut of functions
    {
      "FUNCNAME": "BAPI_SERVICENOTIFICAT_GETLIST",
      "GROUPNAME": "IWWW",
      "APPL": "I",
      "HOST": "",
      "STEXT": "Select service notifications according to customer or contact person"
    }
  ],
  "error": null,
  "self_url": "http://localhost:3000/sap/functions/customer%20get/2?description=1",
  "next_url": "http://localhost:3000/sap/functions/customer%20get/3?description=1",
  "previous_url": "http://localhost:3000/sap/functions/customer%20get/1?description=1",
  "first_url": "http://localhost:3000/sap/functions/customer%20get?description=1",
  "last_url": "http://localhost:3000/sap/functions/customer%20get/5?description=1"
}

Migrating from version 0.3.2 and below

Change in endpoints:

Old endpointNew endpoint
/sap/exec/:functionName/sap/:functionName
/sap/metadata/:functionName/sap/:functionName/metadata
/sap/findFunction/:searchTerms/sap/functions/:searchTerms

...