You are on page 1of 13

method WDDOINIT .

DATA lo_nd_ekbe1 TYPE REF TO if_wd_context_node.


DATA ls_ekbe1 TYPE wd_this->Element_ekbe1.
DATA lt_ekbe1 TYPE wd_this->Elements_ekbe1.
*

navigate from <CONTEXT> to <EKBE1> via lead selection


lo_nd_ekbe1 = wd_context->get_child_node( name = wd_this->wdctx_ekbe1 )

.
*
*
*

@TODO handle non existant child


IF lo_nd_ekbe1 IS INITIAL.
ENDIF.

* * @TODO compute values


* * e.g. call a model function
SELECT *
INTO CORRESPONDING FIELDS OF TABLE LT_EKBE1
FROM EKBE
WHERE EBELN LIKE '414-%'.
lo_nd_ekbe1->bind_table( new_items = lt_ekbe1
set_initial_elements = abap_false ).
*
CALL METHOD LO_ND_EKBE1->SET_LEAD_SELECTION_INDEX
*
EXPORTING
*
INDEX = 700
*
.
endmethod.

method ONACTIONADD .
DATA lo_nd_ekbe1 TYPE REF TO if_wd_context_node.
DATA lo_el_ekbe1 TYPE REF TO if_wd_context_element.
DATA ls_ekbe1 TYPE wd_this->Element_ekbe1.
*

navigate from <CONTEXT> to <EKBE1> via lead selection


lo_nd_ekbe1 = wd_context->get_child_node( name = wd_this->wdctx_ekbe1 )

.
*
*
*

@TODO handle non existant child


IF lo_nd_ekbe1 IS INITIAL.
ENDIF.

get element via lead selection


lo_el_ekbe1 = lo_nd_ekbe1->get_element( ).
alternative access via index
lo_el_ekbe1 = lo_nd_ekbe1->get_element( index = 1 ).
@TODO handle not set lead selection
IF lo_el_ekbe1 IS INITIAL.
ENDIF.

*
*
*

get all declared attributes


lo_el_ekbe1->get_static_attributes(
IMPORTING
static_attributes = ls_ekbe1 ).
DATA lo_nd_ekbe2 TYPE REF TO if_wd_context_node.

DATA ls_ekbe2 TYPE wd_this->Element_ekbe2.


* navigate from <CONTEXT> to <EKBE2> via lead selection
lo_nd_ekbe2 = wd_context->get_child_node( name = wd_this->wdctx_ekbe2 ).
* @TODO handle non existant child
* IF lo_nd_ekbe2 IS INITIAL.
* ENDIF.
ls_ekbe2 = ls_ekbe1.
* append a line to the node
lo_nd_ekbe2->bind_structure( new_item = ls_ekbe2
set_initial_elements = abap_false
INDEX = 1 ).
endmethod.
method ONACTIONREMOVE .
DATA lo_nd_ekbe2 TYPE REF TO if_wd_context_node.
DATA lo_el_ekbe2 TYPE REF TO if_wd_context_element.
DATA ls_ekbe2 TYPE wd_this->Element_ekbe2.
*
.
*

navigate from <CONTEXT> to <EKBE2> via lead selection


lo_nd_ekbe2 = wd_context->get_child_node( name = wd_this->wdctx_ekbe2 )
get element via lead selection
lo_el_ekbe2 = lo_nd_ekbe2->get_element( ).
lo_nd_ekbe2->REMOVE_ELEMENT( lo_el_ekbe2 ).

endmethod.

method ONACTIONDESELECT .
*First identiufy the number of elements a node has.
*So that we can loop those many times.
DATA lo_nd_ekbe1 TYPE REF TO if_wd_context_node.
DATA lo_el_ekbe1 TYPE REF TO if_wd_context_element.
DATA ls_ekbe1 TYPE wd_this->Element_ekbe1.
* navigate from <CONTEXT> to <EKBE1> via lead selection
lo_nd_ekbe1 = wd_context->get_child_node( name = wd_this->wdctx_ekbe1 ).
data lv_count type i.
lv_count = LO_ND_EKBE1->GET_ELEMENT_COUNT( ).
data lv_bool type abap_bool.
do lv_count times.
CALL METHOD LO_ND_EKBE1->IS_SELECTED
EXPORTING
INDEX = sy-index
RECEIVING
FLAG
= lv_bool
.

if lv_bool = abap_true.
CALL METHOD LO_ND_EKBE1->SET_SELECTED
EXPORTING
FLAG
= ABAP_false
INDEX = sy-index
.
endif.
enddo.
endmethod.
method ONACTIONREFRESH .
DATA lo_nd_ekbe2 TYPE REF TO if_wd_context_node.
DATA lo_el_ekbe2 TYPE REF TO if_wd_context_element.
DATA ls_ekbe2 TYPE wd_this->Element_ekbe2.
*
.

navigate from <CONTEXT> to <EKBE2> via lead selection


lo_nd_ekbe2 = wd_context->get_child_node( name = wd_this->wdctx_ekbe2 )
lo_nd_ekbe2->INVALIDATE( ).

endmethod.

method ONACTIONREMOVE_MUL .
*First identify how many records are selected in the node
*1. Get the node reference
DATA lo_nd_ekbe2 TYPE REF TO if_wd_context_node.
DATA lo_el_ekbe2 TYPE REF TO if_wd_context_element.
DATA ls_ekbe2 TYPE wd_this->Element_ekbe2.
*

navigate from <CONTEXT> to <EKBE2> via lead selection


lo_nd_ekbe2 = wd_context->get_child_node( name = wd_this->wdctx_ekbe2 )

.
*2 Using the node reference call the method GET_SELECTED_ELEMENTS
DATA LT_ELEMENTS TYPE TABLE OF REF TO IF_WD_CONTEXT_ELEMENT.
DATA WA TYPE REF TO IF_WD_CONTEXT_ELEMENT.
CALL METHOD lo_nd_ekbe2->GET_SELECTED_ELEMENTS
EXPORTING
INCLUDING_LEAD_SELECTION = ABAP_true
RECEIVING
SET
= lt_elements
.
LOOP AT LT_ELEMENTS INTO WA.
lo_nd_ekbe2->REMOVE_ELEMENT( WA ).
ENDLOOP.

endmethod.

method ONACTIONSELECT_ALL .
*First identiufy the number of elements a node has.
*So that we can loop those many times.
DATA lo_nd_ekbe1 TYPE REF TO if_wd_context_node.
DATA lo_el_ekbe1 TYPE REF TO if_wd_context_element.
DATA ls_ekbe1 TYPE wd_this->Element_ekbe1.
* navigate from <CONTEXT> to <EKBE1> via lead selection
lo_nd_ekbe1 = wd_context->get_child_node( name = wd_this->wdctx_ekbe1 ).
data lv_count type i.
lv_count = LO_ND_EKBE1->GET_ELEMENT_COUNT( ).
do lv_count times.
CALL METHOD LO_ND_EKBE1->SET_SELECTED
EXPORTING
*
FLAG
= ABAP_TRUE
INDEX = sy-index
.
enddo.
endmethod.

method ONACTIONREFRESH .
DATA lo_nd_ekbe2 TYPE REF TO if_wd_context_node.
*

navigate from <CONTEXT> to <EKBE2> via lead selection


lo_nd_ekbe2 = wd_context->get_child_node( name = wd_this->wdctx_ekbe2 ).
lo_nd_ekbe2->INVALIDATE( ).

endmethod.

method POPULATE_DATA_VBAK .
* General Notes
* =============
* A common scenario for a supply method is to aquire key
* informations from the parameter <parent_element> and then
* to invoke a data provider.
* A free navigation thru the context, especially to nodes on
* the same or deeper hierachical level is strongly discouraged,
* because such a strategy may easily lead to unresolvable
* situations!!
*
*
*
*
*

if necessary, get static attributes of parent element


DATA ls_parent_attributes TYPE wd_this->element_context.
parent_element->get_static_attributes(
IMPORTING
static_attributes = ls_parent_attributes ).

*
** data declaration

DATA lt_vbak TYPE wd_this->Elements_vbak.


* DATA ls_vbak LIKE LINE OF lt_vbak.
** @TODO compute values
** e.g. call a data providing FuBa
SELECT *
INTO CORRESPONDING FIELDS OF TABLE LT_VBAK
FROM VBAK
UP TO 20 ROWS.
** bind all the elements
node->bind_table(
new_items
= lt_vbak
set_initial_elements = abap_true ).
*
endmethod.

method POPULATE_DATA_VBAP .
*
*
*
*
*
*
*
*
*

General Notes
=============
A common scenario for a supply method is to aquire key
informations from the parameter <parent_element> and then
to invoke a data provider.
A free navigation thru the context, especially to nodes on
the same or deeper hierachical level is strongly discouraged,
because such a strategy may easily lead to unresolvable
situations!!

* if necessary, get static attributes of parent element


** data declaration
DATA lt_vbap TYPE wd_this->Elements_vbap.
* if necessary, get static attributes of parent element
DATA ls_parent_attributes TYPE wd_this->element_vbak.
parent_element->get_static_attributes(
IMPORTING
static_attributes = ls_parent_attributes ).
SELECT *
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE LT_VBAP
WHERE VBELN = LS_PARENT_ATTRIBUTES-VBELN.
*
**
**
*
**

DATA ls_vbap LIKE LINE OF lt_vbap.


@TODO compute values
e.g. call a data providing FuBa
bind all the elements
node->bind_table(
new_items
= lt_vbap
set_initial_elements = abap_true ).
DATA lo_nd_count TYPE REF TO if_wd_context_node.
DATA lo_el_count TYPE REF TO if_wd_context_element.
DATA ls_count TYPE wd_this->Element_count.
DATA lv_count1 TYPE wd_this->Element_count-count1.

navigate from <CONTEXT> to <COUNT> via lead selection


lo_nd_count = wd_context->get_child_node( name = wd_this->wdctx_count )

.
*
*
*

@TODO handle non existant child


IF lo_nd_count IS INITIAL.
ENDIF.

get element via lead selection


lo_el_count = lo_nd_count->get_element( ).

@TODO handle not set lead selection


IF lo_el_count IS INITIAL.
ENDIF.

*
@TODO fill attribute
*
lv_count1 = 1.
CALL METHOD NODE->GET_ELEMENT_COUNT
RECEIVING
COUNT = lv_count1

.
set single attribute
lo_el_count->set_attribute(
name = `COUNT1`
value = lv_count1 ).

endmethod.

endmethod.
---------------method ONACTIONADD_MULT .
DATA lo_nd_ekbe1 TYPE REF TO if_wd_context_node.
DATA lo_el_ekbe1 TYPE REF TO if_wd_context_element.
DATA ls_ekbe1 TYPE wd_this->Element_ekbe1.
DATA lo_nd_ekbe2 TYPE REF TO if_wd_context_node.
DATA ls_ekbe2 TYPE wd_this->Element_ekbe2.
DATA lt_ekbe2 TYPE wd_this->Elements_ekbe2.
DATA lt_elements type TABLE OF REF TO if_wd_context_element.
DATA wa type REF TO if_wd_context_element.
* navigate from <CONTEXT> to <EKBE1> via lead selection
lo_nd_ekbe1 = wd_context->get_child_node( name = wd_this->wdctx_ekbe1 ).
* navigate from <CONTEXT> to <EKBE2> via lead selection
lo_nd_ekbe2 = wd_context->get_child_node( name = wd_this->wdctx_ekbe2 ).
CALL METHOD LO_ND_EKBE1->GET_SELECTED_ELEMENTS
EXPORTING
INCLUDING_LEAD_SELECTION = ABAP_FALSE
RECEIVING
SET
= lt_elements
.
LOOP AT lt_elements into wa.
*
lo_el_ekbe1->get_static_attributes(
*
IMPORTING
*
static_attributes = ls_ekbe1 ).
CALL METHOD WA->GET_STATIC_ATTRIBUTES
IMPORTING
STATIC_ATTRIBUTES = LS_EKBE1
.
APPEND ls_ekbe1 TO lt_ekbe2.
ENDLOOP.
* @TODO compute values
* e.g. call a model function
*
lo_nd_ekbe2->bind_table( new_items = lt_ekbe2 set_initial_elements = abap_false ).
endmethod.
----------------------------------------------------------------------

You might also like