Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Michael_Keller
Active Contributor
3,799
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").

At the moment the whole thing is nothing more than a "Proof of Concept" and lacks of any error handling 🙂 You can download it from GitHub via abapGit.

What do you think about it?

 

Have fun

Michael

 

 

 

 

 

 

 

 
6 Comments
Labels in this area