Hello Mohamed,
Since u say there would be large data when u try to get all the company hierarchy related details and it might hamper the performance, for this below would be my suggestions as per my knowledge.
Just an example:
Have a single service with different entities which can get all ur sub item details and list of company codes as well.
1. Have Parent Entity say CompanyData which will hold company code. May be we can call this as header details of the company.
2. Have Child Entity say CompSub1 which will hold your 1st child info ( ur 1st sub node data )
3. Have Child Entity say CompSub2 which will hold your 2nd child node ( ur 2nd sub node data )
4. Create entity sets for all the entity types.
Create Association & Navigation between the entities as per ur needs.
Fire the service as below :
Initially u can display all the company codes :
URL :
/sap/opu/odata/sap/SampleServiceCompCode/CompanyDataSet ( this would just list all the company codes with out sub node details )
When the user clicks on sub node say he click on a sub node to get data related to CompSub1
( ur 1st sub node data ). Then fire the service as Below :
URL :
/sap/opu/odata/sap/SampleServiceCompCode/CompanyDataSet(CompCode='0100')?$expand=SubNode1 ( this would just get sub node 1 data alone )
Where SubNode1 is the navigation property.
When the user clicks on sub node say he click on a sub node to get data related to CompSub2
( ur 2nd sub node data ). Then fire the service as Below :
URL :
/sap/opu/odata/sap/SampleServiceCompCode/CompanyDataSet(CompCode='0100')?$expand=SubNode2 ( this would just get sub node 2 data alone )
Where SubNode2 is the navigation property.
If at all U need both sub node 1 and sub node 2 data in one go then fire as below :
URL :
/sap/opu/odata/sap/SampleServiceCompCode/CompanyDataSet(CompCode='0100')?$expand=SubNode1,SubNode2 ( this would just both node 1 & node 2 details )
This way u can use a single service and fetch item level data as when its required as above example.
U can also use filters as well to pass inputs and achieve the same depending on ur use case.
Please refer :
Expand in Framework and Data Provider - SAP NetWeaver Gateway - SAP Library
U can also use Expand functionality by just implementing Get_Entity and Get_Entity_Set as well.
Its all depends the use case and logic we use for a use case.
Regards,
Ashwin