Start of Content Area

Function documentationSetting and Getting Text Positions  Locate the document in its SAP Library structure

There are two ways of accessing text positions. You can either use a line and position within the line, or the absolute character index. Character index means that all of the characters in the text are sequentially numbered.

The main difference is in the way the data passed to the control (as a table) is visualized. If you are using automatic line breaks in the textedit control, the line numbers in the table may not be the same as the line numbers in the control. The same applies, of course, to positions within a line. You define the behavior of the line break in the constructor (for further information, refer to CONSTRUCTOR).

The difference is particularly apparent when you set the line break to WORDWRAP_AT_WINDOWBORDER (automatic line break when the edge of the window is reached). If the user changes the size of the SAPgui and the control container can also be resized, the size of the textedit control will change. If the user makes the SAPgui window smaller, the textedit control will become narrower. Consequently, lines containing words that collide with the window border are automatically split. So even without the user entering any data, the lines and positions within a line are no longer the same as those stored in the internal table at the backend.

It is possible to create a similar example for the line break behavior using WORDWRAP_AT_FIXED_POSITION.

CautionIf you need a direct correspondence between a position in the internal table and a position in the textedit control, you should, because of the behavior described above, use the character index.

Access Using Line and Position Numbers

Line and position numbers in a line begin at 1, so the first character in a text is at line 1, position 1.

Lines and position numbers outside the text area have a logical value. If a number is less than 1, it is set to 1. If it is greater than the number of lines or positions, it is set to the number of the greatest existing line or position.

Getting Text Positions

Setting Text Positions

GET_FIRST_VISIBLE_LINE

SET_FIRST_VISIBLE_LINE

GET_SELECTION_POS

SET_SELECTION_POS

GO_TO_LINE

 
 

SELECT_LINES

 

SET_SELECTION_POS_IN_LINE

Access Using the Character Index

The character index starts at 0. Position zero is the position before the first character. Information about the text position is independent of the line break behavior (see above).

Getting Text Positions

Setting Text Positions

GET_SELECTION_INDEXES

SET_SELECTION_INDEXES