Application Development 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: 

Problem in TextEditor Control

Former Member
0 Kudos

Hi,

I created a text editor control (CL_GUI_TEXTEDITOR). I am filling text from an internal table. This text displays correctly. But after that, when I use the instance method GET_LINE_COUNT, which is supposed to give me the number of lines displayed by the editor, it returns 0 (initial value).

Please take some time to go through the following code.

PARAMETERS P_PROG TYPE PROGRAMM.

DATA: R_CCONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
      R_TEDIT TYPE REF TO CL_GUI_TEXTEDIT,
      REPID TYPE SY-REPID,
      CHMOD_FLAG TYPE C VALUE ' '.

DATA: COUNT TYPE  I.

DATA: CODELINE TYPE C LENGTH 72,
      CODETAB LIKE TABLE OF CODELINE.

START-OF-SELECTION.
  READ REPORT P_PROG INTO CODETAB.
  IF SY-SUBRC = 0.
    REPID = SY-REPID.

    CREATE OBJECT R_CCONT
      EXPORTING
        CONTAINER_NAME              = 'MYCONTAINER'   "container area defined in screen 100.
      EXCEPTIONS
        CNTL_ERROR                  = 1
        CNTL_SYSTEM_ERROR           = 2
        CREATE_ERROR                = 3
        LIFETIME_ERROR              = 4
        LIFETIME_DYNPRO_DYNPRO_LINK = 5
        OTHERS                      = 6
        .

    CREATE OBJECT R_TEDIT
      EXPORTING
     WORDWRAP_MODE          = CL_GUI_TEXTEDIT=>WORDWRAP_AT_WINDOWBORDER
        WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE
        PARENT                 = R_CCONT
      EXCEPTIONS
        ERROR_CNTL_CREATE      = 1
        ERROR_CNTL_INIT        = 2
        ERROR_CNTL_LINK        = 3
        ERROR_DP_CREATE        = 4
        GUI_TYPE_NOT_SUPPORTED = 5
        OTHERS                 = 6
        .

    R_TEDIT->SET_TEXT_AS_R3TABLE( EXPORTING TABLE = CODETAB
                                  EXCEPTIONS OTHERS = 1 ).

    CALL METHOD R_TEDIT->GET_LINE_COUNT
      IMPORTING
        LINES                  = COUNT
      EXCEPTIONS
        ERROR_CNTL_CALL_METHOD = 1
        OTHERS                 = 2.
    CALL SCREEN 100.
  ELSEIF SY-SUBRC = 4.
    MESSAGE I001(ZAB_RD1) WITH P_PROG.    "Program does not exist.
  ENDIF.

The Internal table codetab has more than 100 lines. And the texteditor displays all of them correctly. Only thing is that the method GET_LINE_COUNT doesn't return value. I get 0 into COUNT always.

Does this have something to do with the CL_GUI_CFW=>FLUSH( ).? Please suggest..

Thanks in advance

Arun B

2 REPLIES 2

former_member188685
Active Contributor
0 Kudos
CALL METHOD r_tedit->get_line_count
      IMPORTING
        lines                  = count
      EXCEPTIONS
        error_cntl_call_method = 1
        OTHERS                 = 2.
    CALL SCREEN 100.

see the above code.

you are calling the line_count method before caling the screen. it should be called after the display.

if you want to know the line you can get that from codetab

using the Describe statement.

but if you want check the above method , you should call that after the display.

0 Kudos

Hi Vijay,

Thanks for that point. I can always use the internal table for getting the count. But I also wanted to use certain other methods after that, like highlighting certain lines of text etc.

The main reason why count was not getting filled was that the automation queue gets flushed only towards the end of PBO (If you remember, this gets done implicitly only at the end of PBO).

In my code, I was calling a method before that, and was expecting the result immediately after the method call. Somehow, I missed out the fact that this method doesn't get executed until the automation queue gets cleared.

However explicit flushing of automation queue (using the method CL_GUI_CFW=>FLUSH) is not needed when I can get the count from the internal table, as you correctly pointed out.

But my job is not over with getting the count. As I told earlier, I had planned of writing a logic in a loop to highlight certain lines. Now I have to think of another alternative since if I have to call the flush method once every loop pass, the program is gonna hang. Suggestions welcome.

Once again, thanks.