Saturday, January 14, 2017

ALV Super Class

Many Many years ago, in an SAP system not too far away was a group of developers that would put their idea's and help onto the SDN site to help up up and coming less experienced developers to keep growing their knowledge and maybe even leverage some of their code. In 2007 it was a lot easier to find good code from these great resources than it is now as these guys got to be so good, they now work directly for SAP. This is one of my dreams, though being my own company has worked out very well.
In this we find that ABAP oo was fairly complex and sparsely used but being explained better in more layman's terms by these great guys from enterprise geeks in their demonstration on how to leverage the newer way of showing ALV reporting using the CL_SALV_TABLE persistent class in SAP. They used a lot of their examples in custom function modules which to me were a little clunky and its easier now days to put re-usable code into classes and call them from your programs.
I am sure they do that now but haven't been following too close as I have been in an international implementation for the past 4 years.
When I picked up the project one of the first things I did was to put into the system one of my pets which I call the ALV Super Class. Based purely on the idea's that were sparked into my mind by the persistent ALV class from SAP as explained by our friends at Enterprise Geeks, I knew that trying to remember all those persistent objects would be a little difficult and may make coding an ALV report take longer than necessary so I created the Super Class. The Super Class stands by itself and when you want to leverage it you take and create yourself a new class and point to it as it's Super Class and then if you need to change some things like the constructor, the Custom labels, headers or footers you can do a redefinition of the method and then change the code to suit your needs. Which is very easy.

Here is what my ALV Super Class looks like at a high level:


Leveraging the Superclass will make coding so much easier as the majority of the code you need is already there. in your sub class add methods to get your data, process your data and call your view and redefine the handle links if you are using links. You can put in generic sort objects and hot key names and reuse those as well.

On a side note after taking webdynpro 310 and 410, and taking Fiori classes at open sap, And now hearing of the partnership between Apple and SAP, I think it may just be time to start transitioning from WebDynro  to Fiori as that will be the app of choice in this smart tablet smart hone world we now live in.
Post a Comment