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

Cannot create object

Former Member
6,153

Hi gurus,

the following code:

<b><i>DATA: ref_cl_rsd_odso TYPE REF TO cl_rsd_odso,

ref_if_rsd_dta type ref to if_rsd_dta,

e_s_dta TYPE rsd_s_dta,

wa_e_s_dta TYPE rsd_s_dta.

START-OF-SELECTION.

create object ref_cl_rsd_odso.

CALL METHOD ref_cl_rsd_odso->if_rsd_dta~dta_get_info

IMPORTING

e_s_dta = e_s_dta.</i></b>

return an activation error:

"You cannot create an instance of the class "CL_RSD_ODSO" outside the class"

Could you help me?

Thanks in advance!

Bye!

Ferdinando

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,789

The class cl_rsd_odso has its instantiation set to 'Private' which means that you cannot create a public instance of the same in your program. The class can only be instantiated from within itself.

Your program should work if you comment out the 'Create object' statement.

Hope this helps.

Sudha

5 REPLIES 5
Read only

Former Member
0 Likes
2,789

i think no need to create Instance for this class.

then code will be

DATA: ref_cl_rsd_odso TYPE REF TO cl_rsd_odso,

ref_if_rsd_dta type ref to if_rsd_dta,

e_s_dta TYPE rsd_s_dta,

wa_e_s_dta TYPE rsd_s_dta.

START-OF-SELECTION.

CALL METHOD ref_cl_rsd_odso->if_rsd_dta~dta_get_info

IMPORTING

e_s_dta = e_s_dta.

Regards

Peram

Read only

Former Member
0 Likes
2,790

The class cl_rsd_odso has its instantiation set to 'Private' which means that you cannot create a public instance of the same in your program. The class can only be instantiated from within itself.

Your program should work if you comment out the 'Create object' statement.

Hope this helps.

Sudha

Read only

0 Likes
2,789

Hi,

if i comment "create object", the activation is ok, but there is a dump when

run pgm (OBJECTS_OBJREF_NOT_ASSIGNED, CX_SY_REF_IS_INITIAL).

HELP!!!!!!!!!!!!!!!!!!!!!!!!!!

tHANKS!

1

Read only

0 Likes
2,789

Hi,

Go through the below code,

We need to call the factory method to get the instance of this class.

DATA: ref_cl_rsd_odso TYPE REF TO cl_rsd_odso,

ref_if_rsd_dta type ref to if_rsd_dta ,

e_s_dta TYPE rsd_s_dta,

wa_e_s_dta TYPE rsd_s_dta.

START-OF-SELECTION.

CALL METHOD CL_RSD_ODSO=>FACTORY

  • EXPORTING

  • I_ODSOBJECT = SPACE

  • I_REFNM =

  • I_TXTLG =

  • I_TXTSH =

  • I_INFOAREA =

  • I_BWAPPL =

RECEIVING

R_R_ODSO = ref_cl_rsd_odso.

  • EXCEPTIONS

  • INPUT_INVALID = 1

  • CANCELLED = 2

  • others = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL METHOD ref_cl_rsd_odso->if_rsd_dta~dta_get_info

IMPORTING

e_s_dta = e_s_dta.

Regards,

Azaz Ali.

Read only

Former Member
0 Likes
2,789

Hi,

Your class will be private thats the reason it is giving that error. You can create an instance of private class only in that class itself.

If you want to create object of that class declare static method in that class call that method using the syntax class_name=>method_name in the start-of-selection and then create the object in that method.

Regards,

Azaz Ali.