Hey folks,
I have been playing around with SAP Gateway setting up the necessary data models etc via the Gateway service builder ( I am on SP06 ).
I defined my custom data model based on custom data tables and defined a number of 'associations'.
I built a couple of custom RFC function modules with the necessary import ranges to act like potential filters, etc ...
A service model has been generated using an RFC for the 'Get_EntitySets' ...
When I test the standard QUERY then that works fine ... data is returned as expected ... also with filters, etc ...
When I wanted to test the 'association' then I noticed that the standard generated 'x_Get_EntitySet' method does not contain any code for taking 'associations' into account ...
No worries though ... after a quick thought my plan seemed simply ...
Redefine the method, check whether a navigation path is available, grab its keys and populate the filter options table ( as the navigation key is one of the filters of my RFC ) and call the default implemenation with the provided filters ... easy cake !
Doesn't work ... why ? Because SAP generates code which does not take into account the import filter parameters defined for the method ... instead they ignore half of the defined import parameters and start grabbing the filters out of the technical context object ... great coding practise if you ask me ...
Soooo ... what am I missing here ?
To get the demo working quickly I ended up copying all the standard code in my own implementation and added 3 lines of code which add any data of my own filter table into the one of SAP ... works like a charm ...
But how can this be the intention of clean OO coding and parent/child implementations etc ... I want to be able to reuse the standard generated code of SAP and simply modify or enhance instead of having to copy everything .. it is actually not only about the associations ... SAP generates all kind of code for '$top' or '$skip' which I basically 'loose' when I redefine ...
Why is all that functionality not foreseen as protected methods which I can redefine when needed ...
Basically the main 'Get_entitysets' calls a number of protected methods with default implementations
-> prepare_Data
-> filter_Data
-> <whatever>
-> get_Data ( => here the RFC is called or whatever )
-> skip_Data
-> top_Data
-> etc ...
Or maybe I am overlooking something ... and do I need to tackle 'associations' at a different level ... ?
Thanks,
Steven