使用する
このステップでは、新しいプロセスコードを使用してIDocインタフェースによって識別され、ALE(項目TBD52-FUNCNAME)から呼び出される汎用モジュールを登録する方法について説明します。汎用モジュール(ワークフローを使用しない)を使用した直接インバウンド処理には、常にALEレイヤが含まれます。この設定(汎用モジュールおよびALEレイヤでの処理)は、汎用モジュールIDOC_START_INBOUNDによって読み取られる項目TEDE2-EDIVRSの値6によって識別されます。次に、IDOC_START_INBOUNDはALEを呼び出します。
前提条件
基本タイプの定義と使用で必要な手順を完了している必要があります。
プロセス
-
ツール ABAPワークベンチ 開発 機能ビルダを選択し、新しい汎用モジュールを登録します。
-
セグメントを汎用グループのグローバルデータとして登録します。汎用モジュールは、セグメントから対応するアプリケーションテーブルにアプリケーションデータをコピーし、それに応じてIDocステータスを変更する必要があります。エラーが発生した場合、汎用モジュールは例外処理に対応するワークフローパラメータを設定する必要があります。
-
汎用モジュールをアクティブにします。関数ビルダの初期画面で、を選択します。
アプリケーションの略語 |
V(販売・流通) |
処理タイプ |
通常、すぐに開始します |
正式なパラメータ |
参照構造 |
説明 |
パラメータのインポート |
|
|
入力方式 |
BDWFAP_PAR-INPUTMETHD |
汎用モジュールの処理方法を説明します(例:バックグラウンドで) |
MASS_PROCESSING |
BDWFAP_PAR-MASS_PROC |
大量インバウンド処理?(インジケータ) |
パラメータのエクスポート |
|
|
WORKFLOW_RESULT |
BDWFAP_PAR-結果 |
エラー処理のためにイベントをトリガーする場合は、99999に設定します。 |
APPLICATION_VARIABLE |
BDWFAP_PAR-APPL_VAR |
ワークフロー用のアプリケーションから自由に利用できる変数 |
IN_UPDATE_TASK |
BDWFAP_PAR-UPDATETASK |
非同期更新?(例ではインジケーターは設定されていません) |
CALL_TRANSACTION_DONE |
BDWFAP_PAR-CALLTRANS |
と呼ばれるトランザクション?(例ではインジケーターは設定されていません) |
テーブル |
|
|
IDOC_CONTRL |
EDIDC |
IDoc制御レコード |
IDOC_DATA |
EDIDD |
IDocデータレコード |
IDOC_STATUS |
BDIDOCSTAT |
ALEのIDocステータスレコード |
RETURN_VARIABLES |
BDWFRETVAR |
オブジェクトタイプメソッドパラメータへのIDoc割り当て |
SERIALIZATION_INFO |
BDI_SER |
複数のIDocを特定の順序で処理する場合:この構造には、必要な情報が含まれています。 |
例
FUNCTION IDOC_INPUT_TESTER.*"-------------------------------------------------------------------*"*"Globale Schnittstelle:*" IMPORTING*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC*" EXPORTING*" VALUE(WORKFLOW_RESULT) LIKE BDWFAP_PAR-RESULT*" VALUE(APPLICATION_VARIABLE) LIKE BDWFAP_PAR-APPL_VAR*" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK*" VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS*" TABLES*" IDOC_CONTRL STRUCTURE EDIDC OPTIONAL*" IDOC_DATA STRUCTURE EDIDD*" IDOC_STATUS STRUCTURE BDIDOCSTAT*" RETURN_VARIABLES STRUCTURE BDWFRETVAR*" SERIALIZATION_INFO STRUCTURE BDI_SER*"-------------------------------------------------------------------* initialize SET/GET Parameter and internal tables PERFORM INITIALIZE_ORGANIZATIONAL_DATA.* Move IDOC to internal tables of application PERFORM READ_IDOC_TESTER.* call transaction Order Entry VA01 PERFORM CALL_VA01_IDOC_ORDERS USING ERRORCODE.* set status value perform write_status_record using errorcode.* return values of function module PERFORM RETURN_VARIABLES_FILL USING ERRORCODE.ENDFUNCTION.FORM INITIALIZE_ORGANIZATIONAL_DATA.* initialize SET/GET parameters SET PARAMETER ID 'VKO' FIELD SPACE. SET PARAMETER ID 'VTW' FIELD SPACE. SET PARAMETER ID 'SPA' FIELD SPACE. SET PARAMETER ID 'VKB' FIELD SPACE. SET PARAMETER ID 'VKG' FIELD SPACE.* initialize internal tables REFRESH BDCDATA. CLEAR BDCDATA. CLEAR BELEGNUMMER. CLEAR ERRTAB. REFRESH ERRTAB. REFRESH XBDCMSGCOLL. CLEAR XBDCMSGCOLL.ENDFORM. " INITIALIZE_ORGANIZATIONAL_DATAFORM READ_IDOC_TESTER. PERFORM INITIALIZE_IDOC. LOOP AT IDOC_DATA WHERE DOCNUM = IDOC_CONTRL-DOCNUM. CASE IDOC_DATA-SEGNAM.* header data WHEN 'E1HEAD'. MOVE IDOC_DATA-SDATA TO E1HEAD. PERFORM PROCESS_SEGMENT_E1HEAD.* position data WHEN 'E1ITEM'. MOVE IDOC_DATA-SDATA TO E1ITEM. PERFORM PROCESS_SEGMENT_E1ITEM. ENDCASE. ENDLOOP.* only when there were one or more items CHECK FIRST NE 'X'. APPEND XVBAP. "last oneENDFORM. " READ_IDOC_TESTERFORM INITIALIZE_IDOC. CLEAR XVBAK. REFRESH XVBAP. CLEAR XVBAP. POSNR = 0. FIRST = 'X'.ENDFORM. " INITIALIZE_IDOCFORM PROCESS_SEGMENT_E1HEAD.* requested date of delivery WLDAT = E1HEAD-WLDAT.* delivery date XVBAK-BSTDK = E1HEAD-BSTDK.* customer number XVBAK-KUNNR = E1HEAD-AUGEB.* order number XVBAK-BSTNK = E1HEAD-BELNR.* division XVBAK-SPART = E1HEAD-SPART.* distribution channel XVBAK-VTWEG = E1HEAD-VTWEG.* sales organization XVBAK-VKORG = E1HEAD-VKORG.* order type XVBAK-AUART = E1HEAD-AUART.* do not fill incoterms (inco1, inco2)* customer function CALL CUSTOMER-FUNCTION '001' EXPORTING PI_VBAK621 = XVBAK IMPORTING PE_VBAK621 = XVBAK TABLES PT_IDOC_DATA_RECORDS = IDOC_DATA.ENDFORM. " PROCESS_SEGMENT_E1HEADFORM PROCESS_SEGMENT_E1ITEM.* position number XVBAP-POSNR = XVBAP-POSNR + 1.* amount XVBAP-WMENG = E1ITEM-MENGE.* unit CALL FUNCTION 'ISO_TO_SAP_MEASURE_UNIT_CODE' EXPORTING ISO_CODE = E1ITEM-BMEINH IMPORTING SAP_CODE = XVBAP-VRKME EXCEPTIONS OTHERS = 0.* material number XVBAP-MATNR = E1ITEM-LMATNR.CALL CUSTOMER-FUNCTION '002' EXPORTING PI_VBAP621 = XVBAP IMPORTING PE_VBAP621 = XVBAP TABLES PT_IDOC_DATA_RECORDS = IDOC_DATA.APPEND XVBAP.ENDFORM. " PROCESS_SEGMENT_E1ITEMFORM CALL_VA01_IDOC_ORDERS USING ERRORCODE.* call transaction first dynpro PERFORM DYNPRO_START.* call transaction double-line entry PERFORM DYNPRO_DETAIL2.* incoterms PERFORM DYNPRO_HEAD_300.* call transaction item datas PERFORM DYNPRO_POSITION. PERFORM DYNPRO_SET USING 'BDC_OKCODE' 'SICH'.* determine input method IF INPUT_METHOD IS INITIAL. INPUT_METHOD = 'N'. ENDIF.* call transaction VA01 CALL TRANSACTION 'VA01' USING BDCDATA MODE INPUT_METHOD UPDATE 'S' MESSAGES INTO XBDCMSGCOLL.errorcode = SY-SUBRC. " remember returncode for status updateENDFORM. " CALL_VA01_IDOC_ORDERSform write_status_record using errorcode.* FILL IDOC_STATUS IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM. IF ERRORCODE = 0.IDOC_STATUS-STATUS = BELEG_GEBUCHT. "value 53 GET PARAMETER ID 'AUN' FIELD BELEGNUMMER. IDOC_STATUS-MSGID = 'V1'. IDOC_STATUS-MSGNO = '311'. IDOC_STATUS-MSGV1 = 'Terminauftrag'. IDOC_STATUS-MSGV2 = BELEGNUMMER. ELSE. IDOC_STATUS-STATUS = BELEG_NICHT_GEBUCHT. "value 51 IDOC_STATUS-MSGID = SY-MSwGID. IDOC_STATUS-MSGNO = SY-MSGNO. IDOC_STATUS-MSGV1 = SY-MSGV1. IDOC_STATUS-MSGV2 = SY-MSGV2. IDOC_STATUS-MSGV3 = SY-MSGV3. IDOC_STATUS-MSGV4 = SY-MSGV4. ENDIF. APPEND IDOC_STATUS.ENDFORM.FORM DYNPRO_START. PERFORM DYNPRO_NEW USING PROGRAMM_AUFTRAG DYNPRO-EINSTIEG CHANGING LAST_DYNPRO.* ordertype PERFORM DYNPRO_SET USING 'VBAK-AUART' XVBAK-AUART.* sales organization PERFORM DYNPRO_SET USING 'VBAK-VKORG' XVBAK-VKORG.* Distribution channel PERFORM DYNPRO_SET USING 'VBAK-VTWEG' XVBAK-VTWEG.* Division PERFORM DYNPRO_SET USING 'VBAK-SPART' XVBAK-SPART.* Sales office PERFORM DYNPRO_SET USING 'VBAK-VKBUR' XVBAK-VKBUR.* Sales group PERFORM DYNPRO_SET USING 'VBAK-VKGRP' XVBAK-VKGRP.ENDFORM. " DYNPRO_STARTFORM DYNPRO_NEW USING PROGNAME DYNPRONR CHANGING LAST_DYNPRO. CLEAR BDCDATA. BDCDATA-PROGRAM = PROGNAME. BDCDATA-DYNPRO = DYNPRONR. BDCDATA-DYNBEGIN = 'X'. APPEND BDCDATA. LAST_DYNPRO = DYNPRONR.ENDFORM. " DYNPRO_NEWFORM DYNPRO_SET USING FELDNAME FELDINHALT. CLEAR BDCDATA. CHECK FELDINHALT NE SPACE.* dynpro field name BDCDATA-FNAM = FELDNAME.* contents BDCDATA-FVAL = FELDINHALT. APPEND BDCDATA.ENDFORM. " DYNPRO_SETFORM DYNPRO_DETAIL2.* okcode* PERFORM DYNPRO_SET USING 'BDC_OKCODE' PANEL-UER2.* fix dynpro number 4001 PERFORM DYNPRO_NEW USING PROGRAMM_AUFTRAG '4001' CHANGING LAST_DYNPRO.* order party PERFORM DYNPRO_SET USING 'KUAGV-KUNNR' XVBAK-KUNNR.* purchase order number PERFORM DYNPRO_SET USING 'VBKD-BSTKD' XVBAK-BSTNK.* requested delivery date PERFORM DYNPRO_DATE_SET USING 'VBKD-BSTDK' XVBAK-BSTDK.* purchase order date PERFORM DYNPRO_DATE_SET USING 'RV45A-KETDAT' WLDAT.ENDFORM. " DYNPRO_DETAIL2FORM DYNPRO_DATE_SET USING FELDNAME FELDINHALT. DATA: DATE TYPE D. CLEAR BDCDATA. CHECK FELDINHALT NE SPACE. BDCDATA-FNAM = FELDNAME. WRITE FELDINHALT TO DATE. BDCDATA-FVAL = DATE. APPEND BDCDATA.ENDFORM. " DYNPRO_DATE_SETFORM DYNPRO_HEAD_300. PERFORM DYNPRO_SET USING 'BDC_OKCODE' PANEL-KKAU.* incoterms part 1 IF NOT XVBAK-INCO1 IS INITIAL. PERFORM DYNPRO_SET USING 'VBKD-INCO1' XVBAK-INCO1. ENDIF.* incoterms part 2 IF NOT XVBAK-INCO2 IS INITIAL. PERFORM DYNPRO_SET USING 'VBKD-INCO2' XVBAK-INCO2. ENDIF.* PERFORM DYNPRO_SET USING 'BDC_OKCODE' 'BACK'.ENDFORM. " DYNPRO_HEAD_300FORM DYNPRO_POSITION. LOOP AT XVBAP.* dynpro item double line entry* PERFORM DYNPRO_SET USING 'BDC_OKCODE' 'UER2'. IF XVBAP-POSNR = 1.* material number PERFORM DYNPRO_SET USING 'VBAP-MATNR(01)' XVBAP-MATNR.* order quantity PERFORM DYNPRO_SET USING 'RV45A-KWMENG(01)' XVBAP-WMENG.* desired delivery date PERFORM DYNPRO_DATE_SET USING 'RV45A-ETDAT(1)' WLDAT.* sales unit PERFORM DYNPRO_SET USING 'VBAP-VRKME(1)' XVBAP-VRKME. ELSE.* PERFORM DYNPRO_SET USING 'BDC_OKCODE' 'POAN'.* material number PERFORM DYNPRO_SET USING 'VBAP-MATNR(02)' XVBAP-MATNR.* order quantity PERFORM DYNPRO_SET USING 'RV45A-KWMENG(02)' XVBAP-WMENG.* desired delivery date PERFORM DYNPRO_DATE_SET USING 'RV45A-ETDAT(02)' WLDAT.* sales unit PERFORM DYNPRO_SET USING 'VBAP-VRKME(02)' XVBAP-VRKME. ENDIF. ENDLOOP.ENDFORM. " DYNPRO_POSITIONFORM RETURN_VARIABLES_FILL USING ERRORCODE.* allocate IDOC numbers to Workflow output parameters IF MASS_PROCESSING <> SPACE. IF ERRORCODE = 0. RETURN_VARIABLES-WF_PARAM = PID. RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM. APPEND RETURN_VARIABLES. RETURN_VARIABLES-WF_PARAM = APO. RETURN_VARIABLES-DOC_NUMBER = BELEGNUMMER. APPEND RETURN_VARIABLES. WORKFLOW_RESULT = C_WF_RESULT_OK. ELSE. RETURN_VARIABLES-WF_PARAM = EID. RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM. APPEND RETURN_VARIABLES. WORKFLOW_RESULT = C_WF_RESULT_ERROR. ENDIF. ELSE. IF ERRORCODE = 0. RETURN_VARIABLES-WF_PARAM = APE. RETURN_VARIABLES-DOC_NUMBER = BELEGNUMMER. APPEND RETURN_VARIABLES. WORKFLOW_RESULT = C_WF_RESULT_OK. ELSE. WORKFLOW_RESULT = C_WF_RESULT_ERROR. ENDIF. ENDIF.ENDFORM. " RETURN_VARIABLES_FILLGlobale Daten von IDOC_INPUT_TESTER TABLES: E1HEAD, E1ITEM.DATA: BEGIN OF BDCDATA OCCURS 500. INCLUDE STRUCTURE BDCDATA.DATA: END OF BDCDATA.DATA: BEGIN OF XVBAK. "Kopfdaten INCLUDE STRUCTURE VBAK621.DATA: END OF XVBAK.DATA: BEGIN OF XVBAP OCCURS 50. "Position INCLUDE STRUCTURE VBAP.DATA: WMENG(18) TYPE C.DATA: LFDAT LIKE VBAP-ABDAT.DATA: KSCHL LIKE KOMV-KSCHL.DATA: KBTRG(16) TYPE C.DATA: KSCHL_NETWR LIKE KOMV-KSCHL.DATA: KBTRG_NETWR(16) TYPE C.DATA: INCO1 LIKE VBKD-INCO1.DATA: INCO2 LIKE VBKD-INCO2.DATA: YANTLF(1) TYPE C.DATA: PRSDT LIKE VBKD-PRSDT.DATA: HPRSFD LIKE TVAP-PRSFD.DATA: END OF XVBAP.DATA: BEGIN OF DYNPRO, EINSTIEG LIKE T185V-DYNNR VALUE 101, KKAU LIKE T185V-DYNNR, UER2 LIKE T185V-DYNNR, KBES LIKE T185V-DYNNR, ERF1 LIKE T185V-DYNNR, PBES LIKE T185V-DYNNR, PKAU LIKE T185V-DYNNR, PEIN LIKE T185V-DYNNR, EID1 LIKE T185V-DYNNR, POPO LIKE T185V-DYNNR, EIPO LIKE T185V-DYNNR, KPAR LIKE T185V-DYNNR, PSDE LIKE T185V-DYNNR, PPAR LIKE T185V-DYNNR, KDE1 LIKE T185V-DYNNR, KDE2 LIKE T185V-DYNNR, PDE1 LIKE T185V-DYNNR, PDE2 LIKE T185V-DYNNR, PKON LIKE T185V-DYNNR, END OF DYNPRO.DATA: BEGIN OF PANEL, KKAU LIKE T185V-PANEL VALUE 'KKAU', UER2 LIKE T185V-PANEL VALUE 'UER2', KBES LIKE T185V-PANEL VALUE 'KBES', ERF1 LIKE T185V-PANEL VALUE 'ERF1', PBES LIKE T185V-PANEL VALUE 'PBES', PKAU LIKE T185V-PANEL VALUE 'PKAU', PEIN LIKE T185V-PANEL VALUE 'PEIN', EID1 LIKE T185V-PANEL VALUE 'EID1', EIAN LIKE T185V-PANEL VALUE 'EIAN', POPO LIKE T185V-PANEL VALUE 'POPO', EIPO LIKE T185V-PANEL VALUE 'EIPO', KPAR LIKE T185V-PANEL VALUE 'KPAR', PSDE LIKE T185V-PANEL VALUE 'PSDE', POAN LIKE T185V-PANEL VALUE 'POAN', PPAR LIKE T185V-PANEL VALUE 'PPAR', KDE1 LIKE T185V-PANEL VALUE 'KDE1', KDE2 LIKE T185V-PANEL VALUE 'KDE2', PDE1 LIKE T185V-PANEL VALUE 'PDE1', PDE2 LIKE T185V-PANEL VALUE 'PDE2', PKON LIKE T185V-PANEL VALUE 'PKON', KOAN LIKE T185V-PANEL VALUE 'KOAN', END OF PANEL.DATA: BEGIN OF ERRTAB OCCURS 20, TRANS LIKE TSTC-TCODE, ARBGB LIKE T100-ARBGB, CLASS(1) TYPE C, MSGNR LIKE T100-MSGNR,* TEXT LIKE T100-TEXT, TEXT(123) TYPE C, MSGV1 LIKE SY-MSGV1, MSGV2 LIKE SY-MSGV2, MSGV3 LIKE SY-MSGV3, MSGV4 LIKE SY-MSGV4, END OF ERRTAB.*---- Hilfsfelder ------------------------------------------------*DATA: PROGRAMM_AUFTRAG LIKE T185V-AGIDV VALUE 'SAPMV45A'.DATA: LAST_DYNPRO LIKE T185V-DYNNR, WLDAT LIKE VBAK-BSTDK, POSNR LIKE VBAP-POSNR, FIRST(1) TYPE C VALUE 'X'.DATA: BEGIN OF XBDCMSGCOLL OCCURS 10. INCLUDE STRUCTURE BDCMSGCOLL.DATA: END OF XBDCMSGCOLL.* Terminauftrag ( Auftragsart wird fest gesetzt !)DATA: BELEGNUMMER LIKE VBAK-VBELN.DATA: ERRORCODE LIKE SY-SUBRC.* Statuswerte fuer IDOC-StatusDATA: BELEG_NICHT_GEBUCHT LIKE TEDS1-STATUS VALUE '51'.DATA: BELEG_GEBUCHT LIKE TEDS1-STATUS VALUE '53'.*- Direktwerte für Return_variables -------------------------data: eid like bdwfretvar-wf_param value 'Error_IDOCs', pid like bdwfretvar-wf_param value 'Processed_IDOCs', apo like bdwfretvar-wf_param value 'Appl_Objects', ape like bdwfretvar-wf_param value 'Appl_Object'.*- Direktwerte für Workflow_Result -------------------------DATA: C_WF_RESULT_ERROR LIKE BDWFAP_PAR-RESULT VALUE '99999'.DATA: C_WF_RESULT_OK LIKE BDWFAP_PAR-RESULT VALUE '0'.