2005 Aug 01 3:49 PM
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
2005 Aug 01 3:56 PM
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
2005 Aug 01 4:02 PM
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
2005 Aug 01 4:12 PM
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
2005 Aug 01 5:57 PM
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
2005 Aug 02 4:33 AM
2005 Aug 02 4:44 AM
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.
2005 Nov 10 8:26 PM
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.