cancel
Showing results for 
Search instead for 
Did you mean: 

How to loop through purchase order item's with ABSL

0 Kudos

Dear Exports,

I'm totally new to SAP ByD and even more to ABSL coding.

Could you please explain me, how can I retrieve PurchaseOrder items' lines with ABSL.

I need a 2 levels loop through PurchaseOrder and it's Items (ordered articles).

Here is what I came up with:

var query = PurchaseOrder.QueryByElements;

var selectionParams = query.CreateSelectionParams(); selectionParams.Add(query.ID.content,"I","EQ","90");

var resultData = query.Execute(selectionParams);

foreach(var po in resultData){

var currPurchaseOrderItemsQuery = PurchaseOrder.Retrieve(po.UUID).Item.QueryByElements;

var currSelectionParams = currPurchaseOrderItemsQuery.CreateSelectionParams();

var resultCurr = currPurchaseOrderItemsQuery.Execute(currSelectionParams);

foreach (var po1 in resultCurr) {

raise MsgInfo.Create("I","Found article ".Concatenate(po1.ID.content));}

}

I'm getting the error "Identifier 'QueryByElements' does not exist".

It is coused by this line:

var currPurchaseOrderQuery = PurchaseOrder.Retrieve(po.UUID).Item.QueryByElements;

I don't understand why the editor is proposing .QueryByElements after Item when I press ctrl+space, but when I use it, the code evaluation fails.

I haven't found any peace of code which would explain me the way how to get lines of the order.

I will be grateful for some help in this certain problem and maybe if you have, some good links pointing to place where ABSL objects navigation is well explained.

Thank you in advance

Best Regards

Piotr Kowalski

Accepted Solutions (1)

Accepted Solutions (1)

former_member200567
Active Contributor
0 Kudos

Hi Piotr,

You can access the node instances of a parent instance just by using "." operator. You just need another foreach loop to access each item.

var query = PurchaseOrder.QueryByElements;

var selectionParams = query.CreateSelectionParams(); selectionParams.Add(query.ID.content,"I","EQ","90");

var resultData = query.Execute(selectionParams);

foreach(var po in resultData){

var poID = po.ID; // here you can access the elements and nodes of a particular purchase order

foreach(var item in po.Item){

var itemID = item.ID; // here you can access the elements and nodes of a particular purchase order item

}

}

Best Regards,

Fred

0 Kudos

Fred,

thank you very much. You really helped me to move forward 🙂

Best Regards

Piotr

Answers (0)