cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with method GET_READONLY_MODE of class CL_GUI_TEXTEDIT

0 Kudos

I have issue with using this method in my test program.

I want to toggle the readonly mode via button for the Textbox. I am using GET_READONLY_MODE protected method in my test program to get the current readonly_mode of the textbox. Here i am not able to get the readonly_mode status in the variable.But i am getting the readonly_mode status as soon as this FM 'POPUP_TO_CONFIRM' triggered. I am not able to figure it out what and where i am doing mistake. please check the code and help me out is there i am missing flushing the buffer memory or anything i have to clear or there is some mistake in code.

DATA: l_v_read   TYPE i,

      l_v_read1  TYPE i,

      l_v_editor TYPE REF TO cl_gui_textedit,


CLASS lcl_class DEFINITION INHERITING FROM cl_gui_textedit.

  PUBLIC SECTION.

    METHODS:

      set_readonly_mode_lcl IMPORTING VALUE(lcl_sreadonly) TYPE i,

      get_readonly_mode_lcl ."EXPORTING VALUE(lcl_readonly) TYPE i.

ENDCLASS.


CLASS lcl_class IMPLEMENTATION.

  METHOD get_readonly_mode_lcl.

    CALL METHOD l_v_editor->get_readonly_mode IMPORTING readonly_mode = l_v_read.

    "lcl_readonly = l_v_read.

    "CLEAR l_v_read.

  ENDMETHOD.

  METHOD set_readonly_mode_lcl.

    CALL METHOD l_v_editor->set_readonly_mode EXPORTING readonly_mode = lcl_sreadonly .

  ENDMETHOD.

ENDCLASS.



DATA: l_v_lcl     TYPE REF TO lcl_class,

      l_container TYPE REF TO cl_gui_custom_container.


START-OF-SELECTION.

  CALL SCREEN 100.


MODULE status_0100 OUTPUT.

  SET PF-STATUS 'PF1'.

*  SET TITLEBAR 'xxx'.

  CREATE OBJECT l_container

    EXPORTING

      container_name              = 'L_CUST'

    EXCEPTIONS

      cntl_error                  = 1

      cntl_system_error           = 2

      create_error                = 3

      lifetime_error              = 4

      lifetime_dynpro_dynpro_link = 5

      OTHERS                      = 6.

  IF sy-subrc IS INITIAL.

    CREATE OBJECT l_v_editor

      EXPORTING

        wordwrap_mode              = cl_gui_textedit=>wordwrap_at_fixed_position

        wordwrap_position          = 256

        wordwrap_to_linebreak_mode = cl_gui_textedit=>true

        parent                     = l_container

        max_number_chars           = 100000.

    IF sy-subrc IS NOT INITIAL.

      MESSAGE 'TEXT EDIT BOX NOT CREATED' TYPE 'I'.

    ENDIF.

  ENDIF.



  CALL METHOD l_v_editor->set_readonly_mode

    EXPORTING

      readonly_mode = 1.



  CALL METHOD cl_gui_cfw=>flush.

  IF sy-subrc IS NOT INITIAL.

    MESSAGE 'ERROR IN FLUSH' TYPE 'I'.

  ENDIF.



MODULE user_command_0100 INPUT.

  DATA: l_v_get TYPE i,

        l_v_set TYPE i.

  DATA: ok_code TYPE sy-ucomm.

  CASE sy-ucomm.

    WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.

      LEAVE PROGRAM.

  ENDCASE.

  CASE sy-ucomm.

    WHEN 'BUT'.

      CREATE OBJECT l_v_lcl

      EXPORTING

      Parent = l_container.

      CALL METHOD l_v_lcl->get_readonly_mode_lcl.

" Here after calling method readonly_mode status i am not able to get it into the variable.
"Tried with Importing the value also but no help.
"if i will remove this FM then GET_READONLY_METHOD is not giving any value

      DATA: l_v_ans TYPE sychar01.

      CALL FUNCTION 'POPUP_TO_CONFIRM'

        EXPORTING

          titlebar              = 'CONFIRMATION'

          text_question         = 'DO YOU WANT TO CHANGE?'

          text_button_1         = 'YES'

          text_button_2         = 'NO'

          default_button        = '1'

          display_cancel_button = 'X'

          start_column          = 25

          start_row             = 6

        IMPORTING

          answer                = l_v_ans

        EXCEPTIONS

          text_not_found        = 1

          OTHERS                = 2.

"As soon as this FM triggers the value is coming in the variable.
"EX.
"if present Textbox readonly_mode is 1. then l_v_read is updating with value 1 or opposite.

      IF sy-subrc IS INITIAL.

        CASE l_v_ans.

          WHEN '1'.

            IF l_v_read = 1.

              l_v_set = 0.

            ELSE.

              l_v_set = 1.

            ENDIF.

            CALL METHOD l_v_lcl->set_readonly_mode_lcl

              EXPORTING

                lcl_sreadonly = l_v_set.

            CLEAR: l_v_get,

                   l_v_set.

          WHEN '2'.

            LEAVE PROGRAM.

          WHEN '3'.

            LEAVE PROGRAM.

        ENDCASE.

      ENDIF.

    CALL METHOD cl_gui_cfw=>flush.

    IF sy-subrc IS NOT INITIAL.

      MESSAGE 'ERROR IN FLUSH' TYPE 'I'.

    ENDIF.

ENDCASE.

ENDMODULE.

Please give me solution or is there anyother way to achieve this then please advice me.

Accepted Solutions (1)

Accepted Solutions (1)

raymond_giuseppi
Active Contributor

Did you try to call the method "cl_gui_cfw=>flush" after the call of GET_READONLY_MODE, the pop-up FM trigger a dynpro PAI/PBO cycle so synchronize itself the automation queue.

  • As soon as your program performs well, try to minimize the number of such call as they create new RFC connection with the SAPgui.
  • Why don't you memorize the readonly status in somme attribute of one of your classes?
0 Kudos

I tried to use cl_gui_cfw=>flush before and after the call of GET_READONLY_MODE but no luck.

if i remove the FM from code then GET_READONLY_MODE is not at all working.

I will try to create attribute and check with it. still if you have any other solution please give me

Thank you

0 Kudos

Hey I was able to get the status into attribute 🙂 Before the FM only.

Thank you so much.

Answers (1)

Answers (1)

Sandra_Rossi
Active Contributor

Simply use the public attribute M_READONLY_MODE.

(sorry I saw too late that you just found the solution)

0 Kudos

So no need to call GET_READONLY_MODE method, i can get the current status of text box by using the attribute?

Got it, No need to call the get_readonly_method. Thank you so much!! and learnt alot of things.

Vote++