Recently I was involved in a project that required writing a lot of custom ALV OO reports in the PP and PS Modules.Most of these reports required a header or a footer section depending on the business functionality of the particular report. I got an idea about how to add header and footer sections in ALV OO reports using the CL_DD_DOCUMENT class from an interesting blog posted by Vijay Babu Dudla.The link to that article is as below : TOP_OF_PAGE in ALV Using CL_GUI_ALV_GRID
Now my problem was solved but the code kept repeating in each of the 50 odd reports and there was lack of uniformity in the code developement as everyone in the team was coding in their own style.This prompted me to write a class which encapsulates the functionalities of classes CL_GUI_ALV_GRID and CL_DD_DOCUMENT and merges them into a single class which can be used by everybody.This class can now be used to display the header and the footer sections along with the ALV output.The “EVENT_NAME” passed to the constructor decides whether to display the header(TOP_OF_PAGE) or the footer(END_OF_LIST).
Part 1 : Class ZCL_DOCUMENT
Note : This class can currently display either the header or the footer .A small modification in the constructor method can be done if both header or footer sections are required together.