Read Standard text SO10 in String

Code snippet in form of class method to read standard text into string.

CLASS yhr_cl_appraisal_wda DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    CLASS-METHODS read_so10_to_str
      IMPORTING
        !iv_id         TYPE thead-tdid DEFAULT 'ST'
        !iv_name       TYPE thead-tdname
        !iv_langu      TYPE thead-tdspras DEFAULT sy-langu
        !iv_object     TYPE thead-tdobject DEFAULT 'TEXT'
      RETURNING
        VALUE(rv_text) TYPE string .
ENDCLASS.

CLASS YHR_CL_APPRAISAL_WDA IMPLEMENTATION.

* <SIGNATURE>---------------------------------------------------------------------------+
* | Static Public Method YHR_CL_APPRAISAL_WDA=>READ_SO10_TO_STR
* +-------------------------------------------------------------------------------------+
* | [--->] IV_ID                          TYPE        THEAD-TDID (default ='ST')
* | [--->] IV_NAME                        TYPE        THEAD-TDNAME
* | [--->] IV_LANGU                       TYPE        THEAD-TDSPRAS (default =SY-LANGU)
* | [--->] IV_OBJECT                      TYPE        THEAD-TDOBJECT (default ='TEXT')
* | [<-()] RV_TEXT                        TYPE        STRING
* +--------------------------------------------------------------------------</SIGNATURE>
  METHOD read_so10_to_str.

    DATA : lt_lines TYPE idmx_di_t_tline .

    CLEAR rv_text .

    CALL FUNCTION 'READ_TEXT'
      EXPORTING
        id                      = iv_id
        language                = iv_langu
        name                    = iv_name
        object                  = iv_object
      TABLES
        lines                   = lt_lines
      EXCEPTIONS
        id                      = 1
        language                = 2
        name                    = 3
        not_found               = 4
        object                  = 5
        reference_check         = 6
        wrong_access_to_archive = 7.

    IF sy-subrc <> 0 .
      RETURN .
    ENDIF.

    CALL FUNCTION 'IDMX_DI_TLINE_INTO_STRING'
      EXPORTING
        it_tline       = lt_lines
      IMPORTING
        ev_text_string = rv_text.

  ENDMETHOD.
ENDCLASS.

Leave a Reply