Functional Consultant:
I need one report which deletes the junk entries from the table (which are created due to program errors.)
My answer:
Ya simple.
(But the next statement which he added made me think)
Functional Consultant:
The Report should be such that it should be executed only once and just after the execution it should be deleted automatically. Just like a suicide bomber. So that there is no chance that user executes that report by mistake once again.
Requirement is confusing???? But let’s don’t get into functional things.
So now i have a requirement that my program should delete the unwanted records from the table based on some condition and just after that it should delete itself.
At first glance it sounds strange but it is not at all difficult.
See the Diagram below:
When you create a program and generate it . It generates LOAD. The LOAD consists largely of byte code whose statements are linked with C functions. So next time when you call this program application server use this LOAD and execute it. The actual source code is stored in
the Repository. In the database in the form in which they are developed. These are the only versions that can be displayed in the Workbench.
The LOAD is generated automatically when the program is called if none exists yet or if the LOAD in the database or the program buffer is obsolete. You can also generate programs explicitly, for example, in the ABAP Editor with menu path Program -> Generate.
A saved or buffered LOAD is considered obsolete when:
- The developed version of the program was changed.
- An object that the program uses was changed in the Data Dictionary.
I got the following function module which can be used to delete a Report Program. (Note: This FM deletes the Source code of the program which is stored inside the DATABASE in Repository)
I know what you are thinking now!!!!!
What would happen to the LOAD when you delete the report program from the database?
The answer is: The LOAD will be removed from the buffer automatically when Application server realised that the Report program is deleted from the database (Don’t ask me how much time application server takes, as it is in micro-second).
So finally my program is look like:
Report ZDELENTREIS.
“Code to delete unwanted entries from the table
“as per client requirement
Data : l_subrc type i.
“Call function module RKE_DELETE_REPORT
“To delete this report to avoid re use
CALL FUNCTION ‘RKE_DELETE_REPORT’
EXPORTING
PROGRAM = ‘ZDELENTREIS’
importing
subrc = l_subrc.