cancel
Showing results for 
Search instead for 
Did you mean: 

hi! regarding the singleton property in webdynpro abap

Former Member
0 Kudos

Hi experts ,

Could anyone explain me in detail the property of singleton and wht r the conditions tht we should use wht will represents..

plz explain me in detail......rather than sending links plz do explain me in detail....

Regards,

Sana...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi misbah......

this is used for instantiating an element only once....

check this link

[link|help.sap.com/saphelp_erp2005/helpdata/en/7a/787e40417c6d1de10000000a1550b0/content.htm]

---regards,

alex b justin

Answers (4)

Answers (4)

Srisap
Participant
0 Kudos

Hello,

To understand this correctly....compare it with LOOP statement like this....

Consider the Loop statement having a control break statement AT NEW MATNR. Whenever the value of MATNR changes this statement is executed and some logic inside it is executed.

Similarly, for the context node, when the value of the selected element in the node changes to something else i.e. the supply function method is triggered and code is executed in it.

Consider for example in case of Loop statement logic you want to get the material description.

For lead selection change of context node you want to update the material description on the view by making a select from the database.

I hope you have undrstood what I have written above.

Please award points if satisfied.

Regards,

Sridhar Karra.

Former Member
0 Kudos

Cardinality : number of possible elements within the node.

Singleton property means whether or not all instances of this node get created at runtime or not.

Singleton property is mostly used to save memory & increase performance. we would go for singleton nodes in cases where UI needs only display from one-instance of data from my node.....

What happens when you set singleton property to YES for a node?? Assume you have context structure like

Context

Vehicle( parent node )

( attribute veh-ID primary key for all types of vehicles, dealer, area )

twowheeler( subnode of vehicle with cardinality-0..n singleton-NO)

( attributes veh-ID, regno, model, color)

fourwheeler( subnode of vehicle with cardinality-0..n singleton-YES)

( attributes veh-ID, regno, model, color)

At design time you fill the data within this context. Now you have 100 entries under the subnode twowheeler & 90 entries under the subnode fourwheeler . You create UI elements to display the node twowheeler details in a View . At runtime when user selects the veh-ID and identifies that a twowheeler data needs to be fetched/displayed all the 100 entries for the twowheeler node get created in the background although you are displaying only the ONE corresponding to the veh-ID.

if Veh-ID selected coresponded to fourwheeler( singleton property -yes) only ONE row of the data from the fourwheeler entries would have been fetched and ONLY Once instance of the fourwheeler would be created by background process!!

thus saving memory & processing time.

Scenarios singleton-YES

If i were required to display details of only ONE vehicle based on the entered Veh-ID , i will make twowheeler & fourwheeler nodes singleton-YES.

Scenario singleton-NO

if i were required to show all the vehicles that belong to one particular Area.

Former Member
0 Kudos

Hi Misbah Sultana,

singleton property defines the number of instance of a perticular node.

suppose there is a node A and node A is having a sub node B, if node a is singleton selected means there exist only one instance of B for a.

Eg: if in node A we are populating flight details from Sflight and in node b we want to populate booking details for each flight in node A.

then if A is singletone selected means, for the selected record there will be corresponding details in B, ie if record ofFlight AA is selected in A, then booking details for flight AA is populated in Node B.

if node A is not singleton selected then, booking details for all the flights in Node A will be there in Node b at every instance.

usually singlton proprty, we are using with supply function, we usually in the abouve example will give a supply fn to node b, so that based on the selection of a record in node a, supply function will populate corresponding record to node B.

regards

Sarath

Former Member
0 Kudos

Hi Misbah.

Consider a parent context node with sub nodes. When you set the parent node to singleton the

subnodes of an element of this parent node only exist when the lead selection is set to this element. As soon as the lead selection is set to a certain element the subnodes are initialized and the supply c methods are called.

Just read the link alex posted carefully.

Cheers,

Sascha