IDOC TO BTP CPI from ECC on Save of Flight Booking Part 3

In my earlier blogs I have described in detail the configuration Steps that are required for sending and receiving IDOCs . To recap this.



In keeping with my philosophy of using on systems that are available  to all and can be be tried by anyone without ERP access. I am using  ABAP Trail version that can be installed by anyone and BTP trial integration suite.

The blogs in PART1 and PART2 describe how to send IDOC from ECC to CPI(BTP) and receive.  To test this we have to manually populate IDOC in WE19 and test it.

In this blog PART 3 I wanted to demonstrate in practical use case that most people might require.  On any tcode we would like to invoke CPI  iflow on SAVE button.  This will help to add value to the customer and improve efficiency of business processing.  As we are using ABAP trail version we have are forced  to use SFLIGHT example.  The Transaction BC_GLOBAL_SBOOK_CREA will allow to create a new Flight Booking.  When we Click on the Save button we would like to generate a IDOC that can be used to Send to CPI which will then send the booking information by email to a travel agent.

To achieve this I have created a n FM which will be called from an implicit enhancement in the ABAP include BC_GLOBAL_SBOOK_CREATEF01 in FORM SAVE.

A) FM to send to IDOC for Flight Booking

FUNCTION zflbooking_idoc_create.
*”*”Local Interface:
DATAlt_idoc_data  TYPE STANDARD TABLE OF edidd,
ls_idoc_data  TYPE edidd,
ls_idoc_ctr   LIKE edidc,
lt_comm_idocs TYPE STANDARD TABLE OF edidc,
ls_bookdata   TYPE e1bpsbonew,
ls_seg1       TYPE e1sbo_cre,
ls_seg3       TYPE e1bpparex.

MOVE in_idoctp TO ls_idoc_ctridoctp.
MOVE in_mestyp TO ls_idoc_ctrmestyp.
MOVE in_rcvpor TO ls_idoc_ctrrcvpor.
MOVE in_rcvprt TO ls_idoc_ctrrcvprt.
MOVE in_rcvprn TO ls_idoc_ctrrcvprn.

ls_idoc_datasegnam ‘E1SBO_CRE’.
MOVE ls_seg1 TO  ls_idoc_datasdata.
APPEND ls_idoc_data TO lt_idoc_data.

ls_idoc_datasegnam ‘E1BPSBONEW’.

ls_bookdataairlineid in_sbookcarrid.
ls_bookdataconnectid in_sbookconnid.
ls_bookdataflightdate in_sbookfldate.
ls_bookdatacustomerid in_sbookcustomid.
ls_bookdataclass in_sbookclass.
ls_bookdatacounter in_sbookcounter.
ls_bookdataagencynum in_sbookagencynum.
ls_bookdatapassname in_sbookpassname.
ls_bookdatapassform in_sbookpassform.
ls_bookdatapassbirth in_sbookpassbirth.
MOVE ls_bookdata TO  ls_idoc_datasdata.
APPEND ls_idoc_data TO lt_idoc_data.

ls_idoc_datasegnam ‘E1BPPAREX’.
MOVE ls_seg3 TO  ls_idoc_datasdata.
APPEND ls_idoc_data TO lt_idoc_data.

master_idoc_control            ls_idoc_ctr
communication_idoc_control     lt_comm_idocs
master_idoc_data               lt_idoc_data
error_in_idoc_control          1
error_writing_idoc_status      2
error_in_idoc_data             3
sending_logical_system_unknown 4
OTHERS                         5.

IF sysubrc <> 0.
MESSAGE ID symsgid TYPE symsgty NUMBER symsgno
WITH symsgv1 symsgv2 symsgv3 symsgv4.
e_ret sysubrc.
wait ‘X’.
e_ret 0.



B) Implicit Enhancement to SAVE button click

C) Transaction BC_GLOBAL_SBOOK_CREA to create flight booking

When you click on the SAVE button the implicit enhancement will be called which will call the FM to create the IDOC and we will get a message on the screen

As this a trail system NPL my configuration does allow automatic sending of IDOC – The IDOC created in step C will be in status 30 ready for dispatch.

D) in Tcode WE02 locate the idoc created

E) use WE19 to send the idoc using standard outbound processing

When you send this you will get a message IDoc sent by HTTP in XML format..

Due to the configuration described in PART1 and PART2 the BTP CPI iflow will be triggered and email will be sent to the configured email id.

F) verify the email about the booking information

A word of caution.  As Part1 and Part2 were created in BTP about a year back,  I had to recreate my subaccount and activate integration suite. I had exported and saved my integration packages earlier which were imported into the new CPI instance and redeploy.  When this happens we have to all urls in SM59 to point to the new integration. and update the credentials.  Last but the not the least we should also import the Certificates and update STRUST.