cancel
Showing results for 
Search instead for 
Did you mean: 

Performing READ Operation to Navigation Properties using OData Service Consumption Model in RAP

Sijin_Chandran
Active Contributor

Hello Gurus,

I need to perform a read to an EntitySet using it's corresponding Navigation Property and hence need to make a query to a Primary EntitySet and then route to this EntitySet using Navigation Property. And this I need to do using Service Consumption Model in RESTful Application Programming model and I need to pass filters for both the EntitySets.

Below is the example:

/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_Supplier('1000000306')/to_SupplierPurchasingOrg(Supplier='1000000306',PurchasingOrganization='P002')

My query is how I can create this type of query in Service Consumption model, I have done it for Single Entity set and the example is below:

 

      "Navigate to the resource and create a request for the read operation
      lo_request_read_list = lo_client_proxy->create_resource_for_entity_set( 'A_PURCHASE_ORDER_ITEM' )->create_request_for_read( ).

      "Fill the filter values
      lt_range_requirement_tracking  = VALUE #(
                                                sign   = 'I'
                                                option = 'EQ'
                                                (
                                                  low    = |{ i_shipment_id }|
                                                )
                                              ).

      "Create the filter tree
      lo_filter_factory = lo_request_read_list->create_filter_factory( ).

      lo_filter_node_1  = lo_filter_factory->create_by_range( iv_property_path = 'REQUIREMENT_TRACKING'
                                                              it_range         = lt_range_requirement_tracking ).

      lo_filter_node_root = lo_filter_node_1.
      lo_request_read_list->set_filter( lo_filter_node_root ).

      "Execute the request and retrieve the business data
      lo_response_read_list = lo_request_read_list->execute( ).

 

And also for routing to Navigation Properly I could see 'navigate_with_keys' option is there, but my question is how to pass the Key for the Primary Entity Set, like in the example here A_Supplier('1000000306').

In short, I am requesting hints on how to Trigger OData request using OData Service Consumption Model for below uri:

/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_Supplier('1000000306')/to_SupplierPurchasingOrg(Supplier='1000000306',PurchasingOrganization='P002')

My actual scenario is below one: which has 2 levels of Navigation:

/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('1000000306')/to_Supplier/to_SupplierPurchasingOrg(Supplier='1000000306',PurchasingOrganization='P002')

As of now I have a workaround, that I will break all these into Individual EntitySet READs but if this could be done in one single call it would be great.

Helpful comments much appreciated.

Thanks,

Sijin

 

Accepted Solutions (1)

Accepted Solutions (1)

Sijin_Chandran
Active Contributor

Below blog which explains on utilizing $Expand for such kind of scenario will definitely help for such  requirements:

https://community.sap.com/t5/technology-blogs-by-members/usage-of-expand-entity-in-odata-service-con...

Thanks,

Sijin

Answers (0)