消息

动态展示

DATA:gv_msg  TYPE smp_dyntxt, gv_check     TYPE boole_d.
gv_msg = SWITCH #( gv_check
           WHEN '' THEN VALUE #( icon_id = icon_led_green text = '请查阅返回消息' icon_text = '请查阅' )
           WHEN 'X' THEN VALUE #( icon_id = icon_led_red text = '包含错误消息,请查阅' icon_text = '请查阅错误日志' ) ).
TABLES:ekpo.
DATA: gt_message TYPE TABLE OF esp1_message_wa_type,
      lv_lmsg    TYPE text200.
PARAMETERS:p_zorder(10).
PARAMETERS:p_zposnr  TYPE ekpo-ebelp.
PARAMETERS:p_msg  TYPE bapi_msg.
PARAMETERS:p_msgt TYPE bapi_mtype.
lv_lmsg = |单号-{ p_zorder } 行-{ p_zposnr }:{ p_msg }|.
gt_message = VALUE #( BASE gt_message ( msgid = '00' msgty = p_msgt msgno = '000'
             msgv1 = lv_lmsg(50) msgv2 = lv_lmsg+50(50) msgv3 = lv_lmsg+100(50) msgv4 = lv_lmsg+150(50) lineno = lines( gt_message ) + 1 ) ).

IF gt_message IS NOT INITIAL."循环中放消息
  CALL FUNCTION 'C14Z_MESSAGES_SHOW_AS_POPUP'
    TABLES
      i_message_tab = gt_message.
ENDIF.

 

消息弹出:

 

 

 

 REPORT ztest.
 DATA: l_index      TYPE i VALUE 1,
       g_flag_error TYPE c,
       l_tabix      TYPE i,
       l_len        TYPE i,
       ok_code      TYPE sy-ucomm.

 DATA:lv_msg  TYPE  bapi_msg,lv_type TYPE bapi_mtype.


 DATA: xmesg TYPE smesgx OCCURS 0 WITH HEADER LINE, "all messages
       umesg TYPE smesgu OCCURS 0 WITH HEADER LINE. "titles

 TYPES:BEGIN OF typ_msg,
         msgty TYPE smesgx-msgty,
         zeile TYPE smesgx-zeile,
         text  TYPE smesgx-text.
 TYPES:END OF typ_msg.
 DATA:gt_msg TYPE TABLE OF typ_msg.
 DATA:gs_msg TYPE typ_msg.
 FIELD-SYMBOLS:<fs_table> TYPE ANY TABLE  .
 FIELD-SYMBOLS:<fs_MSGTY> TYPE  any    .

 CALL FUNCTION 'MESSAGES_INITIALIZE'.

 DEFINE d_store_message.
   g_flag_error = 'X'.
   CALL FUNCTION 'MESSAGE_STORE'
     EXPORTING
       arbgb = '00'
       msgty = lv_type
       txtnr = '001'
       msgv1 = lv_msg
       msgv2 = ''
       msgv3 = ''
       msgv4 = ''
       zeile = l_index.
   l_index = l_index + 1.
 END-OF-DEFINITION.

 PERFORM check.

 FORM check .

   lv_type = |E|.   lv_msg = '附加字段:行' && l_tabix && ',字段' &&   '的单位字段'  &&'不存在'.
   d_store_message .

   lv_type = |S|.   lv_msg = '附加字段 不存在'.
   d_store_message .

   ASSIGN ('(SAPLSMSG)XMESG[]') TO <fs_table>.
   LOOP AT <fs_table> ASSIGNING <fs_MSGTY>..
     gS_msg = CORRESPONDING #( <fs_MSGTY> ).
     CONDENSE gS_msg-zeile.
     APPEND gS_msg TO gt_msg.CLEAR gS_msg.
   ENDLOOP.
   IF g_flag_error = 'X'.
     CALL FUNCTION 'MESSAGES_SHOW'.
   ENDIF.
 ENDFORM.
View Code

SLG1

 

posted @ 2021-11-04 19:30  蜡哲图  阅读(47)  评论(0编辑  收藏  举报
目录内容