Application Development 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: 

Retrieving entire text from text editor

Former Member
0 Kudos

Currently, I have the codes for retrieving text the user typed from text editor but it is retrieving line by line. How am I suppose to retrieve the entire text instead of retrieving line by line?

Please provide me codes examples to allow me understand better.

5 REPLIES 5

Former Member
0 Kudos

Hi Juz

Hope it will help you.

reward if help.

The usage of texts in SAP is very generic and it is used for all entities and documents . For example the texts exist for Vendor master / CUstomer master and in Sales as well as Purchase orders at item and header level .The long texts are used to maintain certain informative texts which the user wants to have and major benefit is that the additional long texts can be provided to the user through functional customising in IMG - SPRO you do not need any ABAP exit or enhancement for this.

Now you can maintain these texts programatically using the FM :

CREATE_TEXT

SAVE_TEXT

while you can read the existing texts using the FM ' READ_TEXT' .

For this purpose you can also go thru this blog /people/deepak.bhalla/blog/2005/01/24/storing-and-retreiving-of-texts .

I am giving extract from same below :

Please let me know if you need anything further on this .

********************************************************************

There are following ways of storing text in SAP.

1. Using Text Object and Text ID

2. Using Standard text with placeholders

1. Using Text Object and Text ID:

I am assuming that we already have a data in structure required by function module save_text for tables paramenter lines.

1. Use Transaction SE75 to create Text Object and Text ID.

2. Choose first radio button Text Object and ID's

3. Click at create. It will create Text Object.

4. Create Text ID for Text Object.

Now this created Text ID and Text Object can be used to Save and Retreive texts using following function module.

CALL FUNCTION 'ZSAVE_READ_TEXT'

EXPORTING

Save_read_indicator = 'X'

header = p_header

TABLES

lines = p_line.

Exporting parameter Save_read_inidcator type char1. default 'X' for Save.

Header should be of type thead

Tables parameter lines should be of type tline.

Header values should be populated as follows.

p_header-tdobject = name of the text object created.

p_header-tdname = It can be any Unique name.

p_header-tdid = name of text id created.

p_header-tdspras = sy-langu.

p_header-tdtitle = title of text.

Table P_lines will contain all data that is to be saved.It may be through Text control.

call function module save_text as follows to Save text.

If save_read_indicator = 'X'.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

client = sy-mandt

header = p_header

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

lines = p_line

  • EXCEPTIONS

  • ID = 1

  • LANGUAGE = 2

  • NAME = 3

  • OBJECT = 4

  • OTHERS = 5.

ELSE.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = TEXT_ID

LANGUAGE = SY-LANGU

NAME = Same as TDNAME in Save_text

OBJECT = TEXT_OBJECT

TABLES

LINES = LI_LINE

  • EXCEPTIONS

  • ID = 1

  • LANGUAGE = 2

  • NAME = 3

  • NOT_FOUND = 4

  • OBJECT = 5

  • REFERENCE_CHECK = 6

  • WRONG_ACCESS_TO_ARCHIVE = 7

  • OTHERS = 8.

Endif.

2. Using Standard text with placeholders

Here I am assuming that for all placeholders we will have value availble.

1. Maintain standard text with place holder using transaction SO10.

for example :

Dear &1,

Your purchase requisition &2 was approved on &3 .

2. Use following following function module to read Standard text.

CALL FUNCTION 'READ_STDTEXT'

EXPORTING

id = 'ST'

language = sy-langu

name = name of standard text

  • USE_AUX_LANGUAGE = ' '

  • USE_THRUCLIENT = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

lines = p_std_text

  • EXCEPTIONS

  • ID = 1

  • LANGUAGE = 2

  • NAME = 3

  • NOT_FOUND = 4

  • REFERENCE_CHECK = 5

  • OTHERS = 6.

3. Use following code to replace Placeholders returned in table p_std_text.

Loop at p_std_text.

SEARCH p_std_text-tdline FOR '&1'.

IF sy-subrc = 0.

REPLACE '&1' WITH p_name INTO p_std_text-tdline.

ENDIF.

SEARCH p_std_text-tdline FOR '&2'.

IF sy-subrc = 0.

REPLACE '&2' WITH p_name INTO p_std_text-tdline.

ENDIF.

SEARCH p_std_text-tdline FOR '&3'.

IF sy-subrc = 0.

REPLACE '&3' WITH p_name INTO p_std_text-tdline.

ENDIF.

MODIFY p_std_text.

Endloop.[/nobr]

Former Member
0 Kudos

For the READ_TEXT FM codes, can someone explain to me what type of parameters I should put for this 2 line of codes?

-


name = "Text name

object = "text object

-


Where should I get text name and text object?

0 Kudos

Hi,

All long texts are stored in table STXH. Check the text name and text object in the table.

While using READ_TEXT pass the language key also. The required fields are TDID, TDNAME, TDOBJECT and TDSPRAS.

Regards,

Subramanian

0 Kudos

How can i apply read_text with my text editor called (GEN_CODE)?

Any codes example?

Former Member
0 Kudos

Hi juzme,

I have also got the same requirement like to create a text editor in a screen painter and save the text that is entered in the text editor. I have seen your thread in SDN can you please share the code how to save the data that is entered in the text editor.....

Thks