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
Create Cloud to on Premise HTTP as shown below - After that Give a access path to /sap and sub paths
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.
The modified CPI integration is as follows. The configuration of Sender IDOC adapter is the same as described in part1 - We had a request response and Receiver before the email and connect them with IDOC adapter and configure them. We can shift the Content Modifier to be placed after the Request Response
as shown below.
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/