on 2023 Aug 02 8:00 AM
Hi,
We're building a Fiori app prototype in S/4HANA Cloud on stack ABAP environment which can be used to post supplier invoice via API below:
Overview | Supplier Invoice | SAP Business Accelerator Hub
The prototype is to demonstrate Fiori app capability to consume API services from the same S/4HANA Cloud system.
In our program we are using class cl_web_http_client_manager to instantiate the HTTP client in ABAP environment as shown below:
The problem with this code is that we need to put in the username and password in the program as shown in the code from line 107 - 108. Without this the program will not be able to call the API from the same system.
Is there better alternative which we can opt for to consume the API without having the need of putting in the logon credential in the program? Otherwise, is it possible to obtain the user id and password by reading the communication user data in S/4HANA Cloud via CDS view or other class/method approach?
We've configured the corresponding communication arrangement in the system as shown below:
We've also tried using Business Object Interface but it does not work either.
In the behaviour definition, we implemented an action as shown below:
Code below is the implementation:
The app fails right away when it executes the MODIFY ENTITIES statement. Below is the error message we captured from S/4HANA Cloud:
Is there any prerequisite that we need to be aware of for using Business Object Interface in S/4HANA Cloud?
Thanks.
Hi Kah Choon Simon Yong,
please follow Developing External Service Consumption (Outbound Communication): create a communication scenario in ADT, and then configure a communication system and arrangement for the scenario.
DATA(lo_destination) = cl_http_destination_provider=>create_by_comm_arrangement(
comm_scenario = '<SCENARIO ID>'
service_id = '<OUTBOUND SERVICE ID>'
comm_system_id = system_id ).
The credentials will be stored safely in the communication system.
The concept is explained here: Communication Management
Best regards
Kai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Gheorghe-Valer,
I apologize: I was too fast and did not read the entire question thoroughly enough, and I was caught by the question "Is there better alternative ... without having the need of putting in the logon credential in the program." So I was focusing on the question where to store user name and password in case of remote connectivity. I did not realize that the actual requirement is to call an API within the same system. In that case, the recommended approach is using the corresponding business object interface, of course. I will add another answer.
Best regards
Kai
User | Count |
---|---|
99 | |
8 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.