selection criteria as a class
Dear community, in the openSAP course “Writing Testable Code for ABAP” was unit 1 of week 6 about working with legacy code. It was shown how to transform a procedural report into an object-oriented design with a class. The selection criteria, consisting of PARAMETERS and SELECT-OPTIONS, are transferred to the constructor.
Since there can sometimes be many selection criteria, I have thought about a dynamic solution. Below the core idea as a simple graphic (sorry, UML generation of my demo failed 🙁 … that’s the story for another blog):
In my little demo there is a local helper class called LCL_SELECTION_CRITERIA with access to PARAMETES and SELECT-OPTIONS (global variables) of the report ZSEL_CRITERIA_TEST. Therefore it is possible to transfer the selection criteria to an instance of a global class called ZCL_SEL_CRITERIA dynamically. Subsequently, the instance of this global class is passed to the constructor of another class called ZCL_SEL_CRITERIA_TEST where selection takes place and a small output is generated.
One of the nice side effects of presenting the selection criteria as a class is the possibility to automatically generate an identifier with more than 8 letters (for example “PA_BUKRS” is now “COMP_CODE”).
What do you think about it?