*--------------------------------------------------------------------*
* Klasse zur Anzeige eines Nachrichtenprotokolls (Logs)
*
* Kapselt folgende FuBas:
* MESSAGES_INITIALIZE
* MESSAGE_STORE
* MESSAGES_STOP
* MESSAGES_SHOW
*--------------------------------------------------------------------*
CLASS lcl_msg_log DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: init
RETURNING VALUE(rv_ok) TYPE boolean.
CLASS-METHODS: add
IMPORTING
i_arbgb TYPE smesg-arbgb
i_msgty TYPE smesg-msgty
i_txtnr TYPE string
i_zeile TYPE i DEFAULT 0
i_msgv1 TYPE string DEFAULT ''
i_msgv2 TYPE string DEFAULT ''
i_msgv3 TYPE string DEFAULT ''
i_msgv4 TYPE string DEFAULT ''
RETURNING VALUE(rv_ok) TYPE boolean.
CLASS-METHODS: show
IMPORTING
i_show_amodal TYPE boolean DEFAULT abap_false
RETURNING VALUE(rv_ok) TYPE boolean.
ENDCLASS.
*--------------------------------------------------------------------*
CLASS lcl_msg_log IMPLEMENTATION.
*--------------------------------------------------------------------*
* Nachrichtenprotokoll initialisieren
*--------------------------------------------------------------------*
METHOD init.
rv_ok = abap_false.
* Nachrichtenprotokoll initialisieren
CALL FUNCTION 'MESSAGES_INITIALIZE'
EXCEPTIONS
log_not_active = 1
wrong_identification = 2
OTHERS = 3.
IF sy-subrc = 0.
rv_ok = abap_true.
ENDIF.
ENDMETHOD.
*--------------------------------------------------------------------*
* Nachricht im Protokoll ablegen
*--------------------------------------------------------------------*
METHOD add.
rv_ok = abap_false.
* Nachricht im Protokoll ablegen
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = i_arbgb
msgty = i_msgty
msgv1 = i_msgv1
msgv2 = i_msgv2
msgv3 = i_msgv3
msgv4 = i_msgv4
txtnr = i_txtnr
zeile = i_zeile
EXCEPTIONS
message_type_not_valid = 1
not_active = 2
OTHERS = 3.
IF sy-subrc = 0.
rv_ok = abap_true.
ENDIF.
ENDMETHOD.
*--------------------------------------------------------------------*
* Nachrichtenprotokoll anzeigen
*--------------------------------------------------------------------*
METHOD show.
rv_ok = abap_false.
* Baustein analysiert Fehlerprotokoll und gibt als Status eine Exception aus
CALL FUNCTION 'MESSAGES_STOP'
EXCEPTIONS
a_message = 1
e_message = 2
w_message = 3
i_message = 4
s_message = 5
deactivated_by_md = 6
OTHERS = 7.
* Nachrichtenprotokoll anzeigen
CALL FUNCTION 'MESSAGES_SHOW'
EXPORTING
i_use_grid = abap_true
i_amodal_window = i_show_amodal
EXCEPTIONS
inconsistent_range = 1
no_messages = 2
OTHERS = 3.
IF sy-subrc = 0.
rv_ok = abap_true.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
IF abap_true = lcl_msg_log=>init( ).
IF abap_true = lcl_msg_log=>add( i_arbgb = 'SY'
i_msgty = 'E'
i_txtnr = '002'
i_zeile = 0
i_msgv1 = 'Fehler.' ).
IF abap_true = lcl_msg_log=>add( i_arbgb = 'SY'
i_msgty = 'W'
i_txtnr = '002'
i_zeile = 1
i_msgv1 = 'Warnung' ).
IF abap_true = lcl_msg_log=>add( i_arbgb = 'SY'
i_msgty = 'I'
i_txtnr = '002'
i_zeile = 2
i_msgv1 = 'Info' ).
IF abap_true = lcl_msg_log=>show( ).
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.