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: 

Null Object Reference

Former Member
0 Kudos

Hi!

Is there any expression in ABAP Objects like e.g. the "null" object reference in java?

I mean, a null-reference, that is compatible to all other objects and can be used e.g. in method calls?!

I couldn't find anything, though I'd strongly expect it.

Thx

Nick

4 REPLIES 4

athavanraja
Active Contributor
0 Kudos

Welcome to SDN.

I am not sure i understood your question completely.

the equivalent of NULL in abap environment is initial.

for example to check whether a class instance is intantiated or not we do

if <class var> is not INITIAL.

Is this what you are looking for?

Regards

Raja

0 Kudos

Hi, thanks for your answer, but it's not really, what I wanted to know. Here is a short code snipplet:

data: sp type ref to if_srm_poid,

po type ref to if_srm_poid,

uo type ref to object.

mycopypastedata->set(

src_poid = sp

poid = po

text = ''

icon_id = ''

user_object = uo ).

And that's what I like to have:

mycopypastedata->set(

src_poid = NULL

poid = NULL

text = ''

icon_id = ''

user_object = NULL ).

Maybe it's clearer, now. '', space, initial or other things do not work (of course!).

Nick

0 Kudos

data: sp type ref to if_srm_poid,

po type ref to if_srm_poid,

uo type ref to object.

mycopypastedata->set(

src_poid = sp

poid = po

text = ''

icon_id = ''

user_object = uo ).

now within the set method you have to check whether

sp is initial or not.

if you dont want to pass null then

sp = l_xml->find_node(

name = 'CARRID'

  • ROOT = ROOT

).

then pass sp to the set method

Regards

Raja

Former Member
0 Kudos

Just check it out.

var = ''.

I think it will make the var as null value. var can be of any type.

Rgds,

TM.