Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  program editing →  Dynamic Program Editing →  text element 

INSERT TEXTPOOL

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


INSERT TEXTPOOL prog FROM itab LANGUAGE lang. 

Effect

This statement places the contents of table itab into the Repository as a text pool of the language specified in lang for the ABAP program specified in prog. If a text pool for the specified language already exists, all of its text elements are overwritten. Otherwise, a new text pool is created for this language.

For prog, you must specify a flat character-type data object that contains the name of the program of the text elements to be read; it can be uppercase or lowercase.

For lang, you must specify a character-type, flat data object that contains a language key no longer than 1 character, whose value must be in the column SPRAS of database table T002. If an invalid language is specified in lang, no text pool is created or overwritten. If lang contains a blank, the behavior is undefined.

The internal table itab can be any table type and its row type must correspond to the TEXTPOOL structure in the ABAP Dictionary. If a non-existent program is specified in prog, no text pool is created or overwritten.

In the internal table itab, the ENTRY column can contain the texts of the text symbols, the selection texts, the list headers, and the title for the program attributes; in the LENGTH column, you can specify the corresponding lengths. The individual text elements are identified using the entries in the columns ID and KEY, whose valid values are shown in the table for READ TEXTPOOL.

If the columns ID or KEY of the internal table contain invalid values or if duplicate entries exist, an inconsistent text pool is created. If the internal table is empty, all text elements of an existing text pool are deleted or a text pool without text elements is created. If the length specified in LENGTH is shorter than the text length in ENTRY, it is automatically set to the text length in the text pool.

Return Values

The INSERT TEXTPOOL statement always sets sy-subrc to the value 0.


Notes

  • The specification of the text length in LENGTH defines the maximum length of the text element that is available in the ABAP Workbench when translating the text pool into other languages and should be set sufficiently large.
  • In the case of selection texts, there must be eight blanks before the actual text in ENTRY. If you want to use a selection text from the Dictionary, then the first character of ENTRY must be a "D".
  • The INSERT TEXTPOOL statement should be used with caution, because it completely overwrites existing text pools.

Example

Attempt at a translation tool for text elements. The text pools of a source and a target language are imported into internal tables and, for each text element of the source language, a selection screen is displayed as a translation template. After the translation has been completed, the text pool of the target language is overwritten with the correspondingly changed internal table.

PARAMETERS: program TYPE sy-repid, 
            langu1  TYPE spras DEFAULT sy-langu, 
            langu2  TYPE spras. 

SELECTION-SCREEN BEGIN OF SCREEN 500 AS WINDOW. 
SELECTION-SCREEN COMMENT /1(83) source. 
SELECTION-SCREEN BEGIN OF LINE. 
PARAMETERS target TYPE textpool-entry. 
SELECTION-SCREEN END OF LINE. 
SELECTION-SCREEN END OF SCREEN 500. 

DATA: text1 TYPE SORTED TABLE OF textpool 
                 WITH UNIQUE KEY id KEY, 
      text2 TYPE SORTED TABLE OF textpool 
                 WITH UNIQUE KEY id KEY, 
      wa1   TYPE textpool, 
      wa2   TYPE textpool. 

READ TEXTPOOL program: INTO text1 LANGUAGE langu1, 
                      INTO text2 LANGUAGE langu2. 

LOOP AT text1 INTO wa1. 
  CLEAR wa2. 
  READ TABLE text2 INTO wa2 
             WITH TABLE KEY id  = wa1-id 
                            key = wa1-key. 
  source = wa1-entry. 
  target = wa2-entry. 
  CALL SELECTION-SCREEN 500 STARTING AT 1 1. 
  IF sy-subrc = 0. 
    IF target IS NOT INITIAL. 
      wa2-id = wa1-id. 
      wa2-key = wa1-key. 
      wa2-entry = target. 
      wa2-length = wa1-length. 
      DELETE TABLE text2 
             WITH TABLE KEY id  = wa1-id 
                            key = wa1-key. 
      INSERT wa2 INTO TABLE text2. 
    ENDIF. 
  ELSE. 
    EXIT. 
  ENDIF. 
ENDLOOP. 

INSERT TEXTPOOL program FROM text2 LANGUAGE langu2. 

Continue

INSERT TEXTPOOL - Internal addition