ALE/IDoc 在Outbound的时候,需要有程序来生成IDoc,在Inbound的时候需要有程序来解析IDoc,从而在R/3中生成主数据。
由于Outbound有:Message Control, Change Point, Stand-Alone三种方式,所以就衍生出三种不同Outbound程序。但是概念上,总体是一致的,只是实现是一些参数和功能不一样。相比而言,Inbound就比较单一,就只有一种方式,而且格式固定。
下面就放一个Inbound Function的例子,参数的话和标准的都一样的。
FUNCTION Z_KEVIN_INBOUND .
*"----------------------------------------------------------------------
*"*"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 MBDCONWF.
DATA: BEGIN OF LS_TEST,
ID(4) TYPE C,
TEXT(32) TYPE C,
END OF LS_TEST.
DATA LT_TEST LIKE STANDARD TABLE OF LS_TEST.
*initialize workflow result
WORKFLOW_RESULT = C_WF_RESULT_OK.
LOOP AT IDOC_CONTRL.
*make sure we have the correct message passed to us
IF IDOC_CONTRL-MESTYP NE 'ZKEVIN_INBOUND_M'.
RAISE WRONG_FUNCTION_CALLED.
ENDIF.
*clear application buffers
CLEAR LS_TEST.
REFRESH LT_TEST.
* process all data records in an IDoc and transfer them to
* application buffers
LOOP AT IDOC_DATA WHERE DOCNUM EQ IDOC_CONTRL-DOCNUM.
CASE IDOC_DATA-SEGNAM.
WHEN 'ZKEVIN_TEST'.
LS_TEST-ID = IDOC_DATA-SDATA+0(4).
LS_TEST-TEXT = IDOC_DATA-SDATA+4(32).
APPEND LS_TEST TO LT_TEST.
ENDCASE.
ENDLOOP.
INSERT ZKEVIN_T FROM TABLE LT_TEST.
IF SY-SUBRC EQ 0.
* populate return variables for success
RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.
RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
APPEND RETURN_VARIABLES.
* add status record indicating success
IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
IDOC_STATUS-STATUS = '53'.
IDOC_STATUS-MSGTY = 'I'.
IDOC_STATUS-MSGID = 'ZE'.
IDOC_STATUS-MSGNO = '006'.
IDOC_STATUS-MSGV1 = 'TEST ONE'.
APPEND IDOC_STATUS.
ENDIF.
ENDLOOP.
ENDFUNCTION.
阅读(2106) | 评论(0) | 转发(0) |