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: 

Object Refernce

Former Member
0 Kudos
615

Hi,

How can we check if an object has been created or referred, Actually the object is created based on some condition and a method is called later, i want to check if the if an object has been created or referred to avoid a dump when the method is triggered with out the object reference.

can we use

"IF OBJ IS NOT INITIAL" does this mean that the object has been referred?

1 ACCEPTED SOLUTION

matt
Active Contributor
0 Kudos
273

IF obj IS [NOT] BOUND.

matt

3 REPLIES 3

matt
Active Contributor
0 Kudos
274

IF obj IS [NOT] BOUND.

matt

VikasB
Active Participant
0 Kudos
273

Hi, Sreelakshmi,

You can also check value of SY-SUBRC = 0.

If the CREATE OBJECT statement is executed successfully, sy-subrc is set to 0. Values other than 0 are set by specifying EXCEPTIONS in parameter specifications when non-class-based exceptions of the instance constructor are handled.

regards,

vikas.

plz reward if helpful..

Former Member
0 Kudos
273

hi

good

Object References

To access an object from an ABAP program, you use only object references. Object references are pointers to objects. In ABAP, they are always contained in object reference variables.

Object Reference Variables

There are only two types of variable that can contain references in ABAP: object reference variables and data reference variables for data references. Object reference variables contain references to objects. An object reference variable is either initial or contains a reference to an existing object. The identity of an object depends on its object reference. A reference variable that points to an object knows the identity of that object. The instance-dependent components of an object can only be addressed using reference variables that point to the object.

Users cannot access the identity of the object directly. Reference variables are based on reference semantics. When reference semantics is used and a reference variable is assigned to another one, then it is only the address of the object – the object reference – which is passed and not the attributes of the object. Object attributes can themselves also be reference variables.

Like all variables, you initialize object reference variables using the CLEAR statement. The initial value of a reference variable is a reference that does not point to an object.

Data Types for References

ABAP contains a predefined data type for references, comparable to the data types for structures or internal tables. The full data type is not defined until the declaration in the ABAP program. The data type of an object reference variable determines how the program handles its value (that is, the object reference). There are two general types of object reference: class references and interface references (see Interfaces).

You define class references using the

... TYPE REF TO class

addition in the TYPES or DATAstatement, where class refers to a class. A reference variable with the type class reference is called a class reference variable, or class reference for short.

A class reference cref allows a user to create an instance (object) of the corresponding class. Using

cref->comp

the user can access all visible components compof the object which are also contained in the class class.

http://help.sap.com/saphelp_nw70/helpdata/en/c3/225b5f54f411d194a60000e8353423/content.htm

thanks

mrutyun^