ABAP/4 Example Code: SAVE_TEXT

You can create and save long text by apply function module ’SAVE_TEXT’.

Example: We will create program for create standard text. The created text will be contained text ’Test Create Text’. you can input name of long text on selection screen. After you run this program, you can check the output of program in transaction SO10 (Standard Text).


DATA: GW_THEAD LIKE THEAD,
      IT_LINE TYPE TABLE OF TLINE WITH HEADER LINE.
PARAMETERS: P_TXTNAM LIKE THEAD-TDNAME.
START-OF-SELECTION.
  GW_THEAD-TDNAME   = P_TXTNAM.
  GW_THEAD-TDID     = ’ST’.
  GW_THEAD-TDSPRAS  = SY-LANGU.
  GW_THEAD-TDOBJECT = ’TEXT’.
  IT_LINE-TDFORMAT = ’*’.
  IT_LINE-TDLINE   = ’Test Create Text’.
  APPEND IT_LINE.
  CALL FUNCTION ’SAVE_TEXT’
    EXPORTING
*     CLIENT                = SY-MANDT
      HEADER                = GW_THEAD
*     INSERT                = ’ ’
*     SAVEMODE_DIRECT       = ’ ’
*     OWNER_SPECIFIED       = ’ ’
*     LOCAL_CAT             = ’ ’
*   IMPORTING
*     FUNCTION              =
*     NEWHEADER             =
    TABLES
      LINES                 = IT_LINE
    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.

Post new comment