前言
用户想在ALV上编辑长文本,但是ALV只有128个字符肯定是不够用的,所以需要用一个长文本编辑器来输入,本来想自己写的,发现有标准的函数,还挺好用的
代码
在用户双击ALV字段时,触发下述form,分别以修改/显示模式弹窗长文本编辑器
*&---------------------------------------------------------------------*
*& Form frm_click_stkt1
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> PV_SELFIELD_TABINDEX
*&---------------------------------------------------------------------*
FORM frm_click_stkt1 USING pv_index.DATA: lv_mode TYPE c,lv_objname TYPE thead-tdname,lt_note TYPE TABLE OF tdline,lt_lines TYPE TABLE OF tline.DATA: ls_header TYPE thead.READ TABLE gt_output INTO gs_output INDEX pv_index.IF gs_output-status = TEXT-005.lv_mode = 'X'. " 编辑状态ENDIF." 读取长文本IF gs_output-stlty = 'K'."销售BOMlv_objname = gs_output-vbeln && '/' && gs_output-vbpos && '/' && gs_output-matnr.ELSE.lv_objname = gs_output-matnr && '/' && gs_output-werks && '/' && gs_output-stlal.ENDIF.CLEAR gt_complaint_text[].PERFORM frm_get_long_text TABLES gt_complaint_text USING gc_text_obj 'Z001' lv_objname ." 赋值到长文本编辑器lt_note[] = VALUE #( FOR lw_text IN gt_complaint_text( lw_text-tdline ) ).CALL FUNCTION 'TXW_TEXTNOTE_EDIT'EXPORTINGedit_mode = lv_modeTABLESt_txwnote = lt_note." 需要修改长文本IF lv_mode = 'X'.ls_header = VALUE #( tdobject = gc_text_objtdname = lv_objnametdspras = sy-langutdid = 'Z001' ).lt_lines = VALUE #( FOR lw_note IN lt_note( tdline = lw_notetdformat = '*' ) ).CALL FUNCTION 'SAVE_TEXT'EXPORTINGclient = sy-mandtheader = ls_headersavemode_direct = 'X'TABLESlines = lt_linesEXCEPTIONSid = 1language = 2name = 3object = 4OTHERS = 5.READ TABLE gt_output ASSIGNING <fs_output> INDEX pv_index.<fs_output>-stkt1 = concat_lines_of( table = lt_note sep = '' ).ENDIF.ENDFORM.
挺好用的,不错不错