cancel
Showing results for 
Search instead for 
Did you mean: 

Can't catch the text of a text editor since first time

Former Member
0 Kudos

I have the following code. In the screen I have a text Editor, a button and a textbox I want that the text in the text editor appear in the textbox when I push the botton, but only when I click the button a second time it appers the actual text. The first time I click the button it's blank the text box and the first time I click the button when the editor has text before it appears the original text and not the actual until the second time I push the button.

Do you know what's happening?

Thanx in advance

&----


*& Report ZPRUEBAPANT

*&

&----


*&

*&

&----


REPORT zpruebapant MESSAGE-ID 02.

DATA nombre LIKE pa0001-ename.

DATA container TYPE REF TO cl_gui_custom_container.

DATA editor TYPE REF TO cl_gui_textedit.

DATA texto TYPE string.

START-OF-SELECTION.

CALL SCREEN '100'.

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

IF sy-ucomm EQ 'GRABAR'.

CALL METHOD editor->get_textstream

IMPORTING

text = texto.

MOVE texto TO nombre.

ENDIF.

IF sy-ucomm EQ 'EXIT'.

LEAVE PROGRAM.

ENDIF.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS '200'.

IF container IS INITIAL OR editor IS INITIAL.

CREATE OBJECT container

EXPORTING container_name = 'CONTAINER'.

CREATE OBJECT editor

EXPORTING parent = container.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Not sure what the problem is, I can't recreate it. This is working for me. I have defined the green check icon in the gui status as ENTER. Also, I create my gui status as 100 instead of 200.





report zpruebapant message-id 02.

<b>types: text(100) type c.</b>


data nombre like pa0001-ename.
data container type ref to cl_gui_custom_container.
data editor type ref to cl_gui_textedit.
data texto type string.

<b>data: itext type standard table of text.
data: xtext type text.</b>
start-of-selection.
  call screen '100'.


*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0100 input.

  if sy-ucomm eq 'ENTER'.

<b>    call method editor->get_text_as_stream
    importing
    text = itext.

    read table itext into xtext index 1.
    move xtext to nombre.</b>
  endif.

  if sy-ucomm eq 'EXIT'.
    leave program.
  endif.


endmodule. 


*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0100 output.

<b>  set pf-status '100'.</b>

  if container is initial or editor is initial.
    create object container
    exporting container_name = 'CONTAINER'.

    create object editor
    exporting parent = container.
  endif.

endmodule. 

Regards,

Rich Heilman

Answers (1)

Answers (1)

Former Member
0 Kudos

Pls do this in your user_command module and see if it works....

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

IF sy-ucomm EQ 'GRABAR'.

CALL METHOD editor->get_textstream

IMPORTING

text = texto.

<b> CALL METHOD cl_gui_cfw=>flush

EXCEPTIONS

cntl_system_error = 1

cntl_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.</b>

MOVE texto TO nombre.

ENDIF.

IF sy-ucomm EQ 'EXIT'.

LEAVE PROGRAM.

ENDIF.

ENDMODULE. " USER_COMMAND_0100 INPUT