Technical Articles
Send IDOC from Cloud Platform Integration to ECC (inbound Part2)
Most of the blogs that deal with Cloud Platform Integration API describe in detail integration with SAP- There are not a lot of blogs that deal with CPI API trial version with Cloud Connector and on premise ECC Systems. As everybody can get access to cloud trial version(CPI), API management, Trail ABAP system and cloud connector I decided to choose this environment for all my blogs on CPI.
In my earlier blog https://blogs.sap.com/2021/01/14/send-idoc-from-abap-trail-version-npl-to-cloud-platform-integration/ which is part 1 of an end to end ECC CPI sending IDOC from ECC to CPI. In this blog which is Part 2 I describe the inbound process in which CPI sends IDOC to ECC and then we process the IDOC to create a Travel Booking for Customer which anybody can try out.
In Part1 I described the necessary settings to RZ11, STRUST and SM59 type G RFC Connection, IDOC Port in WE21 and Partner Profile in WE20. We will use the same PORT and Partner profile and extend to add the inbound Configuration. For this demo scenario I send the IDOC from the ECC To CPI and another CPI integration will send the IDOC to the same ECC. This could very easily be another S4HANA system or non SAP System via the cloud connector. Again I send the result to gmail which has to be configured as described in https://blogs.sap.com/2020/12/06/cloud-platform-integration-gmail-configuration-and-integration-flow/
We have to create security material for gmail user/password and on premise ECC username and Password and deploy it. Generally I like to do things from Scratch and also develop end to end integrations across technologies. At the end of this blog I would have implemented an End to End IDOC scenario from scratch. Again we have choose the IDOC message type FLIGHTBOOKING_CREATEFROMDAT to create a customer Travel booking. Here are the steps in detail.
- Create the ABAP RFC Function call can process the IDOC to and Post the travel record Here the ABAP code for the FM
FUNCTION ZIDOC_SBOOK_CREATEFROMDAT.
*”———————————————————————-
*”*”Local Interface:
*” IMPORTING
*” VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*” VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*” EXPORTING
*” VALUE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT
*” VALUE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-APPL_VAR
*” VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
*” VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS
*” TABLES
*” IDOC_CONTRL STRUCTURE EDIDC
*” IDOC_DATA STRUCTURE EDIDD
*” IDOC_STATUS STRUCTURE BDIDOCSTAT
*” RETURN_VARIABLES STRUCTURE BDWFRETVAR
*” SERIALIZATION_INFO STRUCTURE BDI_SER
*” EXCEPTIONS
*” WRONG_FUNCTION_CALLED
*”———————————————————————-
*———————————————————————-*
* this function module is generated *
* never change it manually, please! 29.10.2015 *
*———————————————————————-*
INCLUDE mbdconwf.
DATA: reserve_only LIKE bapisbodat–reserved,
booking_data LIKE bapisbonew,
test_run LIKE bapisflaux–testrun.
DATA: airlineid LIKE bapisbokey–airlineid,
bookingnumber LIKE bapisbokey–bookingid,
ticket_price LIKE bapisbopri.
DATA: extension_in TYPE STANDARD TABLE OF bapiparex,
return TYPE STANDARD TABLE OF bapiret2.
DATA: lT_EDIDD type standard table of EDIDD,
ls_edidd like line of lt_edidd.
DATA : w_zshstuseg LIKE zstudentsseg1.
DATA : t_zstudents LIKE zstudents OCCURS 0 WITH HEADER LINE.
workflow_result = c_wf_result_ok.
LOOP AT idoc_contrl.
IF idoc_contrl–mestyp NE ‘FLIGHTBOOKING_CREATEFROMDAT’.
RAISE wrong_function_called.
ENDIF.
LOOP AT IDOC_DATA WHERE DOCNUM = IDOC_CONTRL–DOCNUM.
APPEND IDOC_DATA TO lT_EDIDD.
ENDLOOP.
LOOP AT lT_EDIDD INTO IDOC_DATA.
CASE IDOC_DATA–SEGNAM.
WHEN ‘E1BPSBONEW’.
booking_data = idoc_data–sdata.
ENDCASE.
ENDLOOP.
CALL FUNCTION ‘BAPI_FLBOOKING_CREATEFROMDATA’
EXPORTING
booking_data = booking_data
IMPORTING
airlineid = airlineid
bookingnumber = bookingnumber
ticket_price = ticket_price
TABLES
extension_in = extension_in
return = return.
.
READ TABLE return WITH KEY type = ‘E’ into Data(lv_type).
IF sy–subrc <> 0.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
wait = ‘X’.
idoc_status–docnum = idoc_contrl–docnum.
idoc_status–status = ’53’.
idoc_status–msgty = ‘I’.
idoc_status–msgid = ‘YM’.
idoc_status–msgno = ‘004’.
idoc_status–msgv1 = bookingnumber.
APPEND idoc_status.
CLEAR idoc_status.
ELSE.
idoc_status–docnum = idoc_contrl–docnum.
idoc_status–status = ’51’.
idoc_status–msgty = ‘E’.
idoc_status–msgid = ‘YM’.
idoc_status–msgno = ‘005’.
idoc_status–msgv1 = lv_type–message.
APPEND idoc_status.
CLEAR idoc_status.
workflow_result = c_wf_result_error.
return_variables–wf_param = ‘Error_Idocs’.
return_variables–doc_number = idoc_contrl–docnum.
APPEND return_variables.
CLEAR return_variables.
ENDIF.
ENDLOOP.
ENDFUNCTION.
2. In Transaction BD51 create a new entry and give the FM created in the previous step
BD51 – Create New Entry and Assign FM
3. In Transaction WE57 Create a new Entry Choose the FM and Direction as Inbound
WE57 New Entry FM and Direction inbound
4) We now have to create Process code. For this we go transaction WE42 – Give a name to the process code and choose Processing by FM radio button and ALE Service Radio button as shown.. When you save you will be taken to a second screen – in the module section you have to choose the FM under consideration. These two images are shown below.
Click Save to Complete the settings for WE42.
5) In Part 1 we have already created Port and Partner Profile for outbound. We choose the Same Partner profile in WE20 and All inbound configuration as shown below below
Partner Profile inbound Configuration WE20
WE 20 Complete
6) In the Cloud Platform integration we are using the Same Integration which we will modify before we do that we can test the inbound configuration in WE19 and Choose Via Message type and enter FLIGHTBOOKING_CREATEFROMDAT for the message type and populate IDOC Segments as show below
WE19 Idoc Header
WE19 Data for IDOC
Having done this we choose inbound processing and enter the FM we created
If everything is OK you should get a message IDOC has been created. We can go to WE02 and Check up that the IDOC is created and check the status. If there are errors you can take corrective actions.
Before we can go the Cloud Platform Integration there are things we need to ECC which are described below.
7) Go to transaction SICF and active the Service /default_host/sap/bc/srt/Idoc. T
8) Go to Transaction SRTIDOC and register the service we activated n the previous step as shown below
9) Here we use cloud connector to create connection to our cloud account. These are described in many blogs. Here are my settings
Create A Connection Cloud Connector Cloud Subaccount in Cloud Foundry Trial account
Now we have cloud connector url http://s4h2:8000 which we will use on CPI IDOC adapter so that ECC instance associated will be invoked by CPI to send the IDOC
9) Now we will modify the CPI integration created so that we will send receive the IDOC from ECC and send this back to ECC via the cloud connector and then we will post in ECC to create a travel record in SBOOK.
End to End IDOC CPI IFLOW
CPI IDOC settings inbound to ECC
The email settings are the same as described in Part1.
Save and Deploy the integration. Go to the Operations view and make sure that the integration has started.
10) in WE19 Send the IDOC as described in part1 and choose outbound processing to send the IDOC – When we do that IDOC sent to CPI and then by IDOC To ECC and then email is sent as configured in the mail adapter. These images are as shown below
Send Outbound IDOC as described in Part 1 outbound processing
CPI Operations View Success Message for integration
Email sent the CPI IFLOW
WE02 Check the IDOC Status with 64 ready to be consumed by the inbound processing
In Real life we will have batch job to pick up the idoc for processing but as this is not set up we will again use WE19 this time we will should the idoc sent by CPIC in status 64 and choose inbound processing
WE19 Inbound Processing Testing
Inbound IDOC processed
WE02 IDOC with Status message 53
Finally Check SE16 for Table SBOOK that new Entry has been created
A New Bookid has been created in table SBOOK by the inbound process
As this my personal computer having too many idocs can use up lot of memory – you can delete unnecessary IDOCs using the tcode WE11 or BD87/
Hi Ramesh,
thanks for all input.
from my POV the title "send IDOC from CPI to ECC" is misleading, as message not realy genereated from a Cloud send to CPI and also missing the following:
(SAP delives thousand of APIs and if not enough BDBG will do).
many thanks in advance for adressing the case "IDOC from CPI outbound to ECC" once more in a standard setup, if possible,
Best regards
Nikos
Nikolaos
Thanks for the feedback and comments.
I wanted to blog end-to-end IDOC CPI scenario. My setup is an ABAP trial system and CPI trial which everybody can download and try. In Part 1 of this series I send an IDOC to CPI and in Part2( this blog) I send the same IDOC from CPI to ECC. I had to resort to this scheme as I did not have access to other systems which is the case in real life.
The Comment below the WE19 figure was to go to WE02 to check the results of WE19.
ZIDOC_SBOOK_CREATEFROMDAT is the FM that is required - although it is outbound from CPI as far as ECC is concerned it is inbound. This FM is linked to the process code which in turn is configured for the inbound IDOC process as described in the blog.
If you want an outbound IDOC from CPI you have to read or get the IDOC file from the FTP server or HTTP and then process it.
Hope this clarifies
Best regards
Ramesh
Hi Ramesh,
I am Alex and I have to configure a SAP ECC 6.00 EHP 4 System to an CPI Cloud Connector. I do the things you descripe until point 8. The connection between CPI and SAP ECC should be HTTPS or do only HTTP work?
The connection between CPI und ECC with HTTPS is "Reachable".
I have registered the SRTIDOC, but when I do the "Test service" I get an HTTP500 error. It starts an HTTP in a browser.
I get an HTTP 500 or HTTP 401 error when I send an Idoc vom S4 over the CPI.
It will be very nice if you could give me some hints.
Regards Alex
Alex
Sorry for the delay in getting back to you. In my setup, I have my own ABAP developer edition and only HTTP is allowed as I don't have HTTPS. The screenshots show the exact steps I had to do to make this work. Check with Basis if you have HTTPS enabled in your system - Try to SICF and right-click any activated node to see the response in Browser.
Regarding SRTIDOC 500 error you have to talk to basis. In my system, I did not have any additional steps to make this work.
Best regards
Ramesh