Introduction
Overview
Solution:
- Create an RFC FM which sends data to COUPA.
- Create a Z_table, to store the acknowledgement from COUPA.
- Create a RFC FM which receives acknowledgement from COUPA.
- Create a Z_program and call the RFC FM which sends data to COUPA with help of Mulesoft.
- Create RFC connection in between SAP and Mulesoft, usually this connection will be available when Mulesoft was set up as Middleware in the systems environment.
SAP ECC objects creation
- Create a RFC FM which sends data to COUPA
FUNCTION z_receive_ack_coupa.
*"----------------------------------------------------------------------*"*"Local Interface:
*" IMPORTING
*" VALUE(IM_ACK) TYPE ZCOUPA_ACK
*"----------------------------------------------------------------------
DATA: wa_zcoupa_ack TYPE zcoupa_ack.
IF NOT im_ack IS INITIAL.
SELECT SINGLE * FROM zcoupa_ack
INTO wa_zcoupa_ack
WHERE po_number EQ wa_zcoupa_ack-po_number
AND status EQ space.
IF sy-subrc EQ 0.
wa_zcoupa_ack-status = im_ack-status.
wa_zcoupa_ack-stat_desc = im_ack-stat_desc.
MODIFY zcoupa_ack FROM wa_zcoupa_ack.
ENDIF.
ENDIF.
ENDFUNCTION.
*&---------------------------------------------------------------------*
*& Report Z_SEND_PO_2_COUPA
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_send_po_2_coupa.
*Data Declaration
DATA: wa_ekko TYPE ekko,
it_ekpo TYPE STANDARD TABLE OF ekpo,
l_v_mulesoft TYPE rfcdest VALUE 'MULE100'. " Moulesoft Logical system
*Selction Screen
PARAMETERS p_ebeln TYPE ebeln.
START-OF-SELECTION.
*Fetch PO Header
SELECT SINGLE * FROM ekko INTO wa_ekko WHERE ebeln = p_ebeln.
IF sy-subrc EQ 0.
* Fetch PO Item
SELECT * FROM ekpo INTO TABLE it_ekpo WHERE ebeln = p_ebeln.
ELSE.
MESSAGE 'Enter Correct PO Number' TYPE 'E'.
ENDIF.
IF NOT wa_ekko IS INITIAL.
CHECK l_v_mulesoft IS NOT INITIAL.
**Also check if the RFC destination is active,
**if not dont send the destination back
**this is to avoid system resulting in runtime error if connection fails
CALL FUNCTION 'RFC_PING'
DESTINATION l_v_mulesoft
EXCEPTIONS
system_failure = 1
communication_failure = 2
OTHERS = 99.
IF sy-subrc EQ 0.
* RFC FM to send PO details to COUPA system.
CALL FUNCTION 'Z_SEND_2_COUPA'
DESTINATION l_v_mulesoft
EXPORTING
im_ekko = wa_ekko
TABLES
im_ekpo = it_ekpo.
ELSE.
MESSAGE 'RFC Error' TYPE 'E'.
ENDIF.
ENDIF.
*& Report Z_SEND_PO_2_COUPA
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_send_po_2_coupa.
*Data Declaration
DATA: wa_ekko TYPE ekko,
it_ekpo TYPE STANDARD TABLE OF ekpo,
l_v_mulesoft TYPE rfcdest VALUE 'MULE100'. " Moulesoft Logical system
*Selction Screen
PARAMETERS p_ebeln TYPE ebeln.
START-OF-SELECTION.
*Fetch PO Header
SELECT SINGLE * FROM ekko INTO wa_ekko WHERE ebeln = p_ebeln.
IF sy-subrc EQ 0.
* Fetch PO Item
SELECT * FROM ekpo INTO TABLE it_ekpo WHERE ebeln = p_ebeln.
ELSE.
MESSAGE 'Enter Correct PO Number' TYPE 'E'.
ENDIF.
IF NOT wa_ekko IS INITIAL.
CHECK l_v_mulesoft IS NOT INITIAL.
**Also check if the RFC destination is active,
**if not dont send the destination back
**this is to avoid system resulting in runtime error if connection fails
CALL FUNCTION 'RFC_PING'
DESTINATION l_v_mulesoft
EXCEPTIONS
system_failure = 1
communication_failure = 2
OTHERS = 99.
IF sy-subrc EQ 0.
* RFC FM to send PO details to COUPA system.
CALL FUNCTION 'Z_SEND_2_COUPA'
DESTINATION l_v_mulesoft
EXPORTING
im_ekko = wa_ekko
TABLES
im_ekpo = it_ekpo.
ELSE.
MESSAGE 'RFC Error' TYPE 'E'.
ENDIF.
ENDIF.
Iam very impressive your site gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you
ReplyDeleteMulesoft online training