In today’s tutorial, I want to show
you how to use the READ_TEXT function module to read SAP long text. Every text
in SAP has its own ID and NAME, by passing these parameters into the READ_TEXT
function, we can get all the text in the SAP long text object.
Here’s how to do it, for example
we’ll be using long text from Sales Order.
1. Execute tcode VA02 and enter the
Sales Order number.
2. Press enter to display the Sales
Order data. Choose GoTo -> Header -> Texts
3. Double click the “Header Note”
text and enter the long text in the text editor.
4. Click CTRL+S to save the Sales
Order data.
5. Now that we need to get the “ID”,
“NAME” and “OBJECT” of the text object to be used as the input parameters of
READ_TEXT function module, to get this information, you can execute VA02 or
VA03 and enter the Sales Order number again.
Choose GoTo -> Header ->
Texts
6. Now double click inside the long
text editor.
7. Choose Goto -> Header.
8. On the next window screen, you
will see all the parameters required for the READ_TEXT function. (Name,
Language, ID, Object)
9. Now let’s get the text using
ABAP, open your ABAP editor (SE38), copy this code below.
"A
sample code to use READ_TEXT FM
data:
BEGIN OF header OCCURS 0,
ld_txt1(163),
ld_txt2(163),
ld_txt3(163),
END OF header.
DATA: li_lines LIKE STANDARD TABLE OF tline
WITH HEADER LINE,
ID like THEAD-TDID,
TNAME LIKE THEAD-TDNAME,
TDOBJECT like THEAD-TDOBJECT.
ID = '0001'.
TNAME = '1820000009'.
TDOBJECT = 'VBBK'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id
= id
language = sy-langu
name
= TNAME
object
= TDOBJECT
TABLES
lines
= li_lines.
READ TABLE li_lines INDEX 1.
IF sy-subrc = 0.
header-ld_txt1 = li_lines-tdline.
ENDIF.
READ TABLE li_lines INDEX 2.
IF sy-subrc = 0.
header-ld_txt2 = li_lines-tdline.
ENDIF.
READ TABLE li_lines INDEX 3.
IF sy-subrc = 0.
header-ld_txt3 = li_lines-tdline.
ENDIF.
WRITE:/ header-ld_txt1.
WRITE:/ header-ld_txt2.
WRITE:/ header-ld_txt3.
10. Now execute the program (F8),
you will see the long text from the header note text object.
Tidak ada komentar:
Posting Komentar