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.
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 * *———————————————————————-*
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.
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