‎2008 Apr 02 11:21 AM
Hi All,
Can any one give me the definition and explain me with example how the function module
CALL FUNCTION 'READ_TEXT' can be utilised in SAP scripts.
points will be rewarded.
Thanks in advance,
S.Gangi reddy.
‎2008 Apr 02 11:26 AM
Hi,
see this example
TABLES: PBIM.
* stxh, stxl, stxb - trans tables for text
* ttxit - text on text-ids
* ttxot - Short texts on text objects
* Transaction MD63
SELECT-OPTIONS: S_MATNR FOR PBIM-MATNR,
S_WERKS FOR PBIM-WERKS.
DATA: BEGIN OF HTEXT.
INCLUDE STRUCTURE THEAD.
DATA: END OF HTEXT.
DATA: BEGIN OF LTEXT OCCURS 50.
INCLUDE STRUCTURE TLINE.
DATA: END OF LTEXT.
DATA: BEGIN OF DTEXT OCCURS 50.
DATA: MATNR LIKE PBIM-MATNR.
INCLUDE STRUCTURE TLINE.
DATA: END OF DTEXT.
DATA: TNAME LIKE THEAD-TDNAME.
SELECT * FROM PBIM WHERE WERKS IN S_WERKS.
MOVE PBIM-BDZEI TO TNAME.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
ID = 'PB'
LANGUAGE = 'E'
NAME = TNAME
OBJECT = 'PBPT'
* ARCHIVE_HANDLE = 0
IMPORTING
HEADER = HTEXT
TABLES
LINES = LTEXT
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
LOOP AT LTEXT.
IF LTEXT-TDLINE NE ''.
MOVE LTEXT-TDLINE TO DTEXT-TDLINE.
MOVE PBIM-MATNR TO DTEXT-MATNR.
APPEND DTEXT.
ENDIF.
ENDLOOP.
ENDSELECT.
LOOP AT DTEXT.
WRITE:/ DTEXT-MATNR, DTEXT-TDLINE.
ENDLOOP.
rgds,
bharat.
‎2008 Apr 02 11:26 AM
Hi,
see this example
TABLES: PBIM.
* stxh, stxl, stxb - trans tables for text
* ttxit - text on text-ids
* ttxot - Short texts on text objects
* Transaction MD63
SELECT-OPTIONS: S_MATNR FOR PBIM-MATNR,
S_WERKS FOR PBIM-WERKS.
DATA: BEGIN OF HTEXT.
INCLUDE STRUCTURE THEAD.
DATA: END OF HTEXT.
DATA: BEGIN OF LTEXT OCCURS 50.
INCLUDE STRUCTURE TLINE.
DATA: END OF LTEXT.
DATA: BEGIN OF DTEXT OCCURS 50.
DATA: MATNR LIKE PBIM-MATNR.
INCLUDE STRUCTURE TLINE.
DATA: END OF DTEXT.
DATA: TNAME LIKE THEAD-TDNAME.
SELECT * FROM PBIM WHERE WERKS IN S_WERKS.
MOVE PBIM-BDZEI TO TNAME.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
ID = 'PB'
LANGUAGE = 'E'
NAME = TNAME
OBJECT = 'PBPT'
* ARCHIVE_HANDLE = 0
IMPORTING
HEADER = HTEXT
TABLES
LINES = LTEXT
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
LOOP AT LTEXT.
IF LTEXT-TDLINE NE ''.
MOVE LTEXT-TDLINE TO DTEXT-TDLINE.
MOVE PBIM-MATNR TO DTEXT-MATNR.
APPEND DTEXT.
ENDIF.
ENDLOOP.
ENDSELECT.
LOOP AT DTEXT.
WRITE:/ DTEXT-MATNR, DTEXT-TDLINE.
ENDLOOP.
rgds,
bharat.
‎2008 Apr 02 11:26 AM
Hi GangiReddy,
The FM 'READ_TEXT' is used to read header texts, line item texts, general texts and ect.
Kindly Reward Points If You Found The Reply Helpful,
Cheers,
Chaitanya.
‎2008 Apr 02 11:28 AM
hi,
REPORT YCMTESTE LINE-SIZE 255 MESSAGE-ID TD.
PARAMETERS:
TEXTNAME LIKE THEAD-TDNAME DEFAULT 'SAPSCRIPT-DRUCKERTEST',
FILE LIKE RLGRAP-FILENAME DEFAULT 'C:\temp\'.
DATA: TEXTHEADER LIKE THEAD.
DATA: TEXTLINES LIKE TLINE OCCURS 100 WITH HEADER LINE.
CALL FUNCTION 'READ_TEXT'
EXPORTING NAME = TEXTNAME
LANGUAGE = SY-LANGU
OBJECT = 'TEXT'
ID = 'ST '
IMPORTING HEADER = TEXTHEADER
TABLES LINES = TEXTLINES
EXCEPTIONS OTHERS = 1.
CHECK SY-SUBRC = 0.
CALL FUNCTION 'EXPORT_TEXT'
EXPORTING CODEPAGE = '1133'
FILE = FILE
FORMATWIDTH = 132
FORMAT_TYPE = 'RTF'
HEADER = TEXTHEADER
SSHEET = ' '
WITH_TAB = ' '
TABLES ITF_LINES = TEXTLINES
EXCEPTIONS DOWNLOAD_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_WRITE_ERROR = 3.
CASE SY-SUBRC.
WHEN 1. MESSAGE E815 WITH FILE.
WHEN 2. MESSAGE E811 WITH FILE.
WHEN 3. MESSAGE E814 WITH FILE.
ENDCASE.
WHEN 0. MESSAGE S807 WITH FILE.
118
READ_TEXT
READ_TEXT provides a text for the application program in the specified work areas.
The function module reads the desired text from the text file, the text memory, or the archive. You must fully specify the text using OBJECT, NAME, ID, and LANGUAGE. An internal work area can hold only one text; therefore, generic specifications are not allowed with these options.
After successful reading, the system places header information and text lines into the work areas specified with HEADER and LINES.
If a reference text is used, SAPscript automatically processes the reference chain and provides the text lines found in the text at the end of the chain. If an error occurs, the system leaves the function module and triggers the exception REFERENCE_CHECK.
Hope this helps, Do reward.
‎2008 Apr 02 11:31 AM
Hi Gangi reddy,
That FM is used to Read the Standard text into the Script.
Akshitha.
‎2008 Apr 02 11:37 AM
Hi,
Read_text fm is used to get text from sap and place that text into the our internal table. we get the data in internal table and place this data in sap script..etc.
Ex:
If u want get text written sales order item level. Use the follwing
code:
The Object field what we given in Read_text FM varied from header level and item level.
DATA : name TYPE thead-tdname,
g_tline TYPE TABLE OF tline WITH HEADER LINE,
it_vbap TYPE TABLE OF vbap WITH HEADER LINE.
vbeln = vbak-vbeln.
select * from vbap into
table it_vbap where vbeln = vbeln.
CONCATENATE vbeln it_vbap-posnr INTO name.
CONDENSE name.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'Z001'
language = sy-langu
name = name
object = 'VBBP'
TABLES
lines = g_tline
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 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'FORMAT_TEXTLINES'
EXPORTING
cursor_column = 0
cursor_line = 0
endline = 99999
formatwidth = 45
linewidth = 45
startline = 1
language = sy-langu
IMPORTING
NEW_CURSOR_COLUMN =
NEW_CURSOR_LINE =
TABLES
lines = g_tline
EXCEPTIONS
BOUND_ERROR = 1
OTHERS = 2
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
g_tline : having text data in salesorder item level.
Whatever data we got is not properly formated. U can format the data using the FM:Format_Textlines
The Object field in Read_text FM Stores in table:TTXOB.
U see the function module documentation for the Read_text fm.
Finding parameters to pass in read_text fm:
U can go to va02,
give sales order number,
click on item number,
goto the Texts tab.
One big box is there. Place the cursor and double click
select the Goto menu/ Header .
If select the item Header.
It will shows thew Text name , Language,Text id and Text object.
If it is helpful rewards points
Regards
Pratap.M