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

Custom Container

Former Member
0 Likes
3,317

Hi All,

Please let me know can we use cl_gui_alv_grid class without creating container for it.

Regards,

Deepak kansal.

11 REPLIES 11
Read only

pramodu
Active Participant
0 Likes
1,991

Hello,

Yes we can use CL_GUI_ALV_GRID without container provide you have used Fullscreen

Example

DATA: goobj_grid type ref to cl_gui_alv_grid.

"Set the daefault screen which will be full size.

  CREATE OBJECT gobj_grid

      EXPORTING

           i_parent = cl_gui_custom_container=>default_screen. 

  Call method gonj_grid->set_table_for_first_display

      exporting

        i_structure_name = '  '         "=> Pass he strcture here

      changing

        it_outtab        = gt_table     "=> Pass he strcture here

      exceptions

        others           = 4.

Thanks,

Pramod

Message was edited by: Pramod Kumar Upadhyay

Read only

0 Likes
1,991

It works.

Good one

Read only

Sijin_Chandran
Active Contributor
0 Likes
1,991

Hello Deepak ,

No you can't because while creating the Object for CL_GUI_GRID_DISPLAY you need to pass the object of Container.

If you are looking for OO ALV without using Screen Programming Elements then use cl_salv_table.

Read only

Former Member
0 Likes
1,991

Hi,

Try the below code.

Replace GT_ALV with the name of your internal table

    DATA : L_ALV           TYPE REF TO CL_SALV_TABLE,
         L_DISPLAY       TYPE REF TO CL_SALV_DISPLAY_SETTINGS,
         L_COLUMNS       TYPE REF TO CL_SALV_COLUMNS_TABLE,
         L_FUNCTIONS     TYPE REF TO CL_SALV_FUNCTIONS,
         L_LAYOUT        TYPE REF TO CL_SALV_LAYOUT,
         L_COLUMN        TYPE REF TO CL_SALV_COLUMN_TABLE.

  DATA : LS_COLUMN  TYPE SALV_S_COLUMN_REF,
         LS_KEY     TYPE SALV_S_LAYOUT_KEY.

  DATA : LT_COLUMN    TYPE SALV_T_COLUMN_REF.

  DATA : LV_VALUE TYPE SCRTEXT_L.

* DISPLAY ALV
  TRY.
      CALL METHOD CL_SALV_TABLE=>FACTORY
        IMPORTING
          R_SALV_TABLE = L_ALV
        CHANGING
          T_TABLE      = GT_ALV.
    CATCH CX_SALV_MSG .
  ENDTRY.

  L_DISPLAY = L_ALV->GET_DISPLAY_SETTINGS( ).
  L_DISPLAY->SET_STRIPED_PATTERN( CL_SALV_DISPLAY_SETTINGS=>TRUE ).
  L_COLUMNS = L_ALV->GET_COLUMNS( ).
  L_COLUMNS->SET_OPTIMIZE( 'X' ).
  LT_COLUMN = L_COLUMNS->GET( ). "TO GET SINGLE COL NAME IN LT_COLUMN



  L_LAYOUT = L_ALV->GET_LAYOUT( ).
  LS_KEY-REPORT = SY-REPID.
  L_LAYOUT->SET_KEY( LS_KEY ).
  L_LAYOUT->SET_SAVE_RESTRICTION( IF_SALV_C_LAYOUT=>RESTRICT_NONE ).
  L_FUNCTIONS = L_ALV->GET_FUNCTIONS( ).
  L_FUNCTIONS->SET_ALL( ABAP_TRUE ).
  L_ALV->DISPLAY( ).

Read only

sivaganesh_krishnan
Contributor
0 Likes
1,991

Hi deepak,

yes we can create a alv without the container .

You can use se80 -> SLIS package -> Programs , u will find many programs there

we can use  cl_gui_custom_container=>screen0 or cl_gui_custom_container=> default_screen just as below .

data lo_grid type ref to cl_gui_alv_grid.

  CREATE OBJECT lo_grid

      EXPORTING

           i_parent = cl_gui_custom_container=>screen 0.  " instead fo creating custom container u can use standard screens

lo_grid->set_table_for_first_display( .... ).

Regards,

Sivaganesh

Read only

0 Likes
1,991

Hi Deepak,

Go through this link https://scn.sap.com/thread/2122042

Read only

Former Member
0 Likes
1,991

Hi Deepak,

Instead of below code

CREATE OBJECT gobj_grid

      EXPORTING

           i_parent = cl_gui_custom_container=>default_screen.

Use CREATE OBJECT gobj_grid

      EXPORTING

           i_parent = cl_gui_custom_container=>screen0.

it will also work.

Thanks,

Satya.

Read only

reachdebopriya
Active Participant
0 Likes
1,991

Hi Deepak,

Code is as below:

WRITE: /n Text-001. "Text-001 will contain blank value.

DATA: gr_grid type ref to cl_gui_alv_grid.


  Call method gr_grid->set_table_for_first_display

      exporting

        i_structure_name = '  '         "=> Pass he strcture here

      changing

        it_outtab        = gt_table     "=> Pass he strcture here

      exceptions

        others           = 4.

BR,

Debopriya Ghosh

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,991

What is your exact question : executing this class with initial/no container or using an implicit container like current screen, or a docking container attached to current screen ?

Nevertheless the answer is yes, we do it usually during background process, only creating container when online using a parent container in a dynpro and not creating when in background (cl_gui_alv_grid=>offline returned true) in second case the class will generate a spool list (using good old REUSE FM)

Regards,

Raymond

Read only

Former Member
0 Likes
1,991

Hi

why you dont want to create the custom container?

İs there a specific reason?

you can attach to a dockıng contaıner too

Read only

Former Member
0 Likes
1,991

Hii deepak,

We can use cl_gui_alv_grid without using custom container.

While creating object of cl_gui_alv_grid like below,

data obj_grid type ref to cl_gui_alv_grid.

start-of-selection.

IF obj_grid IS INITIAL.

      CREATE OBJECT obj_grid

        EXPORTING

          i_parent          = cl_gui_custom_container=>default_screen

        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.

    ENDIF.

then call method

IF NOT <internal_table> IS INITIAL.

      CALL METHOD obj_grid->set_table_for_first_display

        EXPORTING
          i_structure_name      = ur structure name
          is_layout                     = lx_layout
         
        CHANGING

          it_outtab                     = it_trans  "output internal table want to display in grid

      *    it_fieldcatalog               = lt_fieldcat

        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.

*        STOP.

      ENDIF.

    ENDIF.

regards

Syed