1、单条消息的输出
普通消息输出方式每次只能输出最后一条消息,例如: message e001(vf).
2、多条消息的输出
需要用到函数组:MESSAGES_SHOW
TYPES:
BEGIN OF ts_msg,
msgty TYPE msgty,
msgid TYPE msgid,
msgno TYPE syst_msgno,
msgv1 TYPE msgv1,
msgv2 TYPE msgv2,
msgv3 TYPE msgv3,
msgv4 TYPE msgv4,
text TYPE string,
logsys TYPE logsys,
exception TYPE REF TO cx_root,
END OF ts_msg,
tt_msg TYPE STANDARD TABLE OF ts_msg WITH EMPTY KEY.
*====================================================
START-OF-SELECTION.
*====================================================
DATA: lv_corr_wanted TYPE char30,
lv_msg_sel TYPE smesg,
lv_exit_cmd TYPE bal_s_excm.
DATA lt_msg TYPE tt_msg.
MESSAGE e001(vf) INTO DATA(lv_msg).
APPEND CORRESPONDING #( sy ) TO lt_msg.
MESSAGE w005(vf) INTO lv_msg.
APPEND CORRESPONDING #( sy ) TO lt_msg.
MESSAGE i010(vf) INTO lv_msg.
APPEND CORRESPONDING #( sy ) TO lt_msg.
CALL FUNCTION 'MESSAGES_INITIALIZE'.
LOOP AT lt_msg ASSIGNING FIELD-SYMBOL(<ls_msg>).
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = <ls_msg>-msgid
msgty = <ls_msg>-msgty
msgv1 = <ls_msg>-msgv1
msgv2 = <ls_msg>-msgv2
msgv3 = <ls_msg>-msgv3
msgv4 = <ls_msg>-msgv4
txtnr = <ls_msg>-msgno
EXCEPTIONS
OTHERS = 1.
ASSERT sy-subrc = 0.
ENDLOOP.
CALL FUNCTION 'MESSAGES_STOP'
EXCEPTIONS
OTHERS = 0.
CALL FUNCTION 'MESSAGES_SHOW'
EXPORTING
object = 'Message title'
show_linno = abap_false
i_use_grid = abap_true
IMPORTING
corrections_wanted = lv_corr_wanted
msg_selected = lv_msg_sel
e_exit_command = lv_exit_cmd
EXCEPTIONS
OTHERS = 1.
ASSERT sy-subrc = 0.
WRITE: 'done'.