大家都知道SAP ALV的一个单元格最大显示的长度就是255
意思就是你的这个字段在内表里面即使是超过255位,也无法只能显示255
如果客户的需求是需要看到完整的消息内容,
最简单的就是将整个程序的数据右键导出到excle中去查看
如果客户执意需要在ALV中一个一个显示
首先将单元格设置可点击,然后单击去display
1.最简单的办法:cl_demo_output=>display_html
CALL METHOD cl_demo_output=>display_htmlEXPORTINGhtml = gs_result-ifmsg.
显示如图:
2. 函数:FB_MESSAGES_DISPLAY_POPUP
这种方法适用于标准bapi的报错,将错误捕捉后,显示
DATA: lt_tsmesg TYPE tsmesg.DATA: ls_smesg TYPE smesg.ls_smesg-msgty = 'E'.ls_smesg-text = gs_result-ifmsg..APPEND ls_smesg TO lt_tsmesg.CALL FUNCTION 'FB_MESSAGES_DISPLAY_POPUP'EXPORTINGit_smesg = lt_tsmesg
* ID_SMESG_ZEILE =
* IT_RETURN =
* ID_SEND_IF_ONE =EXCEPTIONSno_messages = 1popup_cancelled = 2OTHERS = 3.IF sy-subrc <> 0.
* Implement suitable error handling hereENDIF.
显示效果如图
3:借用longtxt的显示框
3.1 创建一个函数组:ZFG_TOOLS
3.2.创建一个函数:ZFM_DISPLAY_TEXT
源代码:
IF iv_text IS NOT INITIAL .CLEAR:src[].CALL FUNCTION 'SCMS_STRING_TO_FTEXT'EXPORTINGtext = iv_text
* IMPORTING
* LENGTH =TABLESftext_tab = src[].CALL SCREEN 0200 STARTING AT 5 5..ENDIF.
3.3 画一个屏幕:0200
3.4 设置flow logic:
PROCESS BEFORE OUTPUT.MODULE STATUS_0200.
*
PROCESS AFTER INPUT.MODULE USER_COMMAND_0200.
3.5 LZFG_TOOLSTOP 这个include中的代码:
FUNCTION-POOL ZFG_TOOLS. "MESSAGE-ID ..DATA go_editor TYPE REF TO cl_gui_textedit.
DATA: go_editcontainer TYPE REF TO cl_gui_custom_container.
DATA: BEGIN OF src OCCURS 500,line(72),END OF src.DATA:ok_code LIKE sy-ucomm.
* INCLUDE LZFG_TOOLSD... " Local class definition
3.6 新增include:LZFG_TOOLSO01
*----------------------------------------------------------------------*
***INCLUDE LZFG_TOOLSO01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_0200 OUTPUT.IF go_editcontainer IS INITIAL .CREATE OBJECT go_editcontainerEXPORTINGcontainer_name = 'SRC'repid = 'SAPLZFG_TOOLS'dynnr = '0200'.ENDIF.IF go_editor IS INITIAL.SET PF-STATUS 'DMSHOWC'."set titlebar 'DMS'.CREATE OBJECT go_editorEXPORTINGparent = go_editcontainerwordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_positionwordwrap_position = 256max_number_chars = 100000.CALL METHOD go_editor->set_text_as_r3table EXPORTING table = src[].CALL METHOD cl_gui_cfw=>flush.ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0200 INPUT.CASE ok_code.FREE:go_editor,go_editcontainer.LEAVE TO SCREEN 0.ENDCASE.CLEAR ok_code.ENDMODULE.
3.7 在点击事件调用这个函数
DATA: lv_string TYPE string.lv_string = gs_result-ifmsg.CALL FUNCTION 'ZFM_DISPLAY_TEXT'EXPORTINGiv_text = lv_string.
显示结果如下: