2011 Feb 25 8:35 AM
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.
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.
2011 Feb 25 8:56 AM
Hello
Currently even though they are having multiple lines it is concatenated and sent back as a single line. IN order to preserve the lines make the following changes,
1) Change the type of exporting parameter "Text" from char2000 to "FMLINES".
2) Change the below piece of code from,
LOOP AT TEXTLINES.
CONCATENATE TEXT TEXTLINES into TEXT SEPARATED BY space.
ENDLOOP.
To,
Text[ ] = Textlines[ ].
Regards
Ranganath
2011 Feb 25 10:37 AM
Hi Ranganath,
I made changes as you proposed.
FUNCTION ZRFC_READ_TEXT.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(CLIENT) LIKE SY-MANDT DEFAULT SY-MANDT
*" VALUE(ID) LIKE THEAD-TDID
*" VALUE(LANGUAGE) LIKE THEAD-TDSPRAS
*" VALUE(NAME) LIKE THEAD-TDNAME
*" VALUE(OBJECT) LIKE THEAD-TDOBJECT
*" VALUE(ARCHIVE_HANDLE) LIKE SY-TABIX DEFAULT 0
*" EXPORTING
*" VALUE(TEXT) TYPE FMLINES
*" TABLES
*" LINES STRUCTURE TLINE
*"----------------------------------------------------------------------
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.
TEXT[ ] = TEXTLINES[ ].
ENDFUNCTION.
I am getting following error now:
Statement "TEXT[" is not defined. Check your spelling.
2011 Feb 25 10:43 AM
Please remove the extra space between '[' and ']', so it should look like
TEXT[] = TEXTLINES[].
Regards
Ranganath
2011 Feb 25 10:47 AM
Thanks, minute a posted I realized that [] insted of [ ] works.
Thanks Ranganath!!!
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |