Skip to Content

In this blog let us visit how to traverse across the BOL hierarchy to retrieve the right entity.

Let us consider the following BOL structure:




Suppose you have an instance of root node ‘Vehicle’, lo_vehicle.

How would you get the instance of object ‘Car’?

Suppose, if ‘manufacturer’ is an attribute of ‘Car’, how can you select only those instances of ‘Car’ manufactured by Hyandai?


In conventional way, one would have to:

=> Step 1: Get the collection of  object ‘Four Wheeler’: lo_vehicle->get_related_entities( iv_relation_name = ‘VehicleFwRel)’.

=> Step 2: Select the relevant instance of ‘Four Wheeler’ from the collection instance that you got in first step.

=> Step 3: Perform the above Step 1, Step 2 for ‘Four Wheeler’ to ‘Car’, just like you did for ‘Vehicle’ to ‘Four Wheeler’.

=> Step 4: In Step 4, you have got the collection instance of ‘Car’. To retrieve, only those ‘Car’ instances, whose manufacturers are ‘Hyundai’, one would have to get each instances of ‘Car’ from its collection, and then get the value of attribute ‘Manufacturer’ and check if it is ‘Hyundai’.


The above steps can be condensed if one gets the entities by bpath. The following will explain how:

lv_bpath = ‘./VehicleFwRel/FwCarRel[@MANUFACTURER=”HYUNDAI”]’.

lo_car_col ?= lo_vehicle->get_related_entities_by_bpath( iv_bpath_statement = lv_bpath ).

So, here the lo_car_col will have only those instances of ‘Car’ whose ‘Manufacturer’ is ‘Hyundai’.

Hence, the usage of getting entities by bpath will reduce the lines of code. But one has to be careful of the content for lv_bpath. Or else, you might get unintended results. One needs to remember the following points with this approach:

  • Here ‘.’ is the current instance (in this case lo_vehicle is Vehicle Object)
  • ‘VehicleFwRel’, ‘FwCarRel’ are the relation names and not object names.
  • ‘APPT_TYPE’ is the name of the target object attribute name (in this case attribute name of object ‘Car’). Basically, it is used as relation filter for the target BOL instances.
To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply