Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

set handler for src 'src' cannot be 'null'

Former Member
0 Kudos

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

2 REPLIES 2

alex_campbell
Contributor
0 Kudos

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.

0 Kudos

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.