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

Access via 'NULL' object reference not possible.

nbitish
Participant
0 Likes
2,046
PROGRAM  ZNB_CLASS_MOD_POO_IMP.
  DATA LV_MESSAGE TYPE BAPIRET2.
  DATA OBJ TYPE REF TO ZCL_NB_CLASS.
  DATA TRANS_BALANCE TYPE DMBTR.
  DATA BAL TYPE DMBTR.
  DATA BALANCE_LEFT TYPE DMBTR.
  DATA ok_code TYPE sy-ucomm.
DATA  LT_MESSAGE TYPE TABLE OF BAPIRET2.
START-OF-SELECTION.
CREATE OBJECT OBJ ."TYPE ZCL_NB_CLASS.
INCLUDE ZNB_CLASS_MOD_POO_IMP_STATUO01.
INCLUDE ZNB_CLASS_MOD_PAI.

Hi Everyone,

I am getting the null object reference error while I have to declare the object globally. Please help,

I my class code would be required, I will post that.

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
1,924

In the PAI you've got a bit of code like OBJ->DO_PAI( ). But at this point, OBJ is not instantiated. The solution depends on what you are trying to achieve, and the structure of your program.

OBJ is a terrible name for an object reference.

ZCL_NB_CLASS is a terrible name for a class.

9 REPLIES 9
Read only

Muthu_raja
Active Participant
0 Likes
1,924

Hi Nitish,

I think, You are calling corresponding methods of your class ZCL_NB_CLASS without any instance. Kindly check in debugging wheather object has been instantiated ( OBJ ) when calling methods.

Read only

matt
Active Contributor
0 Likes
1,924

Thank-you for properly formatting your program code. Much easier to read.

At what line are you getting the dump? Is it in the code you've posted, or is it in one of the includes?

Read only

DoanManhQuynh
Active Contributor
1,924

where are you calling screen?

Read only

nbitish
Participant
0 Likes
1,924

Hi Mathew,

I am getting the error in the includes, ie., the place at which I am calling the method

in PAI.

Read only

matt
Active Contributor
1,925

In the PAI you've got a bit of code like OBJ->DO_PAI( ). But at this point, OBJ is not instantiated. The solution depends on what you are trying to achieve, and the structure of your program.

OBJ is a terrible name for an object reference.

ZCL_NB_CLASS is a terrible name for a class.

Read only

0 Likes
1,924

Yeah, you are right. I was just practicing, that's why I did that.

Read only

0 Likes
1,924

I just want to know, where should I declare the object globally for multiple screens?

Read only

matt
Active Contributor
0 Likes
1,924

I can't tell you as... "The solution depends on what you are trying to achieve, and the structure of your program."

Read only

Former Member
0 Likes
1,924

Use a function group