ABAP save_text 使用 快速开始
业务背景,保存MIR7的注释字段
PERFORM frm_save_note USING lv_invno lv_year <fs_itab>-zfpdz.
*&---------------------------------------------------------------------*
*& Form frm_save_note
*&---------------------------------------------------------------------*
*& 保存发票地址文本
*&---------------------------------------------------------------------*
*& --> <FS_ITAB>_ZFPDZ
*&---------------------------------------------------------------------*
FORM frm_save_note USING p_invno
p_year
p_zfpdz.
DATA:ls_rbkp TYPE mrm_rbkpv.
DATA:lv_ind TYPE i VALUE '0'.
DATA:lv_time TYPE mseg-menge.
DATA:lv_len TYPE mseg-menge.
"DATA:ls_txt TYPE TDSTXLLINE.
DATA:ls_txt TYPE tline.
DATA:lt_tnote TYPE TABLE OF tline.
DATA: ls_header TYPE thead .
DATA: gt_ltxts TYPE STANDARD TABLE OF tline .
DATA: lw_ltxt TYPE tline .
lv_len = lv_time = lv_ind = 0.
lv_len = strlen( p_zfpdz ).
lv_time = ceil( lv_len / 132 ).
DO lv_time TIMES.
"ls_tline-format_col = '/'.
IF lv_len >= 132.
ls_txt-tdline = p_zfpdz+lv_ind(132).
ELSE.
ls_txt-tdline = p_zfpdz+lv_ind(lv_len).
ENDIF.
lv_len = lv_len - 132.
lv_ind = lv_ind + 132.
ls_txt-tdformat = '*'.
APPEND ls_txt TO lt_tnote.
CLEAR ls_txt.
ENDDO.
CLEAR ls_header .
ls_header-tdobject = 'RBKP' .
ls_header-tdtitle = 'Note' .
ls_header-tdid = '0001'.
ls_header-tdspras = sy-langu.
CONCATENATE p_invno p_year INTO ls_header-tdname.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = ls_header
SAVEMODE_DIRECT = 'X'
TABLES
lines = lt_tnote.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
COMMIT WORK AND WAIT.
ENDIF.
ENDFORM.