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

OOPS ALV using Docking container

Former Member
0 Likes
4,576

Hi,

I am trying to use ALV using oops concept, but the report is not displaying the ALV grid.

{please let me know if there are any error.

Edited by: Arunsri on Jun 3, 2010 5:42 PM

Edited by: Rob Burbank on Jun 3, 2010 11:57 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,286

Hi all,

Thanks for you replies. I am trying to display ALV in a report. Once the user enters the value in the selection screen and execute it should display the ALV.

When i try to display the ALV using REUSE_ALV_GRID_DISPLAY it is working fine.

Since i am learning to create it using OO concept i wanted to bring that using OO.

Since it is a report program, no screens or modules are involved.

Thanks,

sri

7 REPLIES 7
Read only

Former Member
0 Likes
2,286
data : alv_container  type ref to cl_gui_docking_container.
data : alv_grid       type ref to cl_gui_alv_grid.

data : layout    type lvc_s_layo.

data : variant type  disvariant.

check alv_container is initial.

  CREATE OBJECT alv_container
    EXPORTING
*     parent                      =
      repid                       = sy-repid
      dynnr                       = sy-dynnr
      side                        = alv_container->dock_at_left
*      extension                   = 1550
*     style                       =
*     lifetime                    = lifetime_default
*     caption                     =
*     metric                      = 0
*     ratio                       = '95'
*     no_autodef_progid_dynnr     =
*     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.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

*- Make the docking container as parent to the grid

  CREATE OBJECT alv_grid
    EXPORTING
      i_parent          = alv_container
    EXCEPTIONS
      error_cntl_create = 1
      error_cntl_init   = 2
      error_cntl_link   = 3
      error_dp_create   = 4
      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.

*  layout-zebra = 'X'.
  PERFORM build_fieldcat.
  variant-report = sy-repid.

*- Call grid for display

  CALL METHOD alv_grid->set_table_for_first_display
    EXPORTING
      i_structure_name               = 'WT_TEST'
      is_variant                    = variant
      i_save                         = 'A'
*      is_layout                      = layout
    CHANGING
      it_outtab                      = WT_TEST
      it_fieldcatalog                = wt_fcat_log
    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.
Read only

0 Likes
2,286

I think you are not placing your code in PBO, do you? You need that to show your alv once the screen/selection screen is being prepared for display. Only then it will work. So you need the logic


MODULE pbo OUTPUT.
   check alv_container is initial.
    "create container
    ...
    "create ALV
     ...
    "dispaly ALV
ENDMODULE.

For selection screen of course you need to use AT SELECTION-SCREEN OUTPUT instead.

Regards

Marcin

Read only

0 Likes
2,286

You check Tcode: DWDM where same codes of control frame work are available.

You have to create a screen and write the code for showing alv in PBO.

Read only

Former Member
0 Likes
2,287

Hi all,

Thanks for you replies. I am trying to display ALV in a report. Once the user enters the value in the selection screen and execute it should display the ALV.

When i try to display the ALV using REUSE_ALV_GRID_DISPLAY it is working fine.

Since i am learning to create it using OO concept i wanted to bring that using OO.

Since it is a report program, no screens or modules are involved.

Thanks,

sri

Read only

0 Likes
2,286

Hello Arunsri,

If you are using OO method to display alv then you need to define screen in screen painter which will have custom container control on it.

Once you are done with selection of data into internal table then you need to call that screen using

CALL SCREEN <scr_number>.

This will trigger PBO module of screen where you need to check if instance for grid and container are already created or not.

If not then you need to create then,

So, instead of cl_gui_docking_container you need to use cl_gui_custom_container and you need to pass name which is defined for the custom container in screen painter. Once custom container is ready pass this as container pass this to create alv_grid and the data table and it will display screen with the alv grid.

Hope this resolves you issue.

For more details please refer to SAP help for [ ALV using OO | http://help.sap.com/saphelp_47x200/helpdata/en/52/5f0607e02d11d2b47d006094192fe3/frameset.htm ]

Thanks,

-Augustin.

Read only

0 Likes
2,286

You must create a screen for OOPS ALV. Just create a screen and call it in START-OF-SELECTION. As you are using docking container, no need to create a custom container in the screen. In PBO, you can write the code for ALV display.

http://wiki.sdn.sap.com/wiki/display/Snippets/OOPS+ALV

Read only

0 Likes
2,286

Hi,

thanks, It is working fine now.