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

ALV Oops

Former Member
0 Likes
1,007

Hi Experts ,

I want to know the details about Custom Container . What it is and why we use it ? . Is it possible to display ALV without using Custom Container ?

Regards ,

Senthil

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
936

hi,

chk the stnadrad pgms.

se38 -> BCALV_* -> press f4 button.

u will get the usage of custom container.

all the best.

Anver

5 REPLIES 5
Read only

satykumar
Product and Topic Expert
Product and Topic Expert
0 Likes
936

Hi,

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

If you do not want to use Custom Container then use function 'REUSE_ALV_GRID_DISPLAY' .

Thanks,

Satyendra

Read only

anversha_s
Active Contributor
0 Likes
937

hi,

chk the stnadrad pgms.

se38 -> BCALV_* -> press f4 button.

u will get the usage of custom container.

all the best.

Anver

Read only

uwe_schieferstein
Active Contributor
0 Likes
936

Hello Senthil

The answer is: yes and no.

(1) No if you are using the most up-to-date version of ALV lists (see sample report).

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_CL_SALV_TABLE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_cl_salv_table.


DATA:
  gt_knb1        TYPE STANDARD TABLE OF knb1.


DATA:
  go_table       TYPE REF TO cl_salv_table.
*  go_layout      type ref to CL_SALV_LAYOUT,
*  go_display     type ref to CL_SALV_DISPLAY_SETTINGS,
*  go_columns     type ref to CL_SALV_COLUMNS_TABLE.




START-OF-SELECTION.


START-OF-SELECTION.

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


  TRY.
      CALL METHOD cl_salv_table=>factory
*    EXPORTING
*      LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
*      R_CONTAINER    =
*      CONTAINER_NAME =
        IMPORTING
          r_salv_table   = go_table
        CHANGING
          t_table        = gt_knb1.
    CATCH cx_salv_msg .
  ENDTRY.

  go_table->display( ).


END-OF-SELECTION.

(2) If you are using the "classical" OO-approach then you always need a container but not necessarily a custom container. The following sample report displays two ALV lists on a screen without any dynpro elements.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_TWO_ALV_GRIDS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_two_alv_grids.




DATA:
  gd_okcode        TYPE ui_func,
*
  go_docking       TYPE REF TO cl_gui_docking_container,
  go_splitter      TYPE REF TO cl_gui_splitter_container,
  go_cell_top      TYPE REF TO cl_gui_container,
  go_cell_bottom   TYPE REF TO cl_gui_container,
  go_grid1         TYPE REF TO cl_gui_alv_grid,
  go_grid2         TYPE REF TO cl_gui_alv_grid.


DATA:
  gt_knb1          TYPE STANDARD TABLE OF knb1,
  gt_knvv          TYPE STANDARD TABLE OF knvv.





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

  PUBLIC SECTION.
    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.

    CHECK ( sender = go_grid1 ).

    READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
    CHECK ( ls_knb1-kunnr IS NOT INITIAL ).

    CALL METHOD go_grid1->set_current_cell_via_id
      EXPORTING
*        IS_ROW_ID    =
*        IS_COLUMN_ID =
        is_row_no    = es_row_no.


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



  ENDMETHOD.                    "handle_double_click

ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION






START-OF-SELECTION.

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


* Create docking container
  CREATE OBJECT go_docking
    EXPORTING
      parent                      = cl_gui_container=>screen0
      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 splitter container
  CREATE OBJECT go_splitter
    EXPORTING
      parent            = go_docking
      rows              = 2
      columns           = 1
*      NO_AUTODEF_PROGID_DYNNR =
*      NAME              =
    EXCEPTIONS
      cntl_error        = 1
      cntl_system_error = 2
      OTHERS            = 3.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

* Get cell container
  CALL METHOD go_splitter->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = go_cell_top.
  CALL METHOD go_splitter->get_container
    EXPORTING
      row       = 2
      column    = 1
    RECEIVING
      container = go_cell_bottom.

* Create ALV grids
  CREATE OBJECT go_grid1
    EXPORTING
      i_parent          = go_cell_top
    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.


  CREATE OBJECT go_grid2
    EXPORTING
      i_parent          = go_cell_bottom
    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.


* Display data
  CALL METHOD go_grid1->set_table_for_first_display
    EXPORTING
      i_structure_name = 'KNB1'
    CHANGING
      it_outtab        = gt_knb1
    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'
    CHANGING
      it_outtab        = gt_knvv  " 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.


* Link the docking container to the target dynpro
  CALL METHOD go_docking->link
    EXPORTING
      repid                       = syst-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.

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

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

    WHEN OTHERS.
  ENDCASE.

  CLEAR: gd_okcode.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

*&---------------------------------------------------------------------*
*&      Form  ENTRY_SHOW_DETAILS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM entry_show_details .
* define local data
  DATA:
    ld_row      TYPE i,
    ls_knb1     TYPE knb1.

  CALL METHOD go_grid1->get_current_cell
    IMPORTING
      e_row = ld_row.

  READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
  CHECK ( syst-subrc = 0 ).

  SELECT        * FROM  knvv INTO TABLE gt_knvv
         WHERE  kunnr  = ls_knb1-kunnr.



ENDFORM.                    " ENTRY_SHOW_DETAILS

In summary, I do rarely use a custom container on a dynpro to display my controls. In contrast, I link my containers to the dynpro (using method <b>LINK</b>) which allows for much more flexibility.

Regards

Uwe

Read only

Former Member
0 Likes
936

Hi senthil,

Use the SAP Custom Container to build a control into an area on a screen or subscreen. You

define the area occupied by the control in the Screen Painter.

The default size of the control that you place in the Custom Container is the same as that of the container itself.

<b>Before you can include a control in a Custom Container, you must define the area that the container will occupy. You do this in the Screen Painter.</b>

create object custom_container

exporting

parent = parent

container_name = container_name

style = style

dynnr = dynnr

repid = repid

lifetime = lifetime

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

parent : Parent of the instance, that is, the contain in which the control is to be displayed

container_name : Name of the Custom Container defined in the Screen Painter

style : Controls the appearance and behavior of the control

dynnr : Number of the screen to which you want to attach the control

repid Report ID: Program to which you want to attach the control

Step 1 Add a custom control on the screen which will be related to the

custom container. Let’s give it the name ‘CC_ALV’.

Step 2 Declare global variables to be used for ALV Grid.

*-- Global data definitions for ALV

*--- ALV Grid instance reference

DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid .

*--- Name of the custom control added on the screen

DATA gc_custom_control_name TYPE scrfname VALUE ‘CC_ALV’ .

*--- Custom container instance reference

DATA gr_ccontainer TYPE REF TO cl_gui_custom_container .

*--- Field catalog table

DATA gt_fieldcat TYPE lvc_t_fcat .

*--- Layout structure

DATA gs_layout TYPE lvc_s_layo .

*--- Internal table holding list data

DATA BEGIN OF gt_list OCCURS 0 .

INCLUDE STRUCTURE SFLIGHT .

*--In further sections, some additional fields will added here

*--for some functionality

DATA END OF gt_list.

Step 4 Somewhere in your program before calling list display, fill your

list data as you want. Here, it is not our concern what the data are. We assume the

internal table is filled reasonably. We will use the data of table SFLIGHT as our list

data.

Step 5 Call the screen which comprises the ALV Grid control. At PBO of

this screen we will deal with creating the ALV Grid instance.

*--PBO

PROCESS BEFORE OUTPUT .

MODULE display_alv .

MODULE display_alv OUTPUT .

PERFORM display_alv .

ENDMODULE

Step 6 Now, it is high time we wrote something to play. So, this piece

will be the one we will deal mainly. What we do is, checking whether an instance of

the container (or ALV Grid) exists. If it exists, refreshing it, and if not, creating and

setting ALV for the first display.

FORM display_alv .

IF gr_alvgrid IS INITIAL .

*----Creating custom container instance

CREATE OBJECT gr_ccontainer

EXPORTING

container_name = gc_custom_control_name

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6 .

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

*----Creating ALV Grid instance

CREATE OBJECT gr_alvgrid

EXPORTING

i_parent = gr_ccontainer

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

others = 5 .

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

*----Preparing field catalog.

PERFORM prepare_field_catalog CHANGING gt_fieldcat .

*----Preparing layout structure

PERFORM prepare_layout CHANGING gs_layout .

*----Here will be additional preparations

*--e.g. initial sorting criteria, initial filtering criteria, excluding

*--functions

CALL METHOD gr_alvgrid->set_table_for_first_display

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

is_layout = gs_layout

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

CHANGING

it_outtab = gt_list[]

it_fieldcatalog = gt_fieldcat

  • IT_SORT =

  • IT_FILTER =

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4 .

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

ELSE .

CALL METHOD gr_alvgrid->refresh_table_display

  • EXPORTING

  • IS_STABLE =

  • I_SOFT_REFRESH =

EXCEPTIONS

finished = 1

OTHERS = 2 .

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

ENDIF .

ENDFORM .

Read only

Former Member
0 Likes
936

HI Senthil,

A SAP container is a control that can accommodate other controls, such as the SAP Tree Control, SAP Picture Control, or the SAP Textedit Control. It maintains the controls in a logical collection, and provides an area in which they can be displayed.

A container is always assigned to a screen and takes over the role of communicating with the screen.

Each control lives in a container. Since containers are themselves controls, you can nest them.

Controls within a container are usually displayed in the same size as the container itself. Containers are known as the "parents" of the control that they contain. All SAP Containers are derived from a common superclass, the global class CL_GUI_CONTROL. They are derived from this basic container and thus have a uniform object-oriented interface.

SAP containers can contain:

*An area on a screen (SAP Custom Container)

*An entire screen (SAP Docking Container, SAP Dialog Box Container)

*Another container (SAP Splitter Container, SAP Easy Splitter Container)

The fact that you can nest controls provides further display possibilities.

When you create an instance of a SAP container, you assign it to a dialog box level, which you cannot subsequently change.

A dialog box level is created in ABAP by executing the statement CALL SCREEN <screen_no> STARTING AT <left_column_no> <top_row_no> [ENDING AT <right_column_no> <bottom_row_number>].

When you instantiate a container, the class constructor creates the container instances SCREEN0, SCREEN1, ..., SCREEN9. These are assigned to the different dialog box levels. Dialog box level 0 = SCREEN0, level 1 = SCREEN1, ... Dialog box level 9 = SCREEN9.

The container instances SCREEN0, ... , SCREEN9 are called top-level containers. They are used as "parents" for the SAP Custom Container, SAP Docking Container, and SAP Dialog Box Container. The top-level container is automatically assigned to the Container Control when it is instantiated. You cannot change this assignment at runtime.

The top-level container to which a container is assigned affects its visibility, and hence that of the other controls you display in it.

Controls in a container are only visible when the corresponding container is visible.

You need to know what the dialog box level has been assigned if you want to assign a container to a new screen (using the LINK method) or if a container is instantiated within a function module.

Use the SAP Custom Container Control to attach a control to a reserved area on a screen.

Create the area using the Custom Control element in the Screen Painter. The area can be resized.

You can assign a Custom Container Control instance to the area. This assigns the container to the screen. The container can be resized if the user changes the size of the SAP window.

The following parameters identify a custom control area uniquely at the CFW:

*Program name

*Screen number

*Name of the area

*Number of the dialog box level at which the container and screen can be displayed.

To create an instance of the SAP Custom Container Control, you need a data object that you declare using TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

To create the instance itself, use the statement CREATE OBJECT <object_reference_var>. In the statement, you must pass the relevant parameters to specify the attributes of the container. This is illustrated in the graphic. If you do not assign values to the parameters parent, repid, and dynnr, the system uses the current values at runtime (current dialog box level , current program name, current screen). You must specify the name of the screen area in which the container should appear in the parameter container_name.

At runtime, you can assign a custom container instance to a different screen area (with the type Custom Control). The new area can be on the same screen, on another screen in the same program, or even on a screen in a different program.

The screen containing the new area to which you want to link the control can only be displayed in the same dialog box level.

To reassign an instance, you call the method LINK for the container instance you want to reassign. The method links the container instance to the new screen area and dissolves the link to the old one.

Regards,

Balaji

**Rewards if answers are useful