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: 

GENERIC ALV GRID

Former Member
0 Kudos
483

We are trying to make a "Generic ALV grid function module" , this would take , all the parameters required for the the method set_table forfirst_display like it_structure , it_outtab etc ,

We require to pass any kind of an internal table to it .

In the process of achiving this , we

1. made a function group ,

2. added a screen to it.

3. created a function module .

4. passed parameters to it , specifiying the type of it_structure parameter as DD02L-TABNAME , and it_outtab as the generic type STANDARD TABLE as shown in the class cl_gui_alv_grid.

5. we call the screen from the function module ,

6. in order to make the parameters visible in the screen , global variables of the above types are declared in the top include

7. and then setting the values of these global variables as the values of the parameters passed

here we are facing a problem , it_outtab being a generic type (STANDARD TABLE) , we cannot create another variable of the same type as it_outtab.

We tried to use field symobls as folows

FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE. In the top include

And then assign using

ASSIGN it_out TO <dyn_table> .

The code complies fine , but throws a runtime error as ASSIGN_TYPE_ERROR.

We are unable to understand the cause of such an error , as the types of the field symbol and the table it_outtab are the same ,

Is there any way to resolve the above ,

Plese do help ,

Waiting for ur reply

thanks

Abhishek

7 REPLIES 7

FredericGirod
Active Contributor
0 Kudos
100

MMhhhh maybe simple way is to copy the FM REUSE_ALV_GRID_DISPLAY* ..

Why don't you use the standard FM ?

Regards

Frédéric

Former Member
0 Kudos
100

Hi Abhishek,

I am not getting your problem.

But to create a generic funcion module , you can try passing it_outtab in the tables parameter of function module. you can refer to function module REUSE_ALV_GRID_DISPLAY in SE37. This is a generic function module to create an ALV Grid.

Regards

Mitesh

0 Kudos
100

I have actually done the same thing, only with a Popup, here is my code.



function z_popup_with_alvgrid.
*"----------------------------------------------------------------------
*"*"Global interface:
*"  IMPORTING
*"     REFERENCE(ENDPOS_COL) TYPE  I DEFAULT 90
*"     REFERENCE(ENDPOS_ROW) TYPE  I DEFAULT 22
*"     REFERENCE(STARTPOS_COL) TYPE  I DEFAULT 10
*"     REFERENCE(STARTPOS_ROW) TYPE  I DEFAULT 2
*"     REFERENCE(TEXTLINE1) TYPE  C OPTIONAL
*"     REFERENCE(TEXTLINE2) TYPE  C OPTIONAL
*"     REFERENCE(TEXTLINE3) TYPE  C OPTIONAL
*"     REFERENCE(TEXTLINE4) TYPE  C OPTIONAL
*"     REFERENCE(TITLE) TYPE  C OPTIONAL
*"     REFERENCE(FIELDCAT) TYPE  LVC_T_FCAT
*"  TABLES
*"      I_ALV
*"----------------------------------------------------------------------

  call screen 0200 starting at startpos_col
                               startpos_row
                     ending at endpos_col
                               endpos_row.

endfunction.

************************************************************************
*      Module  STATUS_0200  OUTPUT
************************************************************************
module status_0200 output.

  set pf-status '0200'.
  set titlebar  '0200' with title.

  data: alv_container  type ref to cl_gui_custom_container.
  data: alv_grid       type ref to cl_gui_alv_grid.

  data: xfieldcat type lvc_t_fcat.

  xfieldcat = fieldcat.

* Create Controls
  create object:

     alv_container
             exporting
                   container_name    = 'ALV_CONTAINER',

     alv_grid
             exporting
                   i_parent          =  alv_container.

*  Set grid for first display
  call method alv_grid->set_table_for_first_display(
      exporting
           i_structure_name       = 'I_ALV'
      changing
           it_outtab       = i_alv[]
           it_fieldcatalog = xfieldcat[] ).

endmodule.

************************************************************************
*     Module  USER_COMMAND_0100  INPUT
************************************************************************
module user_command_0200 input.

  case sy-ucomm.
    when 'CONTINUE' or 'CANCEL'.
      set screen 0.
      leave screen.
  endcase.

endmodule.


The I_ALV table is defined only in the TABLES statement and has no type.

Hope this helps.

Regards,

Rich Heilman

Former Member
0 Kudos
100

Hi, you can try like following:

data: refer type ref to data.

get reference of it_out into refer.

assign refer->* to <ftab>.

Hope it will be helpful

thanks

Former Member
0 Kudos
100

U can also have a look into these sample program

http://www.sapdevelopment.co.uk/reporting/alvhome.htm

jayanthi_jayaraman
Active Contributor
0 Kudos
100

Hi,

Check this link.May be it can help you.

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

If so,kindly reard points by clicking on the star on the left of the reply.

0 Kudos
100

I know this is somewhat old, but I think the solution here is to assign like this:

ASSIGN it_out[] to <dyn_table>.

I don't get an error when I assigned the contents of the table, rather than the header line.