Ausgabe BAPI-Messages

Mit diesem Funktionsbaustein können Sie in Ihren Programmen in einfacher Weise die Meldungen ausgeben, die ein BAPI erzeugt hat. Sie können die Parameter auch einfach an andere Message-Tabellen anpassen um hier ebenfalls eine Ausgabe zu realisieren.


Eine übersichtliche Ausgabe von Meldungen

FUNCTION z_meldungsausgabe_bapi.
*”———————————————————————-
*”*”Lokale Schnittstelle:
*”  IMPORTING
*”     REFERENCE(I_AMODAL_WINDOW) TYPE  CHAR1
*”  TABLES
*”      IT_RETURN_BAPI STRUCTURE  BAPIRET2 OPTIONAL
*”      IT_RETURN_IDOC STRUCTURE  BDIDOCSTAT OPTIONAL
*”———————————————————————-

*** INIT ***
  CALL FUNCTION ‘MESSAGES_INITIALIZE’.

*** BAPI-MELDUNGEN ***
  LOOP AT it_return_bapi.
    CALL FUNCTION ‘MESSAGE_STORE’
         EXPORTING
              arbgb                   = it_return_bapi-id
              exception_if_not_active = ‘ ‘
              msgty                   = it_return_bapi-type
              msgv1                   = it_return_bapi-message_v1
              msgv2                   = it_return_bapi-message_v2
              msgv3                   = it_return_bapi-message_v3
              msgv4                   = it_return_bapi-message_v4
              txtnr                   = it_return_bapi-number
              zeile                   = ‘ ‘
         EXCEPTIONS
              message_type_not_valid  = 1
              not_active              = 2
              OTHERS                  = 3.
  ENDLOOP.

*** IDOC-MELDUNGEN ***
  LOOP AT it_return_idoc.
    CALL FUNCTION ‘MESSAGE_STORE’
         EXPORTING
              arbgb                   = it_return_idoc-msgid
              exception_if_not_active = ‘ ‘
              msgty                   = it_return_idoc-msgty
              msgv1                   = it_return_idoc-msgv1
              msgv2                   = it_return_idoc-msgv2
              msgv3                   = it_return_idoc-msgv3
              msgv4                   = it_return_idoc-msgv4
              txtnr                   = it_return_idoc-msgno
              zeile                   = ‘ ‘
         EXCEPTIONS
              message_type_not_valid  = 1
              not_active              = 2
              OTHERS                  = 3.
  ENDLOOP.

*** STOP um “Fehler in Message-Handling” zu vermeiden
  CALL FUNCTION ‘MESSAGES_STOP’
       EXCEPTIONS
            a_message = 04
            e_message = 03
            i_message = 02
            w_message = 01.

  IF NOT sy-subrc IS INITIAL.
*** AUSGABE ***
    CALL FUNCTION ‘MESSAGES_SHOW’
         EXPORTING
              i_use_grid         = ‘X’
              i_amodal_window    = i_amodal_window
         EXCEPTIONS
              inconsistent_range = 1
              no_messages        = 2
              OTHERS             = 3.
  ENDIF.

ENDFUNCTION.

Enno Wulff
Letzte Artikel von Enno Wulff (Alle anzeigen)

Leave a Comment