Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

text editor not getting cleared

syed_ibrahim5
Active Participant
0 Likes
2,285

hi experts,

i am doing a module pool to create a gate pass and i when i press create it will go to the next screen .in that screen i have created a texteditor for entering the purpose . if i enter the purpose and if i dont save and click back it goes to the previous screen and then if i again click create the text i entered in the texteditor still is retained. how can i clear that?. will be thankful if some one could help.below is the code i have used in PBO.


IF G_EDITOR IS INITIAL.
    CREATE OBJECT g_editor_container
        EXPORTING
            container_name = 'TEXTEDITOR1'
        EXCEPTIONS
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5.
    CREATE OBJECT g_editor
      EXPORTING
         parent = g_editor_container
         wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
         wordwrap_to_linebreak_mode = cl_gui_textedit=>true
      EXCEPTIONS
          others = 1.
endif.

with thanks in advance,

syed

Edited by: SYED_ibbu on Nov 30, 2010 5:08 AM

1 ACCEPTED SOLUTION
Read only

Former Member
1,904

Syed try it from PBO module it wil work,

If not I wil giv you an Example program

Let me know the status , after u tried..

16 REPLIES 16
Read only

GauthamV
Active Contributor
0 Likes
1,904

Use this logic.


    CALL METHOD cl_gui_cfw=>flush
      EXCEPTIONS
        OTHERS = 1.

Read only

0 Likes
1,904

hi,

thanks gautam for the rply.But i had used flush part that i removed while posting before creating the container.but it is not still getting cleared.


    CALL METHOD cl_gui_cfw=>flush
      EXCEPTIONS
        CNTL_SYSTEM_ERROR = 1
        CNTL_ERROR        = 2.

    CREATE OBJECT g_editor_container
        EXPORTING
            container_name = 'TEXTEDITOR1'
        EXCEPTIONS
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5.
    IF sy-subrc NE 0.
    ENDIF.

with thanks in advance,

syed

Read only

GauthamV
Active Contributor
0 Likes
1,904

Try this.

CALL METHOD cl_gui_cfw=>flush

EXCEPTIONS

OTHERS = 1.

Clear G_editor.

Read only

0 Likes
1,904

thanks again gautam,

i tried with clear g_editor .still no luck.i am posting the whole code for a better picture.


"in PBO
 g_repid = sy-repid.
  IF G_EDITOR IS INITIAL.
    CALL METHOD cl_gui_cfw=>flush
      EXCEPTIONS
        CNTL_SYSTEM_ERROR = 1
        CNTL_ERROR        = 2.
***
    CLEAR G_EDITOR_CONTAINER.CLEAR G_EDITOR.
    CREATE OBJECT g_editor_container
        EXPORTING
            container_name = 'TEXTEDITOR1'
        EXCEPTIONS
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5.
    IF sy-subrc NE 0.
    ENDIF.

    CREATE OBJECT g_editor
      EXPORTING
         parent = g_editor_container
         wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
         wordwrap_to_linebreak_mode = cl_gui_textedit=>true
      EXCEPTIONS
          others = 1.
    IF sy-subrc NE 0.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = g_repid
          txt2  = space
          txt1  = text-001.
    ENDIF.

    IF ( L_FUNC = C_DISPLAY OR L_FUNC = C_CHANGE ).
      REFRESH G_MYTABLE.CLEAR W_MYTABLELINE.
      SELECT SINGLE PURPOSE PURPOSE1 PURPOSE2 PURPOSE3 INTO (TEXT,TEXT1,TEXT2,TEXT3) FROM ZGATE_PASS_CFL WHERE PASS_NO = ZST_GP_CFL-PASS_NO.
      W_MYTABLELINE-LINE = TEXT. APPEND W_MYTABLELINE TO G_MYTABLE.
      W_MYTABLELINE-LINE = TEXT1. APPEND W_MYTABLELINE TO G_MYTABLE.
      W_MYTABLELINE-LINE = TEXT2. APPEND W_MYTABLELINE TO G_MYTABLE.
      W_MYTABLELINE-LINE = TEXT3. APPEND W_MYTABLELINE TO G_MYTABLE.

      CALL METHOD g_editor->SET_text_as_r3table
        EXPORTING
          table  = g_mytable
        EXCEPTIONS
          OTHERS = 1.
      IF sy-subrc NE 0.
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel = g_repid
            txt2  = space
            txt1  = text-003.
      ENDIF.
    ENDIF.

  ENDIF.
  IF L_FUNC = C_DISPLAY OR C_APPROVE2 IS NOT INITIAL.
    CALL METHOD g_editor->set_focus
      EXPORTING
        control = g_editor.
    call method G_editor->SET_READONLY_MODE( '1' ).
  ELSEIF L_FUNC = C_CHANGE AND C_APPROVE2 IS INITIAL.
    CALL METHOD g_editor->set_focus
      EXPORTING
        control = g_editor.
    call method G_editor->SET_READONLY_MODE( '0' ).
  ENDIF.
" in PAI
IF MENGE_FL IS NOT INITIAL AND ( L_FUNC = C_CREATE OR L_FUNC = C_CHANGE ).
    CALL METHOD g_editor->get_text_as_r3table
      IMPORTING
        table  = g_mytable
      EXCEPTIONS
        OTHERS = 1.
    IF sy-subrc NE 0.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = g_repid
          txt2  = space
          txt1  = text-003.
    ENDIF.
    LOOP AT G_MYTABLE INTO W_MYTABLELINE.
      IF SY-TABIX = 1.
        TEXT = W_MYTABLELINE-LINE.
      ELSEIF SY-TABIX = 2.
        TEXT1 = W_MYTABLELINE-LINE.
      ELSEIF SY-TABIX = 3.
        TEXT2 = W_MYTABLELINE-LINE.
      ELSEIF SY-TABIX = 4.
        TEXT3 = W_MYTABLELINE-LINE.
      ENDIF.
    ENDLOOP.
*      READ TABLE G_MYTABLE INTO W_MYTABLELINE INDEX 1.
*      TEXT = W_MYTABLELINE-LINE.

    CALL METHOD cl_gui_cfw=>flush
      EXCEPTIONS
        OTHERS = 1.
    IF sy-subrc NE 0.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = g_repid
          txt2  = space
          txt1  = text-002.
    ENDIF.
CLEAR g_ok_code.

with thanks in advance,

syed

Read only

0 Likes
1,904

Hi Syed ,

Please try this code below :

"in PBO

g_repid = sy-repid.

IF G_EDITOR IS NOT INITIAL.

CALL METHOD cl_gui_cfw=>flush

EXCEPTIONS

CNTL_SYSTEM_ERROR = 1

CNTL_ERROR = 2.

This should work ... the reason it is not working currently is in PBO of screen the system checkes the editor is initial or not ..

if it is not initial then only it should call the flush .

Regards,

Ranjita

Read only

syed_ibrahim5
Active Participant
0 Likes
1,904

Edited by: SYED_ibbu on Nov 30, 2010 6:02 AM

Edited by: SYED_ibbu on Nov 30, 2010 6:02 AM

Read only

0 Likes
1,904

Call the method free before initilizing the object for editor,

CALL METHOD g_editor->free( ).

CLEAR g_editor.

Read only

0 Likes
1,904

thanks benu,

i have used it as below.it is dumping as access not possible due to null refrence.


   call method g_editor->free( ).
    clear g_editor.
    CREATE OBJECT g_editor
      EXPORTING
         parent = g_editor_container
         wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
         wordwrap_to_linebreak_mode = cl_gui_textedit=>true
      EXCEPTIONS
          others = 1.
    IF sy-subrc NE 0.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = g_repid
          txt2  = space
          txt1  = text-001.
    ENDIF.

with thanks in advance,

syed

Read only

Former Member
0 Likes
1,904

HI SYED,

try this code from 'PBO' then it will work.


CALL METHOD cpreg->delete_text.   "    cpreg : container name 

Edited by: Murthy.SAP on Nov 30, 2010 6:20 AM

Read only

0 Likes
1,904

thanks murthy,

when i tried his it is showing the error as 'delete_text is unknown or protected or private'

with thanks,

syed

Read only

0 Likes
1,904

thanks murthy,

when i tried his it is showing the error as 'delete_text is unknown or protected or private'

with thanks,

syed

Read only

Former Member
1,905

Syed try it from PBO module it wil work,

If not I wil giv you an Example program

Let me know the status , after u tried..

Read only

0 Likes
1,904

tahnks again,

i tried it from PBO only.below is the code.


"PBO
    CALL METHOD cl_gui_cfw=>flush
      EXCEPTIONS
        CNTL_SYSTEM_ERROR = 1
        CNTL_ERROR        = 2.
    CLEAR G_EDITOR_CONTAINER.CLEAR G_EDITOR.
CALL METHOD g_editor_container->delete_text.

    CREATE OBJECT g_editor_container
        EXPORTING
            container_name = 'TEXTEDITOR1'
        EXCEPTIONS
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5.
    IF sy-subrc NE 0.
*      add your handling
    ENDIF.

thanks in advance,

syed

Read only

0 Likes
1,904

SYED

This is an example program which iam using in my current project

Surely it wil work check it out..


" IN PBO

DATA : editor_container TYPE REF TO  cl_gui_custom_container,
       cpreg TYPE REF TO cl_gui_textedit.

 IF cpreg IS INITIAL.

    CREATE OBJECT editor_container
      EXPORTING
        container_name = 'CPREG'.

    CREATE OBJECT cpreg
      EXPORTING
        parent                     = editor_container
        wordwrap_mode        = cl_gui_textedit=>wordwrap_at_fixed_position
        wordwrap_position     = 45
        wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

    CALL METHOD cpreg->set_toolbar_mode
      EXPORTING
        toolbar_mode = cl_gui_textedit=>false.

    CALL METHOD cpreg->set_statusbar_mode
      EXPORTING
        statusbar_mode = cl_gui_textedit=>false.

  ENDIF.

"THIS IS ALSO IN PBO

  IF sy-ucomm = 'CLEAR'.
       PERFORM clear_data.
  ENDIF.

"FORM CLEAR_DATA...

FORM clear_data .
    CALL METHOD cpreg->delete_text.
ENDFORM.

Let me know the Status

Read only

0 Likes
1,904

The dump is due to the null reference for the object. You should have cleared the object in PAI event.

So, before freeing the object try calling the free() method.

Regards,

Benu

Read only

0 Likes
1,904

hi murthy,

thanks a lot.it worked.and thanks everyone for helping me out.

with thanks,

syed