Skip to Content
0
Former Member
Feb 25, 2011 at 08:35 AM

RFC enabling READ_TEXT FM

208 Views

I am not ABAP programer, I access SAP RFC functions from PHP in order to make reports. However I need TEXT_READ to be RFC enabled. I found ABAP code which I used to RFC enable TEXT_READ by calling it. However, in case there are multiple lines function is returning only the first line. Would someone be so kind and review the function code (below) and tell me what needs to be corrected in order for this function to return all lines (not concatenated or concatenated)?

FUNCTION ZRFC_READ_TEXT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(ID) TYPE  THEAD-TDID
*"     REFERENCE(LANGUAGE) TYPE  THEAD-TDSPRAS
*"     REFERENCE(NAME) TYPE  THEAD-TDNAME
*"     REFERENCE(OBJECT) TYPE  THEAD-TDOBJECT
*"  EXPORTING
*"     REFERENCE(TEXT) TYPE  CHAR2000
*"----------------------------------------------------------------------

DATA BEGIN OF TEXTHEADER.
        INCLUDE STRUCTURE THEAD.
DATA END OF TEXTHEADER.

DATA BEGIN OF TEXTLINES OCCURS 10.
        INCLUDE STRUCTURE TLINE.
DATA END OF TEXTLINES.

CLEAR TEXTHEADER.

data: l_name type TDOBNAME."TR
l_name = name."TR
CALL FUNCTION 'READ_TEXT'
       EXPORTING
            OBJECT                  = OBJECT
            ID                      = ID
            LANGUAGE                = LANGUAGE
            NAME                    = l_NAME "TR
       IMPORTING
            HEADER                  = TEXTHEADER
       TABLES
            LINES                   = TEXTLINES
       EXCEPTIONS
            ID                      = 1
            LANGUAGE                = 2
            NAME                    = 3
            NOT_FOUND               = 4
            OBJECT                  = 5
            REFERENCE_CHECK         = 6
            WRONG_ACCESS_TO_ARCHIVE = 7
            OTHERS                  = 8.

LOOP AT TEXTLINES.
   CONCATENATE TEXT TEXTLINES into TEXT SEPARATED BY space.
ENDLOOP.


ENDFUNCTION.