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 and Save Text

Former Member
0 Likes
7,098

hi all

please give me an example for

Save_Text

Read_Text

<b>in brief and simple language.

please dont provide me links and help material for this.</b>

regards

ravish

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,198

Hi Vivek,

Following is the code for READ_TEXT

Data:

zz_lines like tline occurs 10 with header line,

zz_text(132),

zz_name like THEAD-TDNAME.

clear: zz_text,zz_insp_text,zz_name,zz_lines[].

zz_name = w_matnr.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

id = 'PRUE'

language = 'E'

name = zz_name

object = 'MATERIAL'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

tables

lines = zz_lines

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.

loop at zz_lines.

zz_text = zz_lines-tdline.

concatenate zz_text zz_insp_text into zz_insp_text separated by space.

endloop.

Regards,

Nikhil Moghe

6 REPLIES 6
Read only

Former Member
0 Likes
2,198

Hi,

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'LTQM'

LANGUAGE = T_QMFE-KZMLA

NAME = L_TEXTNAME

OBJECT = 'QMFE'

IMPORTING

HEADER = TABLE_HEADER

TABLES

LINES = TABLE_LINES

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

HEADER = thead

SAVEMODE_DIRECT = 'X'

insert = ' '

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

LINES = it_lines

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

OBJECT = 4

OTHERS = 5

Satya

Read only

Former Member
0 Likes
2,199

Hi Vivek,

Following is the code for READ_TEXT

Data:

zz_lines like tline occurs 10 with header line,

zz_text(132),

zz_name like THEAD-TDNAME.

clear: zz_text,zz_insp_text,zz_name,zz_lines[].

zz_name = w_matnr.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

id = 'PRUE'

language = 'E'

name = zz_name

object = 'MATERIAL'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

tables

lines = zz_lines

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.

loop at zz_lines.

zz_text = zz_lines-tdline.

concatenate zz_text zz_insp_text into zz_insp_text separated by space.

endloop.

Regards,

Nikhil Moghe

Read only

Former Member
2,198

Save Text

To re-transfer texts from the internal work areas to the text file, use the function module SAVE_TEXT.The application program does not know whether the text is new or a changed version of an existing text. To be able to find this out, the program must read the text file first.If a text exists, the transferred text lines overwrite the old version. If it does not exist, the system creates it. If you know from the beginning that the text is new, you can suppress this read process using the parameter INSERT and thus improve performance.A text you want to store in the text file must consist of at least one line whose paragraph format or line contents is unequal to SPACE. Otherwise the system automatically deletes this text from the text file.Changes to the text file are valid at once if the text object of the text is set to direct storage. If it is set to storage in update task, the text changes are temporarily stored in the text memory. The function module COMMIT_WORK then transfers them to the log file, from where they are updated with the next COMMIT WORK.The function module SAVE_TEXT can handle only texts that are eventually stored in the text file, that is, text with storage mode 'D' or 'V'.

Read_Text

You can process texts only if they are stored in the internal work areas of the program. Therefore, you must first transfer a text into the work areas.To transfer the text header of a text into the specified structure and the text lines into the specified lines table, use the function module READ_TEXT.Usually, the system reads a text from the text file. However, for texts with storage in the update task, the system first looks into the text memory to see whether it contains a currently processed version. If so, the system reads this version of the text into the work area, otherwise the text version from the text file.To read a text version stored in the archive, use the parameter ARCHIVE_HANDLE.If the desired text does not exist, READ_TEXT ends with the exception NOT_FOUND. The contents of the work areas for text header and text lines are then undefined. To be able to use these work areas for another text, you must first initialize them with INIT_TEXT.

The function module READ_TEXT also handles text references. It reads the reference chain to its end and supplies the text lines of this text in the lines table as well.

Read only

Former Member
0 Likes
2,198

Hi,

in order to copy your text you need save_text fm.

the prameters are similar to what you passs it to READ_TEXT.

here you have to pass it to THEAD all the parms...

thead-tdid = 'KOPF'.

thead-tdobject = 'AUFK'.

THEAD-TDSPRAS = 'EN'.

thead-tdname = '050000020633761'.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

HEADER = thead

SAVEMODE_DIRECT = 'X'

insert = ' '

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

LINES = it_lines

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

OBJECT = 4

OTHERS = 5

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Read_text:

DATA: BEGIN OF T_DET OCCURS 0,

QMNUM LIKE QMEL-QMNUM,

MBLNR LIKE QMEL-MBLNR,

LOSMENGE LIKE QALS-LOSMENGE,

END OF T_DET.

DATA:F_TDOBJECT LIKE THEAD-TDOBJECT,

F_TDNAME LIKE THEAD-TDNAME,

F_TDID LIKE THEAD-TDID,

ITAB_LINES LIKE TLINE OCCURS 0 WITH HEADER LINE.

DATA:BEGIN OF ITAB OCCURS 10,

DESC(72),

END OF ITAB.

SELECT QMNUM REFNUM QMDAT QMTXT OBJNR QMGRP QMCOD FROM QMEL

INTO CORRESPONDING FIELDS OF TABLE T_DET

WHERE QMNUM IN S_QMNUM AND

QMART IN S_QMART AND

QMDAT IN S_QMDAT.

LOOP AT T_DET.

F_TDID = 'LTQM'.

F_TDNAME = T_DET-QMNUM.

F_TDOBJECT = 'QMEL'.

F_TDID = 'LTQM'.

F_TDNAME = T_DET-QMNUM.

F_TDOBJECT = 'QMEL'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = F_TDID

LANGUAGE = SY-LANGU

NAME = F_TDNAME

OBJECT = F_TDOBJECT

TABLES

LINES = ITAB_LINES

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

DESCRIBE TABLE ITAB_LINES LINES SY-TFILL.

IF SY-TFILL > 0.

LOOP AT ITAB_LINES.

ITAB-QMNUM = T_DET-QMNUM.

ITAB-DESC = ITAB_LINES-TDLINE.

APPEND ITAB.

CLEAR ITAB.

ENDLOOP.

ENDIF.

ENDLOOP.

Regards

Read only

Former Member
0 Likes
2,198

Hi,

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.

Save_text

SAVE_TEXT writes a text module back to the text file or the text memory, depending on the storage mode of the corresponding text object.

You can use this module either to change existing texts or to create new texts. If you know for sure that the text is new, use the parameter INSERT to indicate this. The system then does not have to read the text first, which improves the performance of the function module.

If the lines table passed with the function module is empty, the system deletes the text from the text file.

Read only

Former Member
0 Likes
2,198

hi nikil and Satayanarayana

thnx for ur instant reply. i have run ur code. its givin error. please tell me wat data is to be declared..

<b>please provide me the executable code not the one with errors</b>

regards

ravish