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

Need for Custom Container

Former Member
0 Likes
2,645

Hi all,

I have read that you use Custom container class for oops alv. But i have not found an answer as to why do we have to use the class.

Can't we just use ALV class only (Cl_gui_alv_grid) ?.

Regards

Varun

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,757

Hi,

The below link talks about the various containers and their purpose.

http://help.sap.com/saphelp_nw2004s/helpdata/en/d3/2955360b00a115e10000009b38f839/frameset.htm

Hi,

The below link talks about the various containers and their purpose.

http://help.sap.com/saphelp_nw2004s/helpdata/en/d3/2955360b00a115e10000009b38f839/frameset.htm

12 REPLIES 12
Read only

Former Member
0 Likes
1,758

Hi,

The below link talks about the various containers and their purpose.

http://help.sap.com/saphelp_nw2004s/helpdata/en/d3/2955360b00a115e10000009b38f839/frameset.htm

Read only

Former Member
0 Likes
1,757

Hi varun,

I think that we cant place an ALv directly on the output screen. First we have to take a container to hold the data that is to be displayed, after that u have to pass the container name and the parent name .

regards,

Vijetha.

Read only

Former Member
0 Likes
1,757

Hi,

If you want to use CL_GUI_ALV_GRID or CL_GUI_TEXTEDIT, in all cases, you must need a container on the screen which will hold these objects.

Read only

0 Likes
1,757

right swastik. I know that you need custom container to hold these objects. But why do you need it. What are the constarints that forces us to use custom container class.

Is there a method that is needed from that class.? If yes then which method.

Thanks

Read only

0 Likes
1,757

With out Custom container you can also create the Grid using Docking container , for which you don't require any Custom control on the Screen.

Read only

0 Likes
1,757

Yeah Vijay then u need a different container which you mentioned. That is for grid u use docking container. so u have to use a container for almost all controls.

Read only

Former Member
0 Likes
1,757

Hi,

There are different types of containers like custom container, docking container.

for the custom container we have to create the screen and a custom container to place the ALV grid in it.

Just you are telling the alv grid to display in that container.

Hope it helps you.

Regards

Manjari.

Read only

Former Member
0 Likes
1,757

Hi Varun,

In order to integrate a control into a screen, we can use different container controls

The SAP Custom Container allows us to display controls in an area defined on a normal screen using the Screen Painter.

Custom Container is used to build a control into an area on a screen or subscreen. You define the area occupied by the control in the Screen Painter.

Hope this will help.

Regards,

Nitin.

Read only

Former Member
0 Likes
1,757

Hi,

When you create ALV through ABAP OBJECTS. You define a screen for it and on that screen you have to define a container. Here container means that you are defining an area where you 'll be placing your ALV. In ALV grid reference, you give the reference of container class and to display the ALV you call the method set_table_for firstdisplay of class cl_gui_alv_grid . Here you specify the field catalog( Fields you want to display )

So to define an area or container where you want to display ALV. You have to use the class cl_gui_custom_container.

Regards

Abhijeet

Read only

0 Likes
1,757

Hi abhijeet

You are saying that for alv we need to use the Custom container so we can define an area for it.

I also want to know that for tabstrip control and sub screen area control do we need a container ?? As they are directly placed on screen i don't think they will be needing any container.

Can u also throw some light on which controls need a container?

Thanks

Varun

Read only

Former Member
0 Likes
1,757

You can only create a grid display in a container...while creating the object for grid contol you have to pass the object reference of the custom container...check out the following for details...


*&---------------------------------------------------------------------*
*& Report  ZTEST_DEMO_ALV
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  ztest_demo_alv.


class cl_event_reciever definition deferred.
data:
wa_vbak type vbak.
data:
i_vbak type standard table of vbak,
i_vbap type standard table of vbap.


data:
v_container1 type scrfname value 'CONT1',
v_grid1      type ref to cl_gui_alv_grid,
v_custom_container1 type ref to cl_gui_custom_container,
v_container2 type scrfname value 'CONT2',
v_grid2      type ref to cl_gui_alv_grid,
v_custom_container2 type ref to cl_gui_custom_container,
ok_code type syucomm,
v_event_reciever type ref to cl_event_reciever.

*----------------------------------------------------------------------*
*       CLASS cl_event_reciever DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class cl_event_reciever definition.
  public section.

    methods:
      handle_double_click for event double_click of cl_gui_alv_grid
        importing e_row e_column.



endclass.                    "cl_event_reciever DEFINITION

*----------------------------------------------------------------------*
*       CLASS cl_event_reciever IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class cl_event_reciever implementation.
  method handle_double_click.

    read table i_vbak
    into wa_vbak
    index e_row.
    if sy-subrc = 0.

      select * from vbap
        into table i_vbap

        where vbeln = wa_vbak-vbeln.
      if sy-subrc = 0.
        set screen 00.
        leave to screen 100.
      endif.
    endif.
  endmethod.                    "handle_double_click
endclass.                    "cl_event_reciever IMPLEMENTATION

select-options:
s_vbeln for  wa_vbak-vbeln.


start-of-selection.

  select * from  vbak
    into table i_vbak
    up to 50 rows
    where vbeln in s_vbeln.
  if sy-subrc <> 0.
    message i000(z_zzz_ca_messages)  with 'No data found!'.
    leave list-processing.

  endif.

end-of-selection.
  call screen 100.


*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
  set pf-status '100'.
*  SET TITLEBAR 'xxx'.

  if v_custom_container1 is not bound.

    create object v_custom_container1
    exporting container_name = v_container1.

    create object v_grid1
      exporting i_parent = v_custom_container1.

    call method v_grid1->set_table_for_first_display
       exporting
*       i_buffer_active               =
*       i_bypassing_buffer            =
*       i_consistency_check           =
         i_structure_name              = 'VBAK'
*       is_variant                    =
*       i_save                        =
*       i_default                     = 'X'
*       is_layout                     =
*       is_print                      =
*       it_special_groups             =
*       it_toolbar_excluding          =
*       it_hyperlink                  =
*       it_alv_graphics               =
*       it_except_qinfo               =
*       ir_salv_adapter               =
      changing
        it_outtab                     = i_vbak
*       it_fieldcatalog               =
*       it_sort                       =
*       it_filter                     =
      exceptions
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        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.
    create object v_event_reciever.
    set handler v_event_reciever->handle_double_click for v_grid1.

  endif.

  if v_custom_container2 is not bound
    and i_vbap is not initial.

    create object v_custom_container2
    exporting container_name = v_container2.

    create object v_grid2
      exporting i_parent = v_custom_container2.

    call method v_grid2->set_table_for_first_display
       exporting
*       i_buffer_active               =
*       i_bypassing_buffer            =
*       i_consistency_check           =
         i_structure_name              = 'VBAP'
*       is_variant                    =
*       i_save                        =
*       i_default                     = 'X'
*       is_layout                     =
*       is_print                      =
*       it_special_groups             =
*       it_toolbar_excluding          =
*       it_hyperlink                  =
*       it_alv_graphics               =
*       it_except_qinfo               =
*       ir_salv_adapter               =
      changing
        it_outtab                     = i_vbap
*       it_fieldcatalog               =
*       it_sort                       =
*       it_filter                     =
      exceptions
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        others                        = 4
            .
  endif.
  if v_custom_container2 is bound.
    call method v_grid2->refresh_table_display.
  endif.

endmodule.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.
  case ok_code.
    when 'BACK'.
      if v_grid1 is bound.
        call method v_grid1->free.
      endif.
      if v_grid2 is bound.
        call method v_grid2->free.
      endif.
      set screen 00.
      leave screen.

  endcase.


endmodule.                 " USER_COMMAND_0100  INPUT

Read only

Former Member
0 Likes
1,757

got info about container