Thursday, July 23, 2020

Read Long Text In SAP ABAP Programming Langauge

Read Long (READ_TEXT)Text In SAP ABAP Programming Langaug.

READ_TEXT function module call for long text.

**********************************
DATA:lv_output_text TYPE char222.
DATA: tname TYPE thead-tdname."TYPE thead-tdname.
*----------------------------------------------------------------------*
* Data Declarations.
* Internal Tables.
  DATA:
    lt_lines TYPE STANDARD TABLE OF tline,
    pc_output_text(222) TYPE c.

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

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


  CONCATENATE gs_item-rbukrs gs_item-belnr gs_item-gjahr gs_item-buzei INTO tname.

                  CALL FUNCTION 'READ_TEXT'
                    EXPORTING
                      client                        = sy-mandt
                      id                            = lc_id
                      language                      = sy-langu
                      name                          = tname
                      object                        = lc_object
*                     ARCHIVE_HANDLE                = 0
*                     LOCAL_CAT                     = ' '
*                   IMPORTING
*                     HEADER                        =
*                     OLD_LINE_COUNTER              =
                    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.
      pc_output_text = <fs_lines>-tdline.
    ENDIF.
  ENDIF.
ENDIF.

No comments:

Post a Comment