I think almost all ABAPpers would agree with me that the most boring and forgetful part of coding is to REFRESH / CLEAR the internal tables / workareas whenever the need for doing so arises.
This small little check that the internal table / workarea must be refreshed at the correct place always remains in our subconscious mind, but, we seldom take a conscious effort to actionize it.
Probably after spending about 2 hours of my life for a small bug in my program, I have learnt to keep the point “REFRESH INTERNAL TABLES / WORKAREAS” at the top of my checklist.
This learning got engraved in my mind when I created an ALV report with a header.
I created an internal table T_TOP of type SLIS_T_LISTHEADER and populated it with the details to be displayed in the header.
In the program, I declared the internal table T_TOP in the global declarations.
Now, in the subroutine TOP_OF_PAGE, I did not clear the internal table T_TOP before filling it with the details, overlooking the fact that the top of page event is called everytime we select any record in the output or select any options in the toolbar.
Now, whenever I double-clicked on the output or selected any options from the toolbar, my report header kept repeating itself and grew in size.
On debugging, I found that I had forgot to clear my internal table T_TOP at the start of the subroutine created for TOP OF PAGE.
So friends, please remember consciously to always clear / refresh the internal tables and workareas wherever necessary, else, a small bug like this can cost you hours.