Application Development and Automation 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: 
Read only

Dump: Access via 'NULL' object reference not possible

Former Member
0 Likes
3,555

Hi,

I am getting the following dump: Access via 'NULL' object reference not possible..

I am not an expert in BADI implementation, and it is my first time using that.

Can you please see if i am doing something wrong in this code:

BADI: CRM_MKTPL

method IF_EX_CRM_MKTPL~SET_ATTRIBUTES.

data: cm_stsma type J_STSMA.

data : cm_guid type CGPL_GUID16.

DATA: object TYPE REF TO CL_CGPL_STATUS_MANAGEMENT .

break-point.

call method im_project->get_guid

importing

EX_GUID = cm_guid.

cm_stsma = 'ZCRMCAMP'.

call method object->STATUS_PROFILE_CHANGE

exporting

im_guid = cm_guid

im_stsma = cm_stsma.

endmethod.

15 REPLIES 15
Read only

amit_khare
Active Contributor
0 Likes
1,879

The dump is not due to BADI it is for Object Oriented Programming.

you are calling a class with empty value.Check it.

Regards,

Amit

Read only

Former Member
0 Likes
1,879

Hello,

Put a CREATE OBJECT Object before trying to call the first method of 'Object'.

Regards,

john.

Read only

0 Likes
1,879

Hi,

The arror in your prog.

call method im_project->get_guid

U have create a object im_project with refrence to existing one.

Read only

Former Member
0 Likes
1,879

Hi,

The object name is wrong im_project) It is just Object.

BADI: CRM_MKTPL

method IF_EX_CRM_MKTPL~SET_ATTRIBUTES.

data: cm_stsma type J_STSMA.

data : cm_guid type CGPL_GUID16.

DATA: object TYPE REF TO CL_CGPL_STATUS_MANAGEMENT .

break-point.

call method <b>Object</b>->get_guid

importing

EX_GUID = cm_guid.

cm_stsma = 'ZCRMCAMP'.

call method object->STATUS_PROFILE_CHANGE

exporting

im_guid = cm_guid

im_stsma = cm_stsma.

endmethod.

Check now.

Regards,

Anji

Read only

Former Member
0 Likes
1,879

hi,

you have declared the object in statement, but not created the instance of it.

DATA: ob TYPE REF TO CL_CGPL_STATUS_MANAGEMENT .

use the "create object ob" to create the object instance without which it is giving 'NULL' object reference not possible.

Hope this helps.

Regards,

Richa

Read only

Former Member
0 Likes
1,879

Ok, thanks.

But i am putting:

DATA: ob TYPE REF TO CL_CGPL_STATUS_MANAGEMENT .

create object ob.

And i can't activate because:

"You cannot create an instance of the class CL_CGPL_STATUS_MANAGEMENT outside the class...

Please help...

Message was edited by:

yukimai maio

Message was edited by:

yukimai maio

Read only

Former Member
0 Likes
1,879

not answered yet

Read only

0 Likes
1,879

Hi,

The error means the class is a singleton and can only be instantiated from within the class. Look for a method in the class to a reference (e.g. GET_REFERENCE).

Regards,

John.

Read only

Former Member
0 Likes
1,879

Hi,

You have not created object in the program, so, it is giving short dump.

Create Object... is missing

if object is bound.                                                   " checking reference exists
call method object->STATUS_PROFILE_CHANGE
exporting
im_guid = cm_guid
im_stsma = cm_stsma.
endif.

Regards

Bhupal Reddy

Read only

Former Member
0 Likes
1,879

In class: CL_CGPL_STATUS_MANAGEMENT i don't have any GET_REFERENCE....

Is there any way to do that?

Read only

0 Likes
1,879

Hi Yukimai,

I Haven't any CRM system available to take a look. You should look for a method which returns a reference to the class itself.

Regards,

John.

Read only

0 Likes
1,879

hi,

call the method STATUS_OBJECT_CREATE. this method is to create the instance.

data: i_CGPL_GUID16 type CGPL_GUID16.

data : i_CRM_J_OBTYP type CRM_J_OBTYP.

DATA: ob TYPE REF TO CL_CGPL_STATUS_MANAGEMENT .

call method ob->STATUS_OBJECT_CREATE

exporting IM_GUID = i_CGPL_GUID16

IM_STATUS_OBJECT = i_CRM_J_OBTYP.

Hope this helps.

Regards,

Richa

Read only

Former Member
0 Likes
1,879

Now i have this:

method IF_EX_CRM_MKTPL~SET_ATTRIBUTES.

data: cm_stsma type J_STSMA.

data : cm_guid type CGPL_GUID16.

DATA: ob TYPE REF TO CL_CGPL_STATUS_MANAGEMENT .

data: i_CGPL_GUID16 type CGPL_GUID16.

data : i_CRM_J_OBTYP type CRM_J_OBTYP.

call method ob->STATUS_OBJECT_CREATE

exporting IM_GUID = i_CGPL_GUID16

IM_STATUS_OBJECT = i_CRM_J_OBTYP.

call method im_project->get_guid

importing

EX_GUID = cm_guid.

cm_stsma = 'ZCRMCAMP'.

call method ob->STATUS_PROFILE_CHANGE

exporting

im_guid = cm_guid

im_stsma = cm_stsma.

When i try to put CREATE OBJECT ob, and when i try to activate always i get the same: "you cannot create an instance of the class CL_CGPL_STATUS_MANAGEMENT outside the class.

Thanks

endmethod.

Read only

0 Likes
1,879

hi Yukimai,

if you class builder(se24) and check the properties of class CL_CGPL_STATUS_MANAGEMENT, you will find the instantiation is given as private. All the classes that have instantiation as private cannot be created via create object statment, so you are getting the message ' "you cannot create an instance of the class CL_CGPL_STATUS_MANAGEMENT outside the class.

'.

These class have a method that is used to create a class. In this case it is STATUS_OBJECT_CREATE. You have to use this method only to create any instance of the class.

Hope this explaination helps.

Regards,

Richa.

Read only

Former Member
0 Likes
1,879

Hi,

In my example how i can call the method call method STATUS_OBJECT_CREATE, because calling like this:

call method ob->STATUS_OBJECT_CREATE

exporting IM_GUID = i_CGPL_GUID16

IM_STATUS_OBJECT = i_CRM_J_OBTYP.

I get the same dump error.

Thanks in advance.

method IF_EX_CRM_MKTPL~SET_ATTRIBUTES.

data: cm_stsma type J_STSMA.

data : cm_guid type CGPL_GUID16.

data: i_CGPL_GUID16 type CGPL_GUID16.

data : i_CRM_J_OBTYP type CRM_J_OBTYP.

DATA: ob TYPE REF TO CL_CGPL_STATUS_MANAGEMENT .

call method ob->STATUS_OBJECT_CREATE

exporting IM_GUID = i_CGPL_GUID16

IM_STATUS_OBJECT = i_CRM_J_OBTYP.

call method im_project->get_guid

importing

EX_GUID = cm_guid.

cm_stsma = 'ZCRMCAMP'.

call method ob->STATUS_PROFILE_CHANGE

exporting

im_guid = cm_guid

im_stsma = cm_stsma.

endmethod.