Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
vodela
Active Participant
4,519
In my earlier blogs I have described in detail the configuration Steps that are required for sending and receiving IDOCs . To recap this.

PARt1 https://blogs.sap.com/2021/01/14/send-idoc-from-abap-trail-version-npl-to-cloud-platform-integration...

PART2  https://blogs.sap.com/2021/01/17/send-idoc-from-cloud-platform-integration-to-ecc-inbound-part2/ 

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:
*"  IMPORTING
*"     REFERENCE(IN_IDOCTP) TYPE  EDIDC-IDOCTP
*"     REFERENCE(IN_MESTYP) TYPE  EDIDC-MESTYP
*"     REFERENCE(IN_RCVPOR) TYPE  EDIDC-RCVPOR
*"     REFERENCE(IN_RCVPRT) TYPE  EDIDC-RCVPRT
*"     REFERENCE(IN_RCVPRN) TYPE  EDIDC-RCVPRN
*"     REFERENCE(IN_SBOOK) TYPE  SBOOK
*"  EXPORTING
*"     REFERENCE(E_RET) TYPE  SY-SUBRC
*"----------------------------------------------------------------------
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_ctr-idoctp.
MOVE in_mestyp TO ls_idoc_ctr-mestyp.
MOVE in_rcvpor TO ls_idoc_ctr-rcvpor.
MOVE in_rcvprt TO ls_idoc_ctr-rcvprt.
MOVE in_rcvprn TO ls_idoc_ctr-rcvprn.

ls_idoc_data-segnam 'E1SBO_CRE'.
MOVE ls_seg1 TO  ls_idoc_data-sdata.
APPEND ls_idoc_data TO lt_idoc_data.

ls_idoc_data-segnam 'E1BPSBONEW'.

ls_bookdata-airlineid in_sbook-carrid.
ls_bookdata-connectid in_sbook-connid.
ls_bookdata-flightdate in_sbook-fldate.
ls_bookdata-customerid in_sbook-customid.
ls_bookdata-class in_sbook-class.
ls_bookdata-counter in_sbook-counter.
ls_bookdata-agencynum in_sbook-agencynum.
ls_bookdata-passname in_sbook-passname.
ls_bookdata-passform in_sbook-passform.
ls_bookdata-passbirth in_sbook-passbirth.
MOVE ls_bookdata TO  ls_idoc_data-sdata.
APPEND ls_idoc_data TO lt_idoc_data.

ls_idoc_data-segnam 'E1BPPAREX'.
MOVE ls_seg3 TO  ls_idoc_data-sdata.
APPEND ls_idoc_data TO lt_idoc_data.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control            ls_idoc_ctr
TABLES
communication_idoc_control     lt_comm_idocs
master_idoc_data               lt_idoc_data
EXCEPTIONS
error_in_idoc_control          1
error_writing_idoc_status      2
error_in_idoc_data             3
sending_logical_system_unknown 4
OTHERS                         5.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
e_ret sy-subrc.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait 'X'.
e_ret 0.

ENDIF.

ENDFUNCTION.

 

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 change all URLs in SM59 to point to the new integration. and update the credentials.

Another change we have to take into consideration is Authentication - Earlier the user name and password we used was client id and client secret of the CPI instance from the config file.  Now we have to create Authentication service and then use the client id and secret from the config file of the authentication service for basic authentication to work. Last but the not the least we should also import the Certificates and update STRUST.

 

 
2 Comments
Labels in this area