SAP Function Module - SAVE_TEXT - Sample Program.
SAVE_TEXT function module writes a text module to the text file or text memory, depending on the specific text object.
This function module can be used to change existing texts and to create new texts. If it is clear that it is a new text, this can be specified via the parameter INSERT. The result is better performance as a test read is not performed.
Sample Program On SAVE_TEXT Using Subroutines:
DATA : gt_head TYPE TABLE OF thead,
gwa_head TYPE thead,
gt_tlines TYPE TABLE OF tline,
gwa_tlines TYPE tline.
PERFORM prepare_save_text USING 'VBBK' lv_vbeln '0001' lv_text.
************Sub Routine*****************
FORM prepare_save_text USING p_tdobject p_tdname p_tdid p_tdline.
CHECK p_tdline IS NOT INITIAL.
REFRESH: gt_tlines.
CLEAR: gwa_tlines.
gwa_head-tdobject = p_tdobject.
gwa_head-tdname = p_tdname.
gwa_head-tdid = p_tdid.
gwa_head-tdspras = sy-langu.
gwa_tlines-tdformat = '*'.
gwa_tlines-tdline = p_tdline.
APPEND gwa_tlines TO gt_tlines.
CLEAR: gwa_tlines.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = gwa_head
insert = 'X'
savemode_direct = 'X'
TABLES
lines = gt_tlines
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.