cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Usage question

Former Member
0 Kudos

i am learning webdynpro so i am new to this.

and i have a question

i have defined a usage to display my data with a alv table.

in the alv usage interfacecontroller i mapped my context node with the data node of the ALV

so i can display my data in the table "lt_liste" with:

DATA lo_nd_alv_list_data TYPE REF TO if_wd_context_node.

DATA lo_el_alv_list_data TYPE REF TO if_wd_context_element.

DATA ls_alv_list_data TYPE wd_this->element_alv_list_data.

lo_nd_alv_list_data = wd_context->get_child_node( name = wd_this->wdctx_alv_list_data ).

lo_el_alv_list_data = lo_nd_alv_list_data->get_element( ).

lo_nd_alv_list_data->bind_table( lt_liste ).

all this works fine.

my problem:

if the user chose another option, i want to display another table "lt_liste1"

this doesnt work because "lt_liste" has another type thand "lt_liste1" and only "lt_liste" is mapped with the alv usage

lo_nd_alv_list_data->bind_table( lt_liste1 ).

doesnt work cause liste1 has the wrong type...

second question:

how can i add a scroll bar to my alv list???

third question:

are there any tutorials or examples at sdn for this ??

thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Regarding scrollbar in ALV, please go to the web dynpro application, then to the properties Tab.

Please select WDTABLENAVIGATION from the F4 help and give the value as 'SCROLLBAR'.

This will set the scrollbar to the ALV.

Thank you.

Former Member
0 Kudos

Thanks, first problem is solved 😃

Answers (3)

Answers (3)

Former Member
0 Kudos

To add scroll bar, the user should go to the 'Parameters' tab and there select WDTABLENAVIGATION via the F4 help and hit SCROLLBAR opposed to the property tab.

uday_gubbala2
Active Contributor
0 Kudos

Hi Bernhard,

You can go through these 2 tutorial:

[Dynamically Creating, Building and Mapping a Context in Web Dynpro HELP.|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6fdae690-0201-0010-a580-d104b459cb44]

[ Using ALV with a Dynamic Context Node in Web Dynpro for ABAP|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4c70444a-0801-0010-7688-9e4bd844b783]

Regards,

Uday

Former Member
0 Kudos

thanks, with this tutorial i finally get it working.

are there more "cookbooks" for webdynpro like this

"Using ALV with a Dynamic Context Node in Web Dynpro for ABAP"

???

uday_gubbala2
Active Contributor
0 Kudos

Hi Bernard,

You will have to just keep searching on SDN and the web. There might be many other resources available which don't turn up just coz we don't come up with a proper search string! You can also go through this extensive [blog by Thomas Jung|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/bf20e84f-0901-0010-fe9e-91d100013a59] for a more complex application in which he re-creates the SE16 TCODE in webdynpro.

Regards,

Uday

Former Member
0 Kudos

Thanks,

i already know this tutorial.

thanks for help!

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

For your first question - you have a couple of choices.

First you could create more than one ALV instance and hide/show the different ALVs depending upon your criteria. This allows everything to be defined statically at design time. You would simply enable/disable the ViewUIElementContainer element that hosts the respective ALV component instances. However having multiple ALVs can get expensive if you need to display a lot of different tables.

If you need to be really dynamic, then I would suggest dynamically creating your context node structure that is bound to the ALV. You can use the API, cl_wd_dynamic_tool=>create_nodeinfo_from_struct, to build the context node dynamically.

data:
    rootnode_info type ref to if_wd_context_node_info,
    dyn_node type ref to if_wd_context_node,
    tabname_node type ref to if_wd_context_node,
    current_tablename type string,
    tablename type string.

*   Create dynamic sub node name TEST1 of structure (tablename)
  cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
    parent_info = rootnode_info
    node_name = tablename
    structure_name = tablename
    is_multiple = abap_true ).

  data: stru_tab type ref to data.
  field-symbols <tab> type table.

*  create internal table that matches the type for our input tablename
  create data stru_tab type table of (tablename).
  assign stru_tab->* to <tab>.

****Logic to populate table dynamically

*  get instance of new node
  dyn_node = wd_context->get_child_node( name = tablename ).

*  Bind internal table to context node
  dyn_node->bind_table( <tab> ).

Third option - which could be a hybrid of the previous two - is to dynamically reassign the ALV component to a different context node. You can do this with the SET_DATA method of the ALV Component Interface.

* Connect to the component Usage of the ALV
  data: l_ref_cmp_usage type ref to if_wd_component_usage.
  l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
  if l_ref_cmp_usage->has_active_component( ) is initial.
    l_ref_cmp_usage->create_component( ).
  endif.

* Through the interface controller of the ALV Component set the DATA node dynamically
  data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .
  l_ref_interfacecontroller =   wd_this->wd_cpifc_alv( ).
  l_ref_interfacecontroller->set_data(
    r_node_data = dyn_node  ).