Product Lifecycle Management Blogs by Members
Get insider knowledge about product lifecycle management software from SAP. Tap into insights and real-world experiences with community member blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
swaroop_anasane
Active Contributor
Hello Everyone,

Recently I learnt few things about SAP DM integration so thought of sharing what little I learnt.

This blog is about utilizing any third party API in SAP DM, to read data and post it against SFC using standard methods and SAP DM LCNC(Low-Code No-Code) options.

We have seen a few blogs around this in past but those were quite heavy and were using different technologies and tools. Here we would be checking this example without any external language knowledge or tool requirement. Let's talk about the pre-requisites first:

  1. Data collection group with parameters maintained for data collection at relevant Operation.

  2. Released order running on a POD with active SFC

  3.  External API to be used to capture data, in this case we would be using a simple weather API, URL example: https://api.open-meteo.com/v1/forecast?latitude=73.8567&longitude=18.5204&current=temperature_2m,win...


Having the system ready with above pre's, below are the steps that will guide you to complete this use case.

STEP 1: Creating a Destination in SAP DM tenant:

Go to accounts.hana.ondemand.com and open subaccount for your DM tenant. Create a destination of Type HTTP in SAP DM tenant, it should look like as shown below.


Destination created on DM Tenant for service API


Note: Here we are using "NoAuthentication" as it is not required for this open service, but you can use appropriate Authentiation depending on the service your are using. Please refer SAP DM help documentation for more on Authentication.

STEP 2: Create a webserver in SAP DM.

Open SAP DM and search for "Manage Web Server" app, click on create and provide name, description and URL ("https://api.open-meteo.com" in our case), click on save. Ref picture below:


Once webserver is created, you would see 4 tabs:

a. Server Details - Having basic server connection configuration

b. Consumed by - Showing which webserver is connected to this, it would initially show 0.

c. Destinations - Select the destination created in DM tenant here for weather api. "DM_WEATHER_SRV"

d. Services - Shows the service using this webserver, currently this section would also be blank.

STEP 3: Linking "DMC_Cloud" to the Webserver created in step 2,

Click on "DMC_Cloud" webserver from the list of web servers under "Manage Web Server", go to connection panel, click on "Create" and select DM_WEATHER_SRV (Note: this should be the name of web server, dont confuse it to Destination name as here we are using same name at both the places which need not be the case in usual scenario).

STEP 4: Create a Service Registry using "Manage Service Registry".

Open SAP DM and search for "Manage Service Registry" app, click on create under API Services tab and provide name, ID, existing group or new group name you are willing you create, and other details for HTTP type, REST protocol and GET method.

Provide the URL suffix that is the remaining part from API url between domain.com and parameters( "/v1/forecast" in our example).
Provide parameters in parameters panel by getting the parameter query string, select the web server from value helper and provide the one created in previous step. Check the "Availability" check box and save. Ref picture below.


Service registry for Weather API.


After this step, your DMC tenant can connect to external API(weather API in our case).

STEP 5: Create a production process design by going to Production Process Designer App in SAP DM. The production process should have start, end, a service call and a script task.

Before you can add web service call to production process, you need to add the service by clicking on "Select Services" button on the left panel, find the Web Server you created in STEP 2 and select the service under that webservice, picture below for ref.


Adding service to production process.


Create the production process as shown below:


Production process design frame


Input to Service call could be automatically included due to parameters maintained while creating service, though this can be modified and parameters can be passed. We are keeping it as it is for simplicity.

Under Script Task, create input/output parameters as input: srv_result (String), Output: srv_result (String), you don't have to assign any value here.

Also, map service response('Service_Weather#httpResponse') to input parameter.

Under script, add below code:

=========================

$output.temprature=JSON.parse($input.srv_result).current.temperature_2m;

=========================

This code reads temperature value from service response JSON and assigns it to output of the script task.

Map input of Log DC control as shown below:


Input parameter mapping for DC


It is obvious the hardcoded values here can be modified with input parameter linking for dynamic values. I have kept it like this for brevity.

No output parameter mapping is required as we can see results in POD directly. Click on "Save All" and "Quick Deploy". Test the production process by clicking on Debug--> Run, check the logs of the flow completing successfully.


DC Collection successfully completed.


Verification: Open Work Center POD, select SFC/Operation and go to data collection panel, you would see the data collected by this process.


DC Collection list on POD.


The above process describes integration and utilization of external web service in SAP DM with the use of Production Process Designer. The flow you created using Production Process Designer can then be linked to Automatic Triggers or POD actions there by using data from external APIs.

The blog grew long but hope this helps you understand the use case in a simple way!!

Do like the blog if you like it.

 

Nice time!

 

Best Regards,

Swaroop
2 Comments
yash_vijay
Explorer
0 Kudos
Hi Swaroop, i am following your blog, but facing an 401 error while trying to call the DM API.

Could you please help me this.

 




  • [Debug] Variable Service_Create_MaterialsResponseProtocol is created with value: null






  • [Debug]Variable Service_Create_MaterialsResponseStatusCode is created with value: 401






  • [Debug]Variable Service_Create_MaterialsResponseReason is created with value: Unauthorized






  • [Debug]Variable Service_Create_MaterialsResponseHeaders is created with value: cache-control: no-cache, no-store, max-age=0, must-revalidate content-length: 0 date: Fri, 10 Nov 2023 16:41:36 GMT expires: 0 pragma: no-cache set-cookie: JSESSIONID=D8739A49E0D548F1E401A0CCAF9F9175; Path=/; Secure; HttpOnly set-cookie: __VCAP_ID__=f3f38dc4-599e-48fe-7350-199f; Path=/; HttpOnly; Secure www-authenticate: Bearer x-content-type-options: nosniff x-correlationid: 33410c0a-2a23-4db7-410d-ef8d9337fb90 x-frame-options: DENY x-vcap-request-id: a97deea3-271a-4634-608c-cb33af9ed153 x-xss-protection: 0 strict-transport-security: max-age=31536000; includeSubDomains; preload;






  • [Debug]Variable Service_Create_MaterialsResponseBody is created with value: null







  • [Error]Indication Color 2



    Service task with java class com.sap.dm.fnd.processengine.fndext.activity.EnrichedHttpActivityBehaviorImpl threw exception HTTP401







  • [Error]Indication Color 2



    Variable FAILED_ACTIVITY_eaa8fceb-fe0d-4f3b-ab8e-2360570d6809_FailJobId is created with value: f9d45933-7fe7-11ee-be45-36859cbb3fad







  • [Error]Indication Color 2



    Variable FAILED_ACTIVITY_eaa8fceb-fe0d-4f3b-ab8e-2360570d6809_StatusCode is created with value: HTTP401







  • [Error]Indication Color 2



    Variable FAILED_ACTIVITY_eaa8fceb-fe0d-4f3b-ab8e-2360570d6809_ErrorMessage is created with value: HTTP401



swaroop_anasane
Active Contributor
0 Kudos

Hi Yash,

Is your destination reachable from BTP?