The function module ‘READ_TEXT’ can be used to retrieve different long text values (or text objects) in different SAP document. All long text in SAP can be retrieved using this function module.



Getting the TEXT ID in a sales document:

    Sales order long text can be viewed in VA03 through the menu ‘Goto > Header’.
    Select one of the text and click on the icon  image003 (found at the bottom of the text)
    On the next window, we will get the appropriate information to pass to the function module ‘READ_TEXT’ to retrieve the appropriate text.

Note: Text can be edited using the transaction SO10 and all the text are available in the tables STXH (header) and STXL (item for the text).



Function Module Documentation:

    CLIENT : Text modules are client-dependent. The client is therefore part of the key. Valid values for this field are defined in table T000.
    ID : The text ID defines a further subdivision of the texts for a text object. Valid values for the text ID are defined in table TTXID.
    LANGUAGE : Text modules or layout sets can exist in several languages. The language is therefore part of the key. Valid values for this field are defined in table T002.
    NAME : The text name can be up to 70 characters long. The structure depends on the text object used. All characters except for ‘*’ and ‘&’ are valid.
    OBJECT : The text object is part of the text key and assigns the text module to a specific application object. Valid text objects are defined in table TTXOB.
    HEADER : The text header contains information which describes a text module, for example short text, user who created the text, user who last changed it, etc. The structure of the header is defined in table THEAD.
    LINES : The table contains all text lines belonging to a text module. The line structure is defined in table TLINE. The line contents are stored in ITF format.


*Internal tables and structures:
DATA:
  lt_text               TYPE STANDARD TABLE OF tline.

*Local Variables:
 DATA:
   lv_tdname_partly     TYPE thead-tdname,
   lv_tdname            TYPE thead-tdname.

*Local Constants:
 CONSTANTS:
   lc_id                TYPE thead-tdid       VALUE '0001',
   lc_object            TYPE thead-tdobject   VALUE 'DOC_ITEM'.

*Local Field Symbols:
 FIELD-SYMBOLS:
   <fs_text>            TYPE tline.

*Refreshing internal tables.
 REFRESH:
   lt_text.

*Clearing of variables.
 CLEAR:
   lv_tdname_partly,
   lv_tdname.

* Concatenate FI Document Number, Fiscal Year and the Item Number
* without space. Please note that the item number is the line item

* number.
  lv_tdname_partly = '01234567892015001'.

* Concatenate the Company Code and (FI Document Number, Fiscal Year and the Item Number)
* seperated by space.
  CONCATENATE '123'             " Company Code
              lv_tdname_partly  " Concatenated Number of 'FI Document Number', 'Fiscal Year' and 'Line Item' (without space).
         INTO lv_tdname         " Fully concatenated number
 SEPARATED BY space.            " Seperated by space.



*---------------------------------------*
*READ TEXT FUNCTION MODULE              *
*---------------------------------------*
*This function module will retreive the value of the long text
*from appropriate database tables. Please note that when retrieving
*the text, the connection language(SY-LANGU) was used. Thus, if a user
*logs in 'French', the long text value might be different for a user
*which logs in 'English'.
 CALL FUNCTION 'READ_TEXT'
   EXPORTING
     client                  = sy-mandt     "Client Number
     id                      = lc_id        "Line Item of the FI document in which the text is stored
     language                = sy-langu     "Language
     name                    = lv_tdname    "For FI: Concatenation of the company code document and the year
     object                  = lc_object    "Document item
   TABLES
     lines                   = lt_text      "The long text will be returned in the following internal table
   EXCEPTIONS
     id                      = 1
     language                = 2
     name                    = 3
     not_found               = 4
     object                  = 5
     reference_check         = 6
     wrong_access_to_archive = 7
     OTHERS                  = 8.

*If value found, proceed with populating the column.
 IF sy-subrc EQ 0.

*  Read the first line of the internal table return
*  by the function module. This internal table will
*  contains the appropriate text.
   READ TABLE lt_text
   ASSIGNING <fs_text>
   INDEX 1.

   IF sy-subrc EQ 0.

*   Write the long text.
    WRITE <fs_text>-tdline.

   ENDIF.

 ENDIF.



Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Consultant
Contact : serkurumsal@yandex.com