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: 

Display ALV on container on screen.

0 Kudos

Hello All,

I am trying to display an internal table in an ALV in a container on screen.

Here is what I am trying to do.

DATA: salv_ref TYPE REF TO cl_salv_table.

DATA: lr_columns TYPE REF TO cl_salv_columns_table.

DATA: data_container TYPE REF TO CL_GUI_CONTAINER.

select stmt in internal table.

call screen 100.  //  a custom container is placed on the screen name = TAB_CONTAINER

---------------------

PBO 100.

CREATE OBJECT data_container

  EXPORTING

    clsid                          =     SPACE " Class ID of This Container

    container_name                 =     'TAB_CONTAINER'

  EXCEPTIONS

    cntl_error                     = 1

    cntl_system_error              = 2

    create_error                   = 3

    lifetime_error                 = 4

    lifetime_dynpro_dynpro_link    = 5

    lifetime_dynpro_illegal_parent = 6

    others                         = 7

  .

IF sy-subrc <> 0.

* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

*            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

cl_salv_table=>factory(

  EXPORTING

    r_container    =  data_container

  IMPORTING

    r_salv_table   =  salv_ref

  CHANGING

    t_table        = lt_tab_form

).

salv_ref->display( ).

But I am not seeing anything on the screen.

Could you please suggest where I am doing it wrong.

8 REPLIES 8

maryshchak_conti
Explorer
0 Kudos

Hi,

try to add parameter "container_name"

cl_salv_table=>factory(

  EXPORTING

    r_container    =  data_container

   container_name = ' TAB_CONTAINER''

  IMPORTING

    r_salv_table   =  salv_ref

  CHANGING

    t_table        = lt_tab_form

).

Best regards,
Serge M

deependra_shekhawat3
Contributor
0 Kudos

Hi,

try to pass container name also to factory method.

cl_salv_table=>factory(

  EXPORTING

    r_container    =  data_container

    CONTAINER_NAME =  'TAB_CONTAINER'

  IMPORTING

    r_salv_table   =  salv_ref

  CHANGING

    t_table        = lt_tab_form

).

0 Kudos

It still does not help.

I pass the container name , but there is nothing appears on screen.

0 Kudos

Hi Nandan,

why are you using Container,

use the below codin to get the output ALV screen.

Pass internal table, in t_table parameters.

Basically we use container, when we use CL_GUI_ALV_GRID class to display the information in ALV grid.

Regards.

Praveer,

0 Kudos

Refer this example, if it helps

Report SALV_DEMO_TABLE_SIMPLE ( ouput as Grid)

0 Kudos

Hi Praveer,

This will display the data on the complete screen. whereas I want to display it in a container.

So there is no way I use CL_SALV_table class and display data in a container on screen.

Best Regards,

Nandan

Former Member
0 Kudos

you need to create a container on the screen and then pass the container name while calling the factory method like below:

'CONT' is the name of the custom container on the screen.

DATA lx_msg TYPE REF TO cx_salv_msg.

     TRY.

         CALL METHOD cl_salv_table=>factory

           EXPORTING

             container_name = 'CONT'

           IMPORTING

             r_salv_table   = o_alv

           CHANGING

             t_table        = it_sflight.

       CATCH cx_salv_msg INTO lx_msg.

     ENDTRY.

     CALL METHOD o_alv->display.


This code works for me. I think no need to create the container as you are doing in


CREATE OBJECT data_container

  EXPORTING

    clsid                          =     SPACE " Class ID of This Container

    container_name                 =     'TAB_CONTAINER'

  EXCEPTIONS

    cntl_error                     = 1

    cntl_system_error              = 2

    create_error                   = 3

    lifetime_error                 = 4

    lifetime_dynpro_dynpro_link    = 5

    lifetime_dynpro_illegal_parent = 6

    others                         = 7

  .

IF sy-subrc <> 0.

* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

*            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Follow the program demo 'SALV_DEMO_TABLE_SIMPLE'.

The code says...

if gr_container is not bound.
if cl_salv_table=>is_offline( ) eq if_salv_c_bool_sap=>false.
create object gr_container
exporting
container_name = 'CONTAINER'.
endif.

*... §2 create an ALV table
try.
cl_salv_table=>factory(
exporting
r_container = gr_container
container_name = 'CONTAINER'
importing
r_salv_table = gr_table
changing
t_table = gt_outtab ).
catch cx_salv_msg. "#EC NO_HANDLER
endtry.

....

endif.

The issue is on the declaration of the container

data: gr_container type ref to cl_gui_custom_container. " GUI Custom container

instead of

DATA: data_container TYPE REF TO CL_GUI_CONTAINER. "GUI container