Showing posts with label Report Program. Show all posts
Showing posts with label Report Program. Show all posts

Thursday, March 19, 2020

READ_TEXT Function Module call in program In SAP ABAP.


READ_TEXT Function Module Use in SAP.


READ_TEXT Function Module.

DATA:lv_output_text TYPE char50.

PERFORM f_read_text USING 'ABCD'            " Text ID
                          'E'               " Text Language
                          '12345678'        " Text Name
                          'VBBK'            " Text Object
                 CHANGING lv_output_text.   " Return Text

*Display the standard text.
WRITE lv_output_text.

*----------------------------------------------------------------------*
FORM f_read_text USING pi_textid      TYPE thead-tdid
                       pi_language    TYPE thead-tdspras
                       pi_name        TYPE thead-tdname
                       pi_object      TYPE thead-tdobject
              CHANGING pc_output_text TYPE char50.
*----------------------------------------------------------------------*
* Data Declarations.
* Internal Tables.
  DATA:
    lt_lines TYPE STANDARD TABLE OF tline.

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

* Clearing field to be on the safer side.
  CLEAR pc_output_text.

  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      id                             = pi_textid
      language                  = pi_language
      name                        = pi_name
      object                  = pi_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
      OTHERS                  = 8.

  IF sy-subrc EQ 0.

*  Fetch the text from the FM table.
    READ TABLE lt_lines
    ASSIGNING <fs_lines>
    INDEX 1.

    IF sy-subrc EQ 0.

*    Standard text Details.
      pc_output_text = <fs_lines>-tdline.

    ENDIF.

  ENDIF.

ENDFORM.