10-30-2012 4:27 PM
Hi,
I am new to oops concepts and while doing alv reporting i have come across above runtime error, i want to know when this error will occur and how we can rectify it .
kindly reply to my post and help me out to resolve the issue.
Thanks,
Tej
10-30-2012 5:02 PM
When you declare a field using 'TYPE REF TO' you are telling the system to store a pointer to an object in that field. However, the object itself doesn't exist until you use the CREATE OBJECT statement. CREATE OBJECT creates the object, and populates the field with a pointer to that object. Here is some example syntax:
DATA: src TYPE REF TO cl_src
CREATE OBJECT src.
When you set a handler for a class, you are telling the system to "execute handler <handler> when the object <object> raises event <event>. What that error tells you is that your field isn't pointing to any object. That field is null. Therefore, you need to do the CREATE OBJECT before you do the SET HANDLER.
Another option is to use the FOR ALL INSTANCES extension of the SET HANDLER statement. This will make the handler you specify the handler for all objects of that same class. This staement should very rarely be used though, because it's not often necessary, and it's a messy practice.
10-31-2012 5:16 PM
I see Tej that you Like'd my reply. If it fixes your problem, please mark it as the correct answer, so that this thread will be marked as answered.