cancel
Showing results for 
Search instead for 
Did you mean: 

How to create alv table dynamically by performing action on the button.

Former Member
0 Kudos

Hi all,

my requirement is to create alv table dynamically.

that is i will create two buttons

1) show alv table

2) close alv table

if user selects show alv table then the alv table should be displayed.

and if user selects clsoe alv table then the alv table should be closed.

to create alv table dynamically i have followed this procedure.

under view properties i have added salv_wd_table component. then under the action of showalvbutton i went to code wizard and i have selected instantiate used component component use salv_wd_table. the following code will be generated

with this code i am unable to display alv table dynamically correct me where i went wrong kindly send me the necessary steps how to create alv table dynamically

data lo_cmp_usage type ref to if_wd_component_usage.

lo_cmp_usage = wd_this->wd_cpuse_salv_wd_table( ).

if lo_cmp_usage->has_active_component( ) is initial.

lo_cmp_usage->create_component( ).

endif.

to close table i have used the following code. with this code i am able to achieve the functionality to delete the alv table

data lo_cmp_usage type ref to if_wd_component_usage.

lo_cmp_usage = wd_this->wd_cpuse_salv_wd_table( ).

if lo_cmp_usage->has_active_component( ) is initial.

else.

lo_cmp_usage->Delete_component( ).

endif.

Thanks & Regards,

Naveen

Edited by: naveen.webhelp on Feb 10, 2011 5:52 AM

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

Hi

ALV table will be shown in the viewcontainerUI element.

it is shown there empty if you dont fill the node bound to the data node of the interface controller of the comp usage

SALV_WD_TABLE.

and if you are not getting the table filled in the first place.

then check have you mapped the DATA node to some node in the comp controller

wht basically is your requirment is that you want to show ALV gird on click of one button and delete it on click of other button.

there are many ways to do so.

best way is control the visiblity of the viewcontainer UI element which containes the TABLE view of SALV_WD_table comp.

create an attribute of type WDUI_VISIBILITY name say VIS.

now go to the layout and bound hte visible property of the viewcontainer to this attribute VIS.

then in the showalv grid button's eventhandler write



wd_context->set_attribute( 
name = 'VIS'
value = '02'
).

and in the wddoinit and delete alv grid button's event handler write



wd_context->set_attribute( 
name = 'VIS'
value = '01'
).

thanks

sarbjeet singh

Former Member
0 Kudos

Hi Sarbjeet,

Thanks it is working.

Thanks & Regards,

Naveen

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Please don't use 01 and 02 in your coding to control visiblity. Always use the constants such as CL_WD_UIELEMENT=>E_VISIBLE-NONE or CL_WD_UIELEMENT=>E_VISIBLE-VISIBLE. It increases readability but also protects against future changes to the values to represent these states.

Answers (1)

Answers (1)

karthik_saravanan
Discoverer
0 Kudos

Hi All,

thanks for valuable ideas.

Ya ,its working good