Programmvorlage Batch-Input
Aus SAP-Wiki
Zur Navigation springenZur Suche springen
Siehe Kategorie: Schnittstelle.
Siehe Kategorie: ABAP-Vorlagen.
Siehe Batch-Input.
DATA: ls_bdcdata TYPE bdcdata, lt_bdcdata TYPE TABLE OF bdcdata, lt_itab_msg TYPE TABLE OF bdcmsgcoll, ls_itab_msg type BDCMSGCOLL, lv_modus type c. Data: lv_msgv1 type BALM-MSGV1, lv_msgv2 type BALM-MSGV2, lv_msgv3 type BALM-MSGV3, lv_msgv4 type BALM-MSGV4, lv_lines type i. * Einstiegsbildschirm aufrufen lt_bdcdata = value #( base lt_bdcdata ( program = 'SAPMV45A' dynpro = '0102' dynbegin = 'X' ) ). * Bildschirm füllen lt_bdcdata = value #( base lt_bdcdata ( fnam = 'VBAK-VBELN' fval = lv_vbeln ) ). * OK-Code übergeben CLEAR ls_bdcdata. lt_bdcdata = value #( base lt_bdcdata ( fnam = 'BDC_OKCODE' fval = '/00' ) ). lv_modus = 'E'. "E = Anhalten bei Error, A = Anzeigen, N = Sammeln Fehler * Transaktion ausführen CALL TRANSACTION 'VA03' USING lt_bdcdata MODE lv_modus "E = Stoppen nur bei Error, A = Anzeige (für Test) MESSAGES INTO lt_itab_msg. "Fehlertabelle if lines( lt_itab_msg ) > 0. READ TABLE lt_itab_msg INTO ls_itab_msg WITH KEY msgtyp = 'E'. IF sy-subrc <> 0. READ TABLE lt_itab_msg INTO ls_itab_msg WITH KEY msgtyp = 'S'. ENDIF. IF ls_itab_msg IS NOT INITIAL. lv_msgv1 = ls_itab_msg-MSGV1. lv_msgv2 = ls_itab_msg-MSGV2. lv_msgv3 = ls_itab_msg-MSGV3. lv_msgv4 = ls_itab_msg-MSGV4. Data: lv_err_msg type string. CALL FUNCTION 'MESSAGE_PREPARE' EXPORTING LANGUAGE = ls_itab_msg-msgspra msg_id = ls_itab_msg-msgid msg_no = ls_itab_msg-msgnr MSG_VAR1 = lv_MSGV1 MSG_VAR2 = lv_MSGV2 MSG_VAR3 = lv_MSGV3 MSG_VAR4 = lv_MSGV4 IMPORTING MSG_TEXT = lv_err_msg EXCEPTIONS FUNCTION_NOT_COMPLETED = 1 MESSAGE_NOT_FOUND = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. else. message lv_err_msg type 'I'. return. ENDIF. endif. endif.