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: 

About hiding container in oops abap

Former Member
0 Kudos

I have created two continer on same screen one below the other.

When user double click on any line of first second container get displayed containing more information.

I have created hide button in toolbar of first container, when user click this button second container should be hide.

How can I hide entier container on screen.

I tired following but it is not working.

LOOP AT SCREEN .

IF SCREEN-NAME = 'MY_CONTAINER2'.

SCREEN-INVISIBLE = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

'MY_CONTAINER2' is the name of second container.

If anyone know how o solve this please let me know.

1 ACCEPTED SOLUTION

former_member69765
Contributor
0 Kudos

Hello Amit,

I personally don't like the idea of 'Freeing' the object !

If you set the object free, then you have potential source of bug in you code... What if there is some subroutine or method that still refers to this container?? If the control reaches that part then you will have a short dump !

Also, what if you want that container again ? You will create a new object ?? Not a good Idea...

The trick should be to minimize the container.... If you are using a splitter container control then you could set the height and width of the container to 0 - so that the container is no more visible !!

You can refer this article on Splitter controls here : [Link|http://www.abaplearning.com/abap-tutorials/12-cfw/39-abap-cfw-splitter-container]

7 REPLIES 7

Former Member
0 Kudos

Hi,

Try this..

Clear the object for container and free the object for container..

THanks

Naren

0 Kudos

how toclear object/ free the objectfor container.

what method should be called

and what is syntax

former_member188685
Active Contributor
0 Kudos

In the Button handling you can Clear/Free the object. or else you can use Different name(Which can be Dummy one), that will show an empty screen.

Former Member
0 Kudos

Hi,

You would have created an object for the container..Use that object to clear and free..

Ex..

* Free and clear
CALL METHOD CON_OBJ->FREE.
CLEAR: CON_OBJ.

Thanks

Naren

former_member69765
Contributor
0 Kudos

Hello Amit,

I personally don't like the idea of 'Freeing' the object !

If you set the object free, then you have potential source of bug in you code... What if there is some subroutine or method that still refers to this container?? If the control reaches that part then you will have a short dump !

Also, what if you want that container again ? You will create a new object ?? Not a good Idea...

The trick should be to minimize the container.... If you are using a splitter container control then you could set the height and width of the container to 0 - so that the container is no more visible !!

You can refer this article on Splitter controls here : [Link|http://www.abaplearning.com/abap-tutorials/12-cfw/39-abap-cfw-splitter-container]

0 Kudos

Thanks varun.

I really like your approach toward this situation.

Once again thank you.

uwe_schieferstein
Active Contributor
0 Kudos

Hello Amit

The proposed solution have little to do with hiding controls.

Sample report ZUS_SDN_TWO_ALV_GRIDS_HIDE demonstrates how you can hide and unhide a second ALV grid.

The ALV lists are displayed on the main screen '0100'. Screen '0101' is just a dummy screen to "store" the second docking container in the hidden mode.

In order to display the 2nd ALV list double click on a customer in the 1st grid or enter 'FULLSCREEN' in the command window.

In order to hide the visible 2nd ALV list enter again 'FULLSCREEN' in the command window.


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_TWO_ALV_GRIDS_HIDE
*&
*&---------------------------------------------------------------------*
*& Thread: About hiding container in oops abap
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1050377"></a>
*&
*&---------------------------------------------------------------------*
*& Screen '0100' contains no elements.
*& ok_code -> assigned to GD_OKCODE
*&
*& Flow logic:
*  PROCESS BEFORE OUTPUT.
*    MODULE STATUS_0100.
**
*  PROCESS AFTER INPUT.
*    MODULE USER_COMMAND_0100.
*&
*& GUI-status STATUS_0100: function 'FULLSCREEN' -> hide/display 2nd ALV
*&---------------------------------------------------------------------*

REPORT  zus_sdn_two_alv_grids_hide.

TYPE-POOLS: abap.

DATA:
  gd_repid         TYPE syrepid,
  gd_okcode        TYPE ui_func,
*
  go_docking1      TYPE REF TO cl_gui_docking_container,
  go_docking2      TYPE REF TO cl_gui_docking_container,
  go_grid1         TYPE REF TO cl_gui_alv_grid,
  go_grid2         TYPE REF TO cl_gui_alv_grid,
  gs_layout1       TYPE lvc_s_layo,
  gs_layout2       TYPE lvc_s_layo,
  gs_variant1      TYPE disvariant,
  gs_variant2      TYPE disvariant.


DATA:
  gt_outtab1       TYPE STANDARD TABLE OF knb1,
  gt_outtab2       TYPE STANDARD TABLE OF knvv.





*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler DEFINITION.

  PUBLIC SECTION.
    CLASS-DATA:
      ms_row      TYPE lvc_s_row,
      ms_col      TYPE lvc_s_col.

    CLASS-METHODS:
      handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
        IMPORTING
          e_row
          e_column
          es_row_no
          sender.


ENDCLASS.                    "lcl_eventhandler DEFINITION



*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.

  METHOD handle_double_click.
*   define local data
    DATA:
      ls_knb1      TYPE knb1.

    CLEAR: ms_row,
           ms_col.

    ms_row = e_row.
    ms_col = e_column.


*   Triggers PAI of the dynpro with the specified ok-code
    CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
    RETURN.

    " Version for SAP release 4.6
    CALL METHOD cl_gui_cfw=>set_new_ok_code
      EXPORTING
        new_code = 'DETAIL'
*      IMPORTING
*        rc       =
        .

  ENDMETHOD.                    "handle_double_click

ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION






START-OF-SELECTION.

  SELECT  * FROM  knb1 INTO TABLE gt_outtab1
         WHERE  bukrs  = '1000'.


  PERFORM init_controls.


* Link the docking container to the target dynpro
  gd_repid = syst-repid.
  CALL METHOD go_docking1->link
    EXPORTING
      repid                       = gd_repid
      dynnr                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      OTHERS                      = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.




* NOTE: dynpro does not contain any elements
  CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*
*PROCESS BEFORE OUTPUT.
*  MODULE STATUS_0100.
**
*PROCESS AFTER INPUT.
*  MODULE USER_COMMAND_0100.



END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
*  SET TITLEBAR 'xxx'.


* Refresh display of detail ALV list
  CALL METHOD go_grid2->refresh_table_display
*    EXPORTING
*      IS_STABLE      =
*      I_SOFT_REFRESH =
    EXCEPTIONS
      OTHERS         = 2.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  TRANSLATE gd_okcode TO UPPER CASE.

  CASE gd_okcode.
    WHEN 'BACK' OR
         'EXIT' OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.

*   User has pushed button "Display Details"
    WHEN 'DETAIL'.
      PERFORM customer_show_details.

    WHEN 'FULLSCREEN'.
      PERFORM toggle_display.


    WHEN OTHERS.
  ENDCASE.

  CLEAR: gd_okcode.

ENDMODULE.                 " USER_COMMAND_0100  INPUT



*&---------------------------------------------------------------------*
*&      Form  INIT_CONTROLS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM init_controls .

* Create docking container
  CREATE OBJECT go_docking1
    EXPORTING
      parent = cl_gui_container=>screen0
      side   = cl_gui_docking_container=>dock_at_top
      ratio  = 70
    EXCEPTIONS
      OTHERS = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


* Create docking container
  CREATE OBJECT go_docking2
    EXPORTING
      parent = cl_gui_container=>screen0
      side   = cl_gui_docking_container=>dock_at_top
      ratio  = 90
    EXCEPTIONS
      OTHERS = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


* Create ALV grids
  CREATE OBJECT go_grid1
    EXPORTING
      i_parent = go_docking1
    EXCEPTIONS
      OTHERS   = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CREATE OBJECT go_grid2
    EXPORTING
      i_parent = go_docking2
    EXCEPTIONS
      OTHERS   = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


* Set event handler
  SET HANDLER:
    lcl_eventhandler=>handle_double_click FOR go_grid1.

  PERFORM set_layout_and_variant.

* Display data
  CALL METHOD go_grid1->set_table_for_first_display
    EXPORTING
      i_structure_name = 'KNB1'
      is_layout        = gs_layout1
      is_variant       = gs_variant1
      i_save           = 'A'
    CHANGING
      it_outtab        = gt_outtab1
    EXCEPTIONS
      OTHERS           = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



  CALL METHOD go_grid2->set_table_for_first_display
    EXPORTING
      i_structure_name = 'KNVV'
      is_layout        = gs_layout2
      is_variant       = gs_variant2
      i_save           = 'A'
    CHANGING
      it_outtab        = gt_outtab2  " empty !!!
    EXCEPTIONS
      OTHERS           = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " INIT_CONTROLS


*&---------------------------------------------------------------------*
*&      Form  SET_LAYOUT_AND_VARIANT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM set_layout_and_variant .
  CLEAR: gs_layout1,
         gs_layout2.
  CLEAR: gs_variant1,
         gs_variant2.

  gs_layout1-grid_title = 'Customers'.
  gs_layout1-cwidth_opt = abap_true.
  gs_layout1-zebra      = abap_true.
*
  gs_layout2-grid_title = 'Sales Areas'.
  gs_layout2-cwidth_opt = abap_true.
  gs_layout2-zebra      = abap_true.

  gs_variant1-report = syst-repid.
  gs_variant1-handle = 'GRD1'.
*
  gs_variant2-report = syst-repid.
  gs_variant2-handle = 'GRD2'.


ENDFORM.                    " SET_LAYOUT_AND_VARIANT


*&---------------------------------------------------------------------*
*&      Form  customer_show_details
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM customer_show_details .
* define local data
  DATA:
    ld_row      TYPE i,
    ls_outtab1  LIKE LINE OF gt_outtab1.



  READ TABLE gt_outtab1 INTO ls_outtab1
                        INDEX lcl_eventhandler=>ms_row-index.
  CHECK ( syst-subrc = 0 ).

  SELECT * FROM  knvv INTO TABLE gt_outtab2
         WHERE  kunnr  = ls_outtab1-kunnr.


  " Link 2nd docking container again to main screen
  CALL METHOD go_docking2->link
    EXPORTING
      repid                       = gd_repid
      dynnr                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      OTHERS                      = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " customer_show_details


*&---------------------------------------------------------------------*
*&      Form  TOGGLE_DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM toggle_display .
* define local data
  DATA: ls_linkinfo   TYPE cfw_link.

  ls_linkinfo = go_docking2->get_link_info( ).

  CASE ls_linkinfo-dynnr.
      " 2nd ALV visible -> hide
    WHEN '0100'.
      CALL METHOD go_docking2->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0101'  " <<< !!!
*          CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
*       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

      " 2nd ALV hidden -> display
    WHEN '0101'.
      CALL METHOD go_docking2->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'  " <<< !!!
*          CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
*       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

    WHEN OTHERS.
  ENDCASE.

ENDFORM.                    " TOGGLE_DISPLAY

Regards

Uwe