Sunday, 21 July 2013

'SAVE_TEXT' Function Module in SAP ABAP

The purpose of this Function Module 'SAVE_TEXT' is to save text/data to a Text Object/Type in SAP.

The Structure of above FM looks like below:

CALL FUNCTION 'SAVE_TEXT'
  EXPORTING
*   CLIENT                = SY-MANDT
    header                =
*   INSERT                = ' '
*   SAVEMODE_DIRECT       = ' '
*   OWNER_SPECIFIED       = ' '
*   LOCAL_CAT             = ' '
* IMPORTING
*   FUNCTION              =
*   NEWHEADER             =
  tables
    lines                 =
* EXCEPTIONS
*   ID                    = 1
*   LANGUAGE              = 2
*   NAME                  = 3
*   OBJECT                = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.


Description:

Mandatory fields for above FM are 'header' which is of type structure 'THEAD' .

To this structure or Workarea we have to pass these fields as mandatory: TDOBJECT, TDNAME, TDID, TDSPRAS.

See below post to find out above attributes for a given Text Type/Object.

"How to find the Properties/Attributes of a Text Object/Type in SAP ABAP"

Another Mandatory field is Tables: 'LINES' which is of type 'TLINE' having fields TDFORMAT and TDLINE.

The value for field TDFORMAT describes how the line is going to be stored in SAP.
Say: 
* -> for Default Parameter
= -> Continuous Text
Pass the text to be stored to the field TDLINE.
Note: Character size for TDLINE is only 132 characters, so if the string size is more than 132 characters split the string and add it to the next line by using TDFORMAT as '=" Continuous text.

Related Links: 



No comments:

Post a Comment