Triggering SAP code from Looply
You can instruct your Looply workflow to make an HTTP request to SAP by using the HTTP Request (SAP) step. While you can make a request to any SAP endpoint, the ABAP Looply Add-On provides two endpoints with hook points to call your own custom code and these will be discussed here.
POST Data to SAP
Set-up on Looply
Configure your step as follows:
SAP Profile
Here you may Use the dropdown to select any of your pre-configured SAP Profiles that you have created and integrated with Looply.
Often however you may want the workflow to send the request to the system in your landscape that it was triggered from, instead of maintaining a different workflow for your development, quality and production systems. You can do this by toggling the Bind profile dynamically switch and binding the System ID and Client ID fields with the respective fields in your payload. When Looply workflows are triggered by the /LOOPLY/CORE=>TRIGGER_WF method, these fields are added to the payload automatically.
Service Path
Enter the following path: /sap/opu/odata/looply/service_srv/
Note: If you have included a / at the end of the Host URL field in your SAP integration do not include it at the start of the service path as the values of the two fields are concatenated when the request is made.
Entity Name
Enter the following value: DataInSet
Request Method
Select POST
Body
You may add the following fields to the request body:
With the exception of field scenario_id, the rest of the fields are optional and can be omitted. In the above screenshot, the first four fields are bound to fields in the payload (see section Triggering a Looply Workflow for more details) and will be used to determine the Z-function to be called once the request reaches the back-end. data contains additional data we want to send to the back-end and may include fields from the payload, information about a button the end-user clicked on, data entered into fields on the card etc. In this example we have used a function step which outputs a json string containing all these fields.
Configuration in your SAP system
In your SAP system, create a new function module by copying sample function /LOOPLY/SAMPLE_POST. The function has the following signature:
IM_DATA
STRING
Data passed in from Looply workflow. (corresponds to request body field data above)
EX_SUBRC
SYSUBRC
Subrc code passed back to the workflow
EX_MESS
BAPIRET2
Message to be logged in the SAP log and passed back to the workflow
EX_DATA
STRING
Data passed back to Looply
TIP: To convert an incoming json string to an internal table or structure you can use method /ui2/cl_json=>serialize. To convert an internal table or structure to a json string to be passed back to Looply you can use method /ui2/cl_json=>deserialize.
Next, make a configuration entry via the following IMG transaction: SPRO->General Application Functions->Looply->Process Determination Insert the values passed into the request body for fields Scenario, Scenario ID, Version, Step and the name of your newly created function module in field Function. You may leave fields Workflow ID and the non-key Version field blank. When the request reaches the back-end, the configuration table will be read based on the Scenario, Scenario ID, Version and Step fields and your function module will be called dynamically.
Download file from SAP
In certain scenarios, you may wish to include a button or a link to download a file/attachment from your sap system in a Microsoft Teams card. You can achieve this in the following way:
Example - Adaptive Card
Insert a Container to your card. (You can use any container type that that has a "Selection action" property like a ColumnSet or TableCells if you have multiple attachments)
If a gateway service endpoint which fetches the file already exists on your sap system you may use a url to that service. (Stelo users for example can include a url to Stelo service /STELO/APP_SERVER_SRV/AttContentSet to retrieve attachments in their payload. For example: https://<host>/sap/opu/odata/stelo/app_server_srv/AttContentSet('<attachment cms document>')/$value )
In other scenarios, an endpoint that fetches the file you want to download might not exist. In such cases you can use a url to the endpoint provided by the Looply ABAP add-on: https://<host>/sap/opu/odata/looply/service_srv/AttSet(scenario='<scenario>',scenario_id='<scenario_id>',version='<version>',step='<step>',data='<data used to get file>')/$value
Using a url with the above format will allow you to call your own Z-function to return a file. You can create such a Z-function by copying sample function /LOOPLY/SAMPLE_GET_FILE. The function has the following signature:
IM_DATA
STRING
String from 'data' url parameter
EX_SUBRC
SYSUBRC
Subrc code passed back to the workflow
EX_MESS
BAPIRET2
Message to be logged in the SAP log and passed back to the workflow
EX_XDATA
XSTRING
File data in XSTRING format
EX_MIME_TYPE
STRING
File Mimetype
EX_FILENAME
STRING
Filename
Next, make a configuration entry via the following IMG transaction: SPRO->General Application Functions->Looply->Process Determination Insert the values that match the url parameters for fields Scenario, Scenario ID, Version, Step and the name of your newly created function module in field Function. You may leave fields Workflow ID and the non-key Version field blank. When the request reaches the back-end, the configuration table will be read based on the Scenario, Scenario ID, Version and Step fields and your function module will be called dynamically.
Last updated