Hello everyone,
I am not able to find the exact difference between singleton vs non singleton concept.I have created a simple application
Node Vbak(fields: Vbeln ,Ernam) under this child node Vbap(Fields: Vbeln,Posnr,Matnr)(Singleton).
In Vbak -Winit method -:
types: begin of ty,
vbeln type vbeln_va,
ernam type ernam,
end of ty.
* tt type ty.
data: it type STANDARD TABLE OF ty,
wa type ty.
select vbeln ernam into table it up to 20 rows from vbak.
DATA LO_ND_VBAK TYPE REF TO IF_WD_CONTEXT_NODE.
DATA LO_EL_VBAK TYPE REF TO IF_WD_CONTEXT_ELEMENT.
DATA LS_VBAK TYPE WD_THIS->ELEMENT_VBAK.
* navigate from <CONTEXT> to <VBAK> via lead selection
LO_ND_VBAK = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_VBAK ).
CALL METHOD LO_ND_VBAK->BIND_TABLE
EXPORTING
NEW_ITEMS = IT.
Created a supply function module for Node VBAP(Property:Singleton,Cardinality:0..1,selection:0..n) followed by code:
DATA ls_parent_attributes TYPE wd_this->element_vbak.
data:context_node type ref to if_wd_context_node.
parent_element->get_static_attributes(
IMPORTING
static_attributes = ls_parent_attributes ).
TYPES: BEGIN OF ty1,
vbeln type vbeln_va,
posnr TYPE posnr,
matnr type matnr,
end of ty1.
data: t_vbap TYPE STANDARD TABLE OF ty1.
select vbeln posnr matnr into table t_vbap from vbap where vbeln = ls_parent_attributes-vbeln.
DATA LO_ND_VBAP TYPE REF TO IF_WD_CONTEXT_NODE.
DATA LO_EL_VBAP TYPE REF TO IF_WD_CONTEXT_ELEMENT.
DATA LS_VBAP TYPE WD_THIS->ELEMENT_VBAP.
LO_ND_VBAP = WD_CONTEXT->PATH_GET_NODE( PATH = `VBAK.VBAP` ).
* navigate from <CONTEXT> to <VBAP> via lead selection
CALL METHOD LO_ND_VBAP->BIND_TABLE
EXPORTING
NEW_ITEMS = T_VBAP.
Now, if property is not set to Singleton,one instance per parent instance exists. The content of the instances does not change when the lead selection of the parent changes.
Removed Singleton property for Vbap:When I debug the supply FM and select different sale order number (different lead selection) the instance(sale order number) is changing which should not happen as per the above definition.However Iam unable to find any difference either singleton/non singleton in debugging mode.
Please let me know if I am missing anything.
Regards,
P.D