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

dynamic table usage in alv

Former Member
0 Likes
1,162

hi experts,

can please forward me the detials of using dynamic internal table as in case of alv and what is the usage of the class 'cl_abap_structdescr' can anybody explain in detail please?????

thanks in advance

janani

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,105

Hi Janani,

Check out the code:

<<copy pasted from some where else with out quoting the orginal source>>

warning 1

For more information you can look at below link:

Thanks,

Chidanand

9 REPLIES 9
Read only

Former Member
0 Likes
1,106

Hi Janani,

Check out the code:

<<copy pasted from some where else with out quoting the orginal source>>

warning 1

For more information you can look at below link:

Thanks,

Chidanand

Read only

Former Member
0 Likes
1,105

HI THANKU FOR YOUR REPLY...............BUT I CANT GET THIS CODE UNTILL AND UNLESS YOU EXPLAIN FOR WHAT AND IN WHAT REQUIREMENT IT IS BEING USED.

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,105

Hello Janani

You may have a look at my Wiki posting

[Creating Flat and Complex Internal Tables Dynamically using RTTI|https://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI]

which hopefully contains sufficient explanations for you.

Regards

Uwe

Read only

Former Member
0 Likes
1,105

ok i could get some idea......i have been asked to create an alv using class ' cl_salv_table'.but when i went and checked up in se24 it says the class does not exits.do have to create a class or where i find this????please help

Read only

Former Member
0 Likes
1,105

Hello,

Check this program

Go through this example programs

RCS00140

SALV_DEMO_TABLE_COLUMNS

SALV_DEMO_TABLE_FUNCTIONS

SALV_DEMO_TABLE_LAYOUT

SALV_DEMO_TABLE_REAL_SIMPLE

SALV_DEMO_TABLE_SIMPLE

SALV_SIMPLE_GRID_CALL

SAPFJ1GFIS0

types: begin of g_type_s_test,

amount type i,

repid type syrepid,

display type i,

dynamic type sap_bool,

end of g_type_s_test.

constants: begin of gc_s_display,

list type i value 1,

fullscreen type i value 2,

grid type i value 3,

end of gc_s_display.

data: gs_test type g_type_s_test.

*-----mandar

types : begin of ty_alv_t_t2,

mandt type mandt,

matnr type matnr,

MATKL type MATKL,

end of ty_alv_t_t2.

*------

*data: gt_outtab type standard table of alv_t_t2. "commented by mandar

data : gt_outtab type standard table of ty_alv_t_t2. "added by mandar

data: gr_table type ref to cl_salv_table.

data: gr_container type ref to cl_gui_custom_container.

data: g_okcode type syucomm.

*----


*

  • SELECTION-SCREEN - for demonstration purposes only *

*----


*

selection-screen begin of block gen with frame.

parameters:

p_amount type i default 30.

selection-screen end of block gen.

selection-screen begin of block dsp with frame.

parameters:

p_full radiobutton group dsp,

p_list radiobutton group dsp,

p_grid radiobutton group dsp.

selection-screen end of block dsp.

*----


*

  • START-OF-SELECTION *

*----


*

start-of-selection.

gs_test-amount = p_amount.

gs_test-repid = sy-repid.

case abap_true.

when p_list.

gs_test-display = gc_s_display-list.

when p_full.

gs_test-display = gc_s_display-fullscreen.

when p_grid.

gs_test-display = gc_s_display-grid.

endcase.

perform select_data.

*----


*

  • END-OF-SELECTION *

*----


*

end-of-selection.

case gs_test-display.

when gc_s_display-fullscreen.

perform display_fullscreen.

when gc_s_display-grid.

perform display_grid.

when gc_s_display-list.

perform display_list.

endcase.

*&----


*

*& Form select_data

*&----


*

  • §2 to display the data, you first have to select it in some table

*----


*

form select_data.

select * from mara into corresponding fields of table gt_outtab

up to gs_test-amount rows. "#EC *

endform. " select_data

*&----


*

*& Form display_fullscreen

*&----


*

  • text

*----


*

form display_fullscreen .

*... §2 create an ALV table

  • §2.2 just create an instance and do not set LIST_DISPLAY for

  • displaying the data as a Fullscreen Grid

try.

cl_salv_table=>factory(

importing

r_salv_table = gr_table

changing

t_table = gt_outtab ).

catch cx_salv_msg. "#EC NO_HANDLER

endtry.

*... §3 Functions

*... §3.1 activate ALV generic Functions

data: lr_functions type ref to cl_salv_functions_list.

lr_functions = gr_table->get_functions( ).

lr_functions->set_default( abap_true ).

0.0.0.0.0.0.1. try and serialize

  • data:

  • l_xml type string.

*

  • call transformation id source data = lr_functions

  • result xml l_xml.

*

  • call transformation id source xml l_xml

  • result data = lr_functions.

*

0.0.0.0.0.0.1. try and serialize

*... set the columns technical

data: lr_columns type ref to cl_salv_columns.

lr_columns = gr_table->get_columns( ).

lr_columns->set_optimize( abap_true ).

perform set_columns_technical using lr_columns.

*... §4 display the table

gr_table->display( ).

endform. " display_fullscreen

*&----


*

*& Form display_list

*&----


*

  • text

*----


*

form display_list .

*... §2 create an ALV table

  • §2.1 set LIST_DISPLAY to 'X' for displaying an ALV List

try.

cl_salv_table=>factory(

exporting

list_display = abap_true

importing

r_salv_table = gr_table

changing

t_table = gt_outtab ).

catch cx_salv_msg. "#EC NO_HANDLER

endtry.

*... §3 Functions

*... §3.1 activate ALV generic Functions

data: lr_functions type ref to cl_salv_functions_list.

lr_functions = gr_table->get_functions( ).

lr_functions->set_default( abap_true ).

*... set the columns technical

data: lr_columns type ref to cl_salv_columns.

lr_columns = gr_table->get_columns( ).

lr_columns->set_optimize( abap_true ).

perform set_columns_technical using lr_columns.

*... §4 display the table

gr_table->display( ).

endform. " display_list

*&----


*

*& Form display_grid

*&----


*

  • text

*----


*

form display_grid.

call screen 100.

endform. "display_grid

*&----


*

*& Module d0100_pbo OUTPUT

*&----


*

  • text

*----


*

module d0100_pbo output.

perform d0100_pbo.

endmodule. " d0100_pbo OUTPUT

*&----


*

*& Module d0100_pai INPUT

*&----


*

  • text

*----


*

module d0100_pai input.

perform d0100_pai.

endmodule. " d0100_pai INPUT

*&----


*

*& Form d0100_pbo

*&----


*

  • text

*----


*

form d0100_pbo .

set pf-status 'D0100'.

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.

*... §3 Functions

*... §3.1 activate ALV generic Functions

data: lr_functions type ref to cl_salv_functions_list.

lr_functions = gr_table->get_functions( ).

lr_functions->set_default( abap_true ).

*... set the columns technical

data: lr_columns type ref to cl_salv_columns.

lr_columns = gr_table->get_columns( ).

lr_columns->set_optimize( abap_true ).

perform set_columns_technical using lr_columns.

*... §4 display the table

gr_table->display( ).

endif.

endform. " d0100_pbo

*&----


*

*& Form d0100_pai

*&----


*

  • text

*----


*

form d0100_pai .

case g_okcode.

when 'BACK' or 'EXIT' or 'CANC'.

set screen 0.

leave screen.

endcase.

endform. " d0100_pai

*&----


*

*& Form set_columns_technical

*&----


*

  • text

*----


*

form set_columns_technical using ir_columns type ref to cl_salv_columns.

data: lr_column type ref to cl_salv_column.

try.

lr_column = ir_columns->get_column( 'MANDT' ).

lr_column->set_technical( if_salv_c_bool_sap=>true ).

catch cx_salv_not_found. "#EC NO_HANDLER

endtry.

try.

lr_column = ir_columns->get_column( 'FLOAT_FI' ).

lr_column->set_technical( if_salv_c_bool_sap=>true ).

catch cx_salv_not_found. "#EC NO_HANDLER

endtry.

try.

lr_column = ir_columns->get_column( 'STRING_F' ).

lr_column->set_technical( if_salv_c_bool_sap=>true ).

catch cx_salv_not_found. "#EC NO_HANDLER

endtry.

try.

lr_column = ir_columns->get_column( 'XSTRING' ).

lr_column->set_technical( if_salv_c_bool_sap=>true ).

catch cx_salv_not_found. "#EC NO_HANDLER

endtry.

try.

lr_column = ir_columns->get_column( 'INT_FIEL' ).

lr_column->set_technical( if_salv_c_bool_sap=>true ).

catch cx_salv_not_found. "#EC NO_HANDLER

endtry.

try.

lr_column = ir_columns->get_column( 'HEX_FIEL' ).

lr_column->set_technical( if_salv_c_bool_sap=>true ).

catch cx_salv_not_found. "#EC NO_HANDLER

endtry.

try.

lr_column = ir_columns->get_column( 'DROPDOWN' ).

lr_column->set_technical( if_salv_c_bool_sap=>true ).

catch cx_salv_not_found. "#EC NO_HANDLER

endtry.

try.

lr_column = ir_columns->get_column( 'TAB_INDEX' ).

lr_column->set_technical( if_salv_c_bool_sap=>true ).

catch cx_salv_not_found. "#EC NO_HANDLER

endtry.

endform. " set_columns_technical(

Read only

Former Member
0 Likes
1,105

hi Santosh Marupally thanku for this code....i copied your code and executed it ...there is a error it says cl_salv_table does not exits....what is the mistake....

Read only

0 Likes
1,105

that means you are on lower versions, that class is available from ecc5.0 . i hope you are working on lower version.

Read only

Former Member
0 Likes
1,105

no i working in 6.0

Read only

Former Member
0 Likes
1,105

thanku very much