Skip to Content
0
Former Member
Nov 20, 2012 at 08:42 AM

TreeByKeyTableColumn issue

30 Views

Hello,

I have created a webdynpro to show a list of functional locations (hierarchicly).

This works fine, but now the customer wants to add the equipments (another object type that is linked to the functional location).

I just added the objects to the table with a different icon but with the same logic (filled the key as equipment number and parent key = functional location number)

This doesn't work for the equipments, they are never shown and I've already played alot with the keys an other possibilities. Any insight maybe?

Here is the code to fill the table:

 DATA:

lt_equipments TYPE STANDARD TABLE OF rihequi,

ls_equipments LIKE LINE OF lt_equipments,

lt_func_locs TYPE STANDARD TABLE OF rihiflo,

ls_func_locs LIKE LINE OF lt_func_locs,

lt_materials TYPE STANDARD TABLE OF rihstpx,

lt_flocs TYPE if_main=>elements_func_locs,

ls_flocs LIKE LINE OF lt_flocs,

lo_nd_func_locs TYPE REF TO if_wd_context_node.



CALL FUNCTION 'PM_HIERARCHY_CALL'

EXPORTING

levdo = 15

tplnr = tplnr

select_equi = fill_equnr

select_iflo = fill_tplnr

select_stpo = fill_matr

selmod = 'D'

with_equi = fill_equnr

with_equi_hier = fill_equnr

with_iflo_hier = fill_tplnr

with_mara = fill_matr

TABLES

equi_tab = lt_equipments

iflo_tab = lt_func_locs

stpo_tab = lt_materials

EXCEPTIONS

no_hierarchy = 1

no_object_defined = 2

no_selection = 3

no_valid_equnr = 4

no_valid_matnr = 5

no_valid_selmod = 6

no_valid_tplnr = 7

no_valid_grbom_werks = 8

OTHERS = 9.



** Functional locations

IF fill_tplnr EQ abap_true.

** Fill context

LOOP AT lt_func_locs INTO ls_func_locs.

CLEAR ls_flocs.

MOVE ls_func_locs-pltxt TO ls_flocs-name.

MOVE ls_func_locs-tplnr TO ls_flocs-path.

MOVE ls_func_locs-tplma TO ls_flocs-parent_path.

IF lt_flocs IS INITIAL.

MOVE abap_true TO ls_flocs-is_expanded.

CLEAR ls_flocs-parent_path.

ELSE.

MOVE abap_false TO ls_flocs-is_expanded.

ENDIF.

READ TABLE lt_func_locs TRANSPORTING NO FIELDS

WITH KEY tplma = ls_func_locs-tplnr.

IF sy-subrc IS INITIAL.

MOVE abap_false TO ls_flocs-is_leaf.

ELSE.

MOVE abap_true TO ls_flocs-is_leaf.

ENDIF.

MOVE ls_func_locs-pltxt TO ls_flocs-value.

MOVE 'ICON_TECHNICAL_PLACE' TO ls_flocs-icon.

APPEND ls_flocs TO lt_flocs.

ENDLOOP.

ENDIF.



** Equipments

IF fill_equnr IS NOT INITIAL.

LOOP AT lt_equipments INTO ls_equipments.

CLEAR ls_flocs.

MOVE ls_equipments-eqktx TO ls_flocs-name.

MOVE ls_equipments-equnr TO ls_flocs-path.

MOVE ls_equipments-tplnr TO ls_flocs-parent_path.

MOVE ls_equipments-eqktx TO ls_flocs-value.

MOVE 'ICON_EQUIPMENT' TO ls_flocs-icon.

APPEND ls_flocs TO lt_flocs.

ENDLOOP.

ENDIF.



lo_nd_func_locs = wd_context->get_child_node( name = wd_this->wdctx_func_locs ).

CALL METHOD lo_nd_func_locs->bind_table

EXPORTING

new_items = lt_flocs.