Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

I did work on storing and retreiving Texts about a year back but recently again I used it but It was bit different this time as I used standard text and text Object/ text ID both. In this blog basically I am sharing what I have done to save and retreive texts.

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.