Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

read_text fm

Former Member
0 Likes
1,245

hi all,

I am using read_text fm and i am using the syntax below to capture the text in j1if .

TEXT_ID = '0001'.

*concatenate j_1iexchdr-rdoc j_1iexchdr-ryear into thead-tdname.

THEAD-TDNAME = temp.

PERFORM READ_TEXT.

LOOP AT TLINES.

IF TLINES-TDLINE NE SPACE.

J_1IREGSET-J_1IRGDESC = TLINES-TDLINE.

ENDIF.

ENDLOOP.

FORM READ_TEXT.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = TEXT_ID

LANGUAGE = SY-LANGU

NAME = THEAD-TDNAME

OBJECT = 'J1IF'

ARCHIVE_HANDLE = 0

IMPORTING

HEADER = THEAD

TABLES

LINES = TLINES

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

ENDFORM.

but i am not getting the text written in that . can anybody give me a solution

thanks & regards

magesh

hi all,

I am using read_text fm and i am using the syntax below to capture the text in j1if .

TEXT_ID = '0001'.

*concatenate j_1iexchdr-rdoc j_1iexchdr-ryear into thead-tdname.

THEAD-TDNAME = temp.

PERFORM READ_TEXT.

LOOP AT TLINES.

IF TLINES-TDLINE NE SPACE.

J_1IREGSET-J_1IRGDESC = TLINES-TDLINE.

ENDIF.

ENDLOOP.

FORM READ_TEXT.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = TEXT_ID

LANGUAGE = SY-LANGU

NAME = THEAD-TDNAME

OBJECT = 'J1IF'

ARCHIVE_HANDLE = 0

IMPORTING

HEADER = THEAD

TABLES

LINES = TLINES

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

ENDFORM.

but i am not getting the text written in that . can anybody give me a solution

thanks & regards

magesh

4 REPLIES 4
Read only

Former Member
0 Likes
893

Hi Magesh,

Problem might be lying in passing the values. Try to manually pass the value to STXH or corresponding text table.

Else. Go to the transaction where you write the long text see its header and put those excat values. Check SY-LANGU also.

Reward if useful!

Read only

Former Member
0 Likes
893

hi

good

go throgh this ans use accordingly.

All the long text can be retrieve using this method.

You have to used the READ_TEXT functions to read the SAP long text. e.g. Sales Order, Purchase Order Item text etc.

To check your long text header, go into the long text. Click Goto -> Header

Example of READ_TEXT functions reading tables PBIM - Independent requirements for material.

REPORT ZTEXT .

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.

What is the purpose of READ_TEXT functuion module and how to get text id value in this scenario(TDID)?

In business process, there are so many transactions that take place in every day, like purchase orders, sales orders, delivery, gooodsmovement etc... SAP provided a feature to maintain some text descriptions.

Read_Text Function module is used to retrieve the text for a particular objects.

To find the Text id these are the following steps. Let us take an example of Billing document Header text.

1. goto VF03, enter Billing doc Number

2. from menuselect Goto>Header-->header Text..... New window will be displayed

3. select the Header Text. here you can see all the text.

4. click on the TEXT (which you want to know the Text id) , then press log ICON (you can find in bottom right of the text window) it looks like a rolled paper.

5. in the Next window you will find Text Name. Text ID, Language. etc...

thanks

mrutyun^

Read only

Former Member
0 Likes
893

You don't need to give THEAD-TDNAME = temp. anf pass 'EN' in some variable and replace sy-langu from that variable. Also see what is the return code in debugging mode to find ou which exception has raised.

Thanks,

Shweta

Read only

0 Likes
893

Hi

It seems you are not passing ther NAME parameter correctly to the fun module

Double click on the text

will take you to text editor

from menu GOTO-> HEADER

see the parammeters for NAME<ID<OBJECT and LANG

observe the NAME field correctly and notedown it may be the combination of one or two fields

so accordinly you have to pass it

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.

Function call:

CALL FUNCTION 'READ_TEXT'

EXPORTING CLIENT = SY-MANDT

OBJECT = ?...

NAME = ?...

ID = ?...

LANGUAGE = ?...

ARCHIVE_HANDLE = 0

IMPORTING HEADER =

TABLES LINES = ?...

EXCEPTIONS ID =

LANGUAGE =

NAME =

NOT_FOUND =

OBJECT =

REFERENCE_CHECK =

WRONG_ACCESS_TO_ARCHIVE =

Export parameters:

CLIENT

Specify the client under which the text is stored. If you omit this parameter, the system uses the current client as default.

Reference field: SY-MANDT

Default value: SY-MANDT

OBJECT

Enter the name of the text object to which the text is allocated. Table TTXOB contains the valid objects.

Reference field: THEAD-TDOBJECT

NAME

Enter the name of the text module. The name may be up to 70 characters long. Its internal structure depends on the text object used.

Reference field: THEAD-TDNAME

ID

Enter the text ID of the text module. Table TTXID contains the valid text IDs, depending on the text object.

Reference field: THEAD-TDID

LANGUAGE

Enter the language key of the text module. The system accepts only languages that are defined in table T002.

Reference field: THEAD-TDSPRAS

ARCHIVE_HANDLE

If you want to read the text from the archive, you must enter a handle here. The system uses it to access the archive. You can create the handle using the function module ACHIVE_OPEN_FOR_READ.

The value '0' indicates that you do not want to read the text from the archive.

Reference field: SY-TABIX

Default value: 0

Import parameters:

HEADER

If the system finds the desired text, it returns the text header in this parameter.

Structure: THEAD

Table parameters:

LINES

The table contains all text lines that belong to the text read.

Structure: TLINE

Exceptions:

ID

The text ID specified in the parameter ID does not exist in table TTXID. It must be defined there together with the object of the text module.

LANGUAGE

The parameter LANGUAGE contains a language key that does not exist in table T002.

NAME

The parameter NAME contains the name of a text module that does not correspond to the SAPscript conventions.

Possible errors:

The field contains only blanks.

The field contains the invalid characters ‘*’ or ‘,’.

OBJECT

The parameter OBJECT contains the name of a text object that does not exist in table TTXOB.

NOT_FOUND

The system did not find the specified text module.

REFERENCE_CHECK

The text module to be read has no text lines of its own but refers to the lines of another text module. This reference chain can include several levels. For the current text, the chain is interrupted, that is, one of the text modules referred to in the chain no longer exists.

WRONG_ACCESS_ TO_ARCHIVE

The exception WRONG_ACCESS_TO_ARCHIVE is triggered if an archive is accessed using an incorrect or non-existing archive handle or an incorrect mode (that is, read if the archive is open for writing or vice versa).

Reward points for useful Answers

Regards

Anji