Skip to Content
author's profile photo Former Member
Former Member

Changing width of a custom container dynamically

Hi,

I have an ABAP report that has 2 custom containers on a screen: CC1 on the left, showing a tree and another one (CC2) consuming the rest of the screen. Depending on what node the user selects in the tree (left CC), I would like to dynamically adjust the width of CC1 and CC2.

Is there a way to do it? I found the method SET_WIDTH of CL_GUI_CUSTOM_CONTAINER (which CC1 and CC2 are instances of), but it does not seem to work.

Any help is appreciated.

Guenther

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2005 at 12:04 AM

    Here is a coding example that demonstrates dynamically changing the width of the container.

    What you cannot see is the screen definition. Screen 100 has a single custom container that fills the entire screen and is set to be resizable. The container name is 'MY_CONTAINER'. Next screen is set to 0.

    Flow logic of screen:

    PROCESS BEFORE OUTPUT.
    
      MODULE pbo.
    
    PROCESS AFTER INPUT.

    Cut and paste this program and define the screen. Run the program and keep hitting ENTER to see the size change from left to right. After 9 times, the program will end.

    REPORT  zcdf_docking_example.
    
    DATA:
      w_sash           TYPE sy-index,
      r_cstm_ctnr      TYPE REF TO cl_gui_custom_container,
      r_easy_splt_ctnr TYPE REF TO cl_gui_easy_splitter_container.
    
    CLASS cl_gui_easy_splitter_container DEFINITION LOAD.
    
    DO 9 TIMES.
    
      w_sash = sy-index * 10.
    
      CALL SCREEN 100.
    
    ENDDO.
    
    MODULE pbo OUTPUT.
    
      IF r_cstm_ctnr IS INITIAL.
    
        CREATE OBJECT r_cstm_ctnr
             EXPORTING container_name = 'MY_CONTAINER'.
    
        CREATE OBJECT r_easy_splt_ctnr
               EXPORTING
                 parent = r_cstm_ctnr
                 orientation =
                   cl_gui_easy_splitter_container=>orientation_horizontal.
    
    *   Set starting sash position.  Position is a percentage.
    
        CALL METHOD r_easy_splt_ctnr->set_sash_position
               EXPORTING
                 sash_position = w_sash.
    
    *   Put ALV in left container.
    
    *    CREATE OBJECT r_alv_grid1
    *           EXPORTING
    *             i_parent = r_easy_splt_ctnr->top_left_container.
    
    *   Put ALV in right container.
    
    *    CREATE OBJECT r_alv_grid2
    *           EXPORTING
    *             i_parent = r_easy_splt_ctnr->bottom_right_container.
    
      ELSE.
    
        CALL METHOD r_easy_splt_ctnr->set_sash_position
               EXPORTING
                 sash_position = w_sash.
    
      ENDIF.
    
    ENDMODULE.                 " pbo  OUTPUT

    Let us know how it goes.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2005 at 02:50 PM

    Hi Guenther,

    One of the options that you must consider is the docking container, which would also allow the user the flexibility to resize the screen as he likes. And I think it makes for better UI design and is also easy to program.

    Regards,

    Anand Mandalika.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Guenther

      Docking container is OK and may be more feasible for some cases, however I would prefer the <b>splitter container</b> if it suits to your needs. You can inspect relevant classes and demo programs by searching with "SPLITTER" mask.

      Easy splitter (<b>CL_GUI_EASY_SPLITTER_CONTAINER</b>) is a lite version, but if you need more features than it offers you can use the classical one (<b>CL_GUI_SPLITTER_CONTAINER</b>).

      Hope you find this helpful...

      *--Serdar

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2005 at 02:43 PM

    Hi Guenther,

    Did you call the following after the change:

    CALL METHOD CL_GUI_CFW=>FLUSH

    EXCEPTIONS

    CNTL_SYSTEM_ERROR = 1

    CNTL_ERROR = 2.

    Or possibly Did you call the function module 'CONTROL_FLUSH' after the change?

    Regards,

    Rob.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2005 at 09:00 PM

    All,

    First of all, I would like to thank everybody for their help!

    I finally ended up using the splitter container approach - initially I tried to avoid it because I had to change the layout of multiple screens. It looks like this is the (only?) best way to go and since I had to touch all these modules anyway, I put in some additional changes and cosmetics.

    One of these moments where one single change request triggers quite a bit of reengineering...

    Again, thanks everybody!

    Guenther

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.