steps for inbound ale idoc

5
Inbound IDoc Posting Function Module In the receiving system, create a function module Z_IDOC_INPUT_ZRZSO_MT using SE37. Below, I have described the logic for the same. Add Include MBDCONWF. This include contains predefined ALE constants. Loop at EDIDC table Check if the message type is ZRZORDER. Otherwise raise WRONG_FUNCTION_CALLED exception Loop at EDIDD table o Append data from the segments to appropriate internal tables o For example: append data from ZRZSEG1 segment to the internal table of type ZCUSTOMERS Update the DDic tables from internal tables Depending on the result of the update, fill the IDoc status record (type BDIDOCSTAT) and append it to the corresponding table. o Status 53 => Success o Status 51 => Error Code for function module Z_IDOC_INPUT_ZRZSO_MT . FUNCTION Z_IDOC_INPUT_ZRZSO_MT. *"---------------------------------------------------------------------- ""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 *"---------------------------------------------------------------------- Include File containing ALE constants INCLUDE MBDCONWF. TABLES : ZCUSTOMERS, "Cutomer Header ZSOHEADERS, "Sales Header ZSOITEMS. "Sales Items ***Data DATA : W_ZRZSEG1 LIKE ZRZSEG1, W_ZRZSEG2 LIKE ZRZSEG2, W_ZRZSEG3 LIKE ZRZSEG3.

Upload: balajisap

Post on 17-Sep-2015

223 views

Category:

Documents


0 download

DESCRIPTION

Inbound IDoc Posting Function Module

TRANSCRIPT

Inbound IDoc Posting Function ModuleIn the receiving system, create a function module Z_IDOC_INPUT_ZRZSO_MT using SE37. Below, I have described the logic for the same.Add Include MBDCONWF. This include contains predefined ALE constants.Loop at EDIDC table Check if the message type is ZRZORDER. Otherwise raise WRONG_FUNCTION_CALLED exception Loop at EDIDD table Append data from the segments to appropriate internal tables For example: append data from ZRZSEG1 segment to the internal table of type ZCUSTOMERS Update the DDic tables from internal tables Depending on the result of the update, fill the IDoc status record (type BDIDOCSTAT) and append it to the corresponding table. Status 53 => Success Status 51 => Error Code for function module Z_IDOC_INPUT_ZRZSO_MT . FUNCTION Z_IDOC_INPUT_ZRZSO_MT.*"----------------------------------------------------------------------""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*"---------------------------------------------------------------------- Include File containing ALE constants INCLUDE MBDCONWF. TABLES : ZCUSTOMERS, "Cutomer Header ZSOHEADERS, "Sales Header ZSOITEMS. "Sales Items***Data DATA : W_ZRZSEG1 LIKE ZRZSEG1, W_ZRZSEG2 LIKE ZRZSEG2, W_ZRZSEG3 LIKE ZRZSEG3. DATA : T_ZCUSTOMERS LIKE ZCUSTOMERS OCCURS 0 WITH HEADER LINE. DATA : T_ZSOHEADERS LIKE ZSOHEADERS OCCURS 0 WITH HEADER LINE. DATA : T_ZSOITEMS LIKE ZSOITEMS OCCURS 0 WITH HEADER LINE.*********************************************************************** WORKFLOW_RESULT = C_WF_RESULT_OK. LOOP AT IDOC_CONTRL. IF IDOC_CONTRL-MESTYP NE 'ZRZSO_MT'. RAISE WRONG_FUNCTION_CALLED. ENDIF.* Before reading a new entry, clear application buffer LOOP AT IDOC_DATA WHERE DOCNUM EQ IDOC_CONTRL-DOCNUM. CASE IDOC_DATA-SEGNAM. WHEN 'ZRZSEG1'. W_ZRZSEG1 = IDOC_DATA-SDATA. MOVE-CORRESPONDING W_ZRZSEG1 TO T_ZCUSTOMERS. INSERT INTO ZCUSTOMERS VALUES T_ZCUSTOMERS. WHEN 'ZRZSEG2'. W_ZRZSEG2 = IDOC_DATA-SDATA. MOVE-CORRESPONDING W_ZRZSEG2 TO T_ZSOHEADERS. INSERT INTO ZSOHEADERS VALUES T_ZSOHEADERS. WHEN 'ZRZSEG3'. W_ZRZSEG3 = IDOC_DATA-SDATA. MOVE-CORRESPONDING W_ZRZSEG3 TO T_ZSOITEMS. INSERT INTO ZSOITEMS VALUES T_ZSOITEMS. ENDCASE. ENDLOOP.************************************************************************ CUSTOMER HEADER ************************************************************************** SELECT ** FROM zcustomers.* ENDSELECT.* IF sy-subrc NE 0.* INSERT INTO zcustomers VALUES t_zcustomers.* ELSE. UPDATE ZCUSTHEAD FROM T_ZCUSTOMERS.* ENDIF. IF SY-SUBRC EQ 0. 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 = T_ZCUSTOMERS-KUNNR. 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 = T_ZCUSTOMERS-KUNNR. 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.************************************************************************ SALES HEADER ************************************************************************** SELECT ** FROM zsoheaders.* ENDSELECT.* IF sy-subrc NE 0.* INSERT INTO zsoheaders VALUES t_zsoheaders.* ELSE. UPDATE ZSOHEADERS FROM T_ZSOHEADERS.* ENDIF. IF SY-SUBRC EQ 0. 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 = T_ZSOHEADERS-VBELN. 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 = T_ZSOHEADERS-VBELN. 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.************************************************************************ SALES ITEM ************************************************************************** SELECT ** FROM zsoitems.* ENDSELECT.* IF sy-subrc NE 0.* INSERT INTO zsoitems VALUES t_zsoitems.* ELSE. UPDATE ZSOITEMS FROM T_ZSOITEMS.* ENDIF. IF SY-SUBRC EQ 0. 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 = T_ZSOITEMS-VBELN. 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 = T_ZSOITEMS-VBELN. 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. Inbound Settings Define Logical Systems - Transaction SALE Assign Client to Logical System - Transaction SALE Maintain RFC Destinations - Transaction SM59 Define Ports - Transaction WE21 Generate/Create Partner Profile - Transactions BD82/WE20 Assign Function Module to Logical message - Transaction WE57 Create a new entry Specify name of the Function Module as Z_IDOC_INPUT_ZRZSO_MT Also, specify Type as F, Basic IDoc type as ZRZORDER, Message type as ZRZSO_MT and Direction as 2 (Inbound) Save the entry Define Input method for Inbound Function Module - Transaction BD51 Create a new entry Provide Function Module name as Z_IDOC_INPUT_ZRZSO_MT Specify the Input method as 2 Save the entry Create a Process Code - Transaction WE42 Create a new Process Code ZPCRZ Select Processing with ALE Service Choose Processing type as Processing by function module Save the entry On the next screen, select your function module from the list Save the changes Now you will be taken to the next screen Double-click on Logical message In the Assignment to logical message, specify the message type ZRZSO_MT Save the changes Send and receive dataOn the sender system, execute the IDoc Generation Program. Check the status of IDoc using transaction WE02.Check the status of the IDoc in the receiver system using transaction WE02. You can also check the contents of DDic tables to make sure that the records have been created in the receiver system.Thus to summarize we have learned how to: Create a custom idoc Write an outbound idoc generation program. Write Inbound Function Module to post Inbound IDoc Configure and test ALE scenario to transmit data between systems distributed across the network Labels parameters