Code snippet in form of class method to read standard text into string.
class zcl_long_text definition
public
final
create public .
public section.
class-methods read_longtext_to_string
importing
!id type thead-tdid default 'ST'
!name type thead-tdname
!language type thead-tdspras default sy-langu
!object type thead-tdobject default 'TEXT'
!fallback_to_english type boolean default abap_true
returning
value(rv_text_string) type string .
protected section.
private section.
endclass.
class zcl_long_text implementation.
* <SIGNATURE>---------------------------------------------------------+
* | Static Public Method ZCL_LONG_TEXT=>READ_LONGTEXT_TO_STRING
* +-------------------------------------------------------------------+
* | [--->] ID TYPE THEAD-TDID (default ='ST')
* | [--->] NAME TYPE THEAD-TDNAME
* | [--->] LANGUAGE TYPE THEAD-TDSPRAS (default =SY-LANGU)
* | [--->] OBJECT TYPE THEAD-TDOBJECT (default ='TEXT')
* | [--->] FALLBACK_TO_ENGLISH TYPE BOOLEAN (default =ABAP_TRUE)
* | [<-()] RV_TEXT_STRING TYPE STRING
* +---------------------------------------------------------</SIGNATURE>
method read_longtext_to_string.
data : text_lines type idmx_di_t_tline .
clear rv_text_string .
call function 'READ_TEXT'
exporting
id = id
language = language
name = name
object = object
tables
lines = text_lines
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8.
if sy-subrc <> 0.
"fallback to english if text does not exist in specified language
if language <> cl_dpr_document_text_services=>sc_langu_english and
fallback_to_english = abap_true .
rv_text_string = read_longtext_to_string(
exporting
id = id
name = name
language = cl_dpr_document_text_services=>sc_langu_english
object = object ).
endif.
else.
call function 'IDMX_DI_TLINE_INTO_STRING'
exporting
it_tline = text_lines
importing
ev_text_string = rv_text_string.
endif.
endmethod.
endclass.
Thanks for sharing, (: