cancel
Showing results for 
Search instead for 
Did you mean: 

Query Parent node

Former Member
0 Kudos

Hi Experts,

I have a BO like this as below

element name:Text;

node parentNode[0,1]{

     element count:Amount;

}

when i query the BO i can't get parent node, the element count.

how can i get the element?

Best Regards,

Thanarat

Accepted Solutions (1)

Accepted Solutions (1)

former_member200567
Active Contributor
0 Kudos

Hi Thanarat,

You can use foreach loop to access the node elements.


var query = BOName.QueryByElements;

var selParams = query.CreateSelectionParams();

     selParams.Add(query.ID.content,"I","EQ","123");

var results = query.Execute(selParams);

foreach(var result in results) {

    foreach( var item in result.ParentNode){

               // you can access node elements here.

          var elementCount= item.count;

     }

}

Best Regards,

Fred

Answers (2)

Answers (2)

former_member186648
Active Contributor
0 Kudos

Hi Thanarat,

You could also create custom query and include both Root and Parent node in single query and then execute the query:

Refer to create query: http://help.sap.com/saphelpiis_studio_1508/studio_od_1508.pdf

Section: 8.3.3.4 Create a Query


Thanks, Pradeep.

sunil1101
Advisor
Advisor
0 Kudos

Hi

You should read inside the loop or make a collection

for example

In BO


import AP.Common.GDT as apCommonGDT;

businessobject IDGenerator {

       [AlternativeKey]element NewID:IntegerValue;

   node ParentNode[0,1]{

  element Count1:Amount;

  }

}

in BeforeSave of Other BO where I am querying BO IDGenerator

Option 1 to read in loop


var qry = IDGenerator.QueryByElements.Execute();

foreach(var ins in qry){

var X = ins.ParentNode.Count1.content;

}

Option2 to read in local variable a


var coll :  collectionof IDGenerator;

coll = qry.OrderByDescending(n => n.NewID);

var a = coll.GetFirst().ParentNode.Count1.content;

Regards

Sunil