Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to position the cursor at the end of the text with EDIT_TEXT?

Hello, it wanted to ask to them if somebody could make work the module of function EDIT_TEXT so that it positions the cursor at the end of the text that is visualizing in the text editor. In the documentation it says that passing a ' X' to him in the field scrollend of the parameter Control is obtained that operation. Nevertheless, I did this and the cursor continues appearing at the beginning of the text that visualizes.

Somebody could help me please?

Regards,

Gabriel

PD: The code that I use is the following one:

FORM f_ingresar_comentarios.

DATA: l_action,

l_result LIKE itcer,

l_pedido LIKE thead-tdname,

li_coment_save LIKE i_comentarios OCCURS 0,

li_coment_aux LIKE i_comentarios OCCURS 0 WITH HEADER LINE,

l_lines TYPE i,

l_lines_save TYPE i,

l_lines_insert TYPE i,

l_index TYPE i,

l_index_aux TYPE i,

l_insert,

lwa_control LIKE itced.

CLEAR: l_action.

CLEAR i_comentarios.

REFRESH: i_comentarios,

li_coment_save,

li_coment_aux.

l_pedido = v_pedido.

  • Leemos el texto si es que existe

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = v_id_text

language = sy-langu

name = l_pedido

object = c_ekko

IMPORTING

header = wa_cabecera

TABLES

lines = i_comentarios "Lineas de texto leídas

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.

  • Armamos la cabecera por primer comentario para el pedido

CLEAR wa_cabecera.

wa_cabecera-tdobject = c_ekko. "Objeto en tabla TTXID

wa_cabecera-tdname = v_pedido. "Nro de pedido

wa_cabecera-tdid = v_id_text. "ID en tabla TTXID

wa_cabecera-tdspras = sy-langu. "Lenguaje

wa_cabecera-tdlinesize = 70.

ENDIF.

  • Salva comentarios originales

li_coment_save[] = i_comentarios[].

lwa_control-scrollend = c_x. " c_x = 'X'

  • Abre el editor de texto

CALL FUNCTION 'EDIT_TEXT'

EXPORTING

header = wa_cabecera

save = space

control = lwa_control

IMPORTING

newheader = wa_cabecera

function = l_action

RESULT = l_result

TABLES

lines = i_comentarios

EXCEPTIONS

object = 1

id = 2

language = 3

name = 4

linesize = 5.

  • Si cambio los comentarios, actualiza comentarios

CASE l_action.

WHEN c_unchanged.

WHEN c_delete.

WHEN c_update OR

c_insert.

  • Obtiene cantidad de lineas de comentarios originales y modificados

DESCRIBE TABLE li_coment_save LINES l_lines_save.

DESCRIBE TABLE i_comentarios LINES l_lines.

  • Si se insertaron lineas...

IF l_lines > l_lines_save.

  • Calcula cantidad de lineas a insertar para luego calcular valor de

  • indice a partir del cual insertar los nuevos comentarios

l_lines_insert = l_lines - l_lines_save.

l_index = ( l_lines - l_lines_insert ) + 1.

  • Controla que al menos una de las lineas insertadas sea diferente de

  • blanco

l_index_aux = l_lines.

l_insert = c_n.

DO l_lines_insert TIMES.

READ TABLE i_comentarios INDEX l_index_aux.

IF sy-subrc = 0 AND

i_comentarios-tdline <> space.

l_insert = c_s.

EXIT.

ENDIF.

l_index_aux = l_index_aux - 1.

ENDDO.

IF l_insert = c_s.

  • Carga comentarios originales y agrega lineas insertadas

li_coment_aux[] = li_coment_save[].

APPEND LINES OF i_comentarios

FROM l_index

TO l_lines

TO li_coment_aux.

  • Setea variable para indicar actualizacion de comentarios.

v_comentario = 'S'.

  • Agrega usuario y fecha del comentario

CONCATENATE sy-uname

'-'

sy-datum

INTO li_coment_aux-tdline

SEPARATED BY space.

li_coment_aux-tdformat = '*'.

APPEND li_coment_aux.

  • Grabamos el texto

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

  • client = sy-mandt

header = wa_cabecera

  • savemode_direct = c_x

IMPORTING

newheader = wa_cabecera

TABLES

lines = li_coment_aux

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.

ENDIF.

ENDIF.

ENDCASE.

ENDFORM. " f_ingresar_comentarios

In addition, I made another program simpler that it uses the same functions and also have the same problem:

*&----


*

*& Report Y_GVA_TEXT *

*& *

*&----


*

*& *

*& *

*&----


*

REPORT y_gva_text .

DATA: wa_cabecera LIKE thead,

i_comentarios LIKE tline OCCURS 0 WITH HEADER LINE.

DATA: l_action,

v_comentario,

l_result LIKE itcer,

v_pedido LIKE thead-tdname VALUE '3',

l_pedido LIKE thead-tdname,

c_a05 LIKE thead-tdid VALUE 'A05',

c_ekko LIKE stxh-tdobject VALUE 'EKKO',

l_lines LIKE sy-tabix,

lwa_control LIKE itced.

CONSTANTS: c_x VALUE 'X',

update VALUE 'U', "Langtext verändert

insert VALUE 'I', "Langtext eingefügt

delete VALUE 'D', "Langtext gelöscht

modify VALUE 'M', "Kein Langtext, Inlinezeile veränd.

unchanged VALUE ' '.

CLEAR: l_action.

CLEAR i_comentarios.

REFRESH i_comentarios.

  • Leemos el texto si es que existe

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = c_a05

language = sy-langu

name = v_pedido

object = c_ekko

IMPORTING

header = wa_cabecera

TABLES

lines = i_comentarios "Lineas de texto leídas

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 'I' NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  • Armamos las cabecera para mostrar los comentarios

CLEAR wa_cabecera.

wa_cabecera-tdobject = c_ekko. "Objeto en tabla TTXID

wa_cabecera-tdname = v_pedido. "Nro de pedido

wa_cabecera-tdid = c_a05. "ID en tabla TTXID

wa_cabecera-tdspras = sy-langu. "Lenguaje

wa_cabecera-tdlinesize = 70.

ENDIF.

lwa_control-noendlines = c_x.

lwa_control-scrollend = c_x.

  • Abre el editor de texto

CALL FUNCTION 'EDIT_TEXT'

EXPORTING

header = wa_cabecera

save = space

control = lwa_control

IMPORTING

newheader = wa_cabecera

function = l_action

RESULT = l_result

TABLES

lines = i_comentarios

EXCEPTIONS

object = 1

id = 2

language = 3

name = 4

linesize = 5.

  • Si cambio los comentarios, actualiza comentarios

CASE l_action.

WHEN unchanged.

WHEN delete.

WHEN update OR

insert.

  • Agrega usuario y fecha del comentario

CONCATENATE sy-uname

'-'

sy-datum

INTO i_comentarios-tdline

SEPARATED BY space.

i_comentarios-tdformat = '*'.

APPEND i_comentarios.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

header = wa_cabecera

IMPORTING

newheader = wa_cabecera

TABLES

lines = i_comentarios.

ENDCASE.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question