cancel
Showing results for 
Search instead for 
Did you mean: 

select / deselect all in a Webdynpro Table

Former Member
0 Kudos

Hi.

I´m using standar webdynpro HRECM00_PLANNING_OVERVIEW. This WD is using a table and it seems that inside the table is defining a hierarchy tree or table. The problem is that the user wants the select all and deselect all buttons. But this webdynpro does not have it.

I beleive this is a standard way when you define the table. But the option is never showed. I have look inside the code trying to find if there is any code that disable these option, but I can not find it. The context of the table is define in cardinality and selection as 1 .. n.

I tried to create an Enhacement with the next code

do reg times.

lo_el_planning = lo_nd_planning->get_element( index = sy-index ).

check lo_el_planning is BOUND.

lo_el_planning->SET_SELECTED( 'X' ).

enddo.

But the reg variable Only get 1 row. That is the parent root.

Any help could be useful to select and deselect all elements.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

ChrisPaine
Active Contributor
0 Kudos

Hello,

seems you've got the enhancement functionality to add the select all button - if your code has been successfully triggered.

so here's a bit of code that should do what you want - it's based around the code calling itself recursively down the tree -

the following will do what you want:

method ONACTIONSELECT_ALL . 

  data: lo_node type ref to if_wd_context_node. 
* as this is display only - we'll handle it right here in the view 

* recursively set all elements to selected. 

  lo_node = wd_context->get_child_node( 'ORG_STRUC' ). 

  set_selected( node = lo_node 
                selected = abap_true ). 

endmethod.

In my example the main node was "ORG_STRUC" I think in your case it will be "PLANNING".

and

method set_selected. 

  data: lt_elements type wdr_context_element_set, 
        lo_element type ref to if_wd_context_element, 
        lo_node type ref to if_wd_context_node. 

  lt_elements = node->get_elements( ). 

  loop at lt_elements into lo_element. 

    lo_element->set_selected( selected ). 

    lo_node = lo_element->get_child_node( 'SUB_NODE' ). 

* recursive call 
    set_selected( node = lo_node 
                  selected = selected ). 

  endloop. 
endmethod.

Now in this case the recursive subnode for the table is called "SUB_NODE" - in your specific example I believe it is called "HIERARCHY".

Hope this helps!

Cheers,

Chris

ChrisPaine
Active Contributor
0 Kudos

NB - the above solution also allows for "deselect all" functionality to be implemented pretty simply - but I'll leave that you you to figure out!

Cheers,

Chris

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks for your help. I resolved this a few months ago, but it's now a could post the answer. I finally use part of the standard code of the webdynrpo: RECM00_PLANNING_OVERVIEW

DATA lo_nd_planning TYPE REF TO if_wd_context_node.

DATA lo_el_planning TYPE REF TO if_wd_context_element.

DATA ls_planning TYPE wd_this->Element_planning.

  • DATA selected_element_tab TYPE wdr_context_element_set.

  • navigate from <CONTEXT> to <PLANNING> via lead selection

lo_nd_planning = wd_context->get_child_node( name = wd_this->wdctx_planning ).

DATA is_leaf TYPE boole_d.

DATA selected_crevi TYPE ecm_crevi.

DATA objects TYPE hrwpc_s_keyobjec.

DATA root_objects_tab TYPE hrwpc_t_keyobjec.

DATA child_objects_tab TYPE hrwpc_t_keyobjec.

DATA reg TYPE i.

DATA reg1 TYPE i.

DATA hierarchy_node TYPE REF TO if_wd_context_node.

DATA hierarchy_element TYPE REF TO if_wd_context_element.

DATA sub_element_tab TYPE wdr_context_element_set.

DATA current_element TYPE REF TO if_wd_context_element.

  • node_planning = wd_context->get_child_node( name = wd_this->wdctx_planning ).

lo_el_planning = lo_nd_planning->get_element( ).

CALL METHOD CL_WD_DYNAMIC_TOOL=>SET_TABLE_TREE_LEAD_SELECTION

EXPORTING

LEAD_SELECTION = lo_el_planning

DATA_SOURCE = lo_nd_planning

INCLUDING_SINGLE_SELECTION = ABAP_TRUE

.

*" ===========================================================

*" This is the action handler for the button "Expand All"

*" Here all currently selected nodes in the tree of the

*" planning overview are completely expanded.

*" ===========================================================

DATA node_planning TYPE REF TO if_wd_context_node.

DATA selected_element_tab TYPE wdr_context_element_set.

DATA fpm TYPE REF TO if_fpm.

DATA view_controller TYPE REF TO if_wd_view_controller.

view_controller = wd_this->wd_get_api( ).

fpm = cl_fpm_factory=>get_instance( ).

  • " Determine currently selected nodes

node_planning = wd_context->get_child_node( name = wd_this->wdctx_planning ).

selected_element_tab = cl_wd_dynamic_tool=>get_table_tree_selection(

data_source = node_planning

including_lead_selection = wd_assist->false ).

IF LINES( selected_element_tab ) IS INITIAL.

" No orgunit selected

fpm->mo_message_manager->report_t100_message(

EXPORTING iv_msgid = wd_assist->c_hrecm00_ui_overview

iv_msgno = '001'

io_component = view_controller ).

ELSE.

" Expand the nodes

wd_this->expand_nodes( EXPORTING element_tab = selected_element_tab

action = wd_assist->c_expand_nodes ).

ENDIF.

  • lv_is_ok = wd_this->selec_all_nodes(

  • LO_ND_PLANNING = LO_ND_PLANNING

  • nodes = lo_el_planning ).

DATA lv_is_ok TYPE boole_d.

lv_is_ok = wd_this->select_node(

currente_element = lo_el_planning " ref to if_wd_context_element

node = lo_nd_planning " ref to if_wd_context_node

).

former_member187452
Contributor
0 Kudos

Hi,

Select All / Deselect All is available in table.

For that use cardinality of table as 0:N and Selection as 0:N for the node of that table and in the properties of the table choose selection mode as ' MULTI ' .

Then the option will be available in top left corner of the table.

Regards,

Bharat

Former Member
0 Kudos

Hello.

but in this case I can not change the cardinality of the context I guess. I don´t know if I could change any behaveor of the standar webdypro.

Is there any other posibility?

thanks.

Former Member
0 Kudos

You can ehnance the standard webynpro component, using enhancement framework.

How to do this: Go through this [article|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/700317da-bd79-2c10-368e-8f18bf5d8b81].

Regards

Manas Dua