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

Not able to call a method from a program

Former Member
0 Likes
2,290

Hi,

I want to use a method which is part of global calss in my custom program. But I am not able to create object to use the same.

Class Name : CL_SA_TAB_PROJECTDOCU

Method : UPDATE_NEW_DOC

Can some one explain me how to call it from custom program and what are the constrains to do the same.

Thanks in advacne.

Regards,

avis

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,562

Hi,

Please check if the class CL_SA_TAB_PROJECTDOCU has a method called "constructor" or not.

If yes, then there is a possibility that the constructor may have some parameters that needs to be passed.

Just for your info:

Constructor is a method that is called by default while creating the object of the class. If this method has a parameter then that needs to be passed when you create the object.

If no,

then as already mentioned, you have to check if the method has some obligatory parameter that needs to be passed.

But looking at you update it seems you are getting an error while creating the object. So I guess it is related to the constructor.

Regards,

Saurabh

9 REPLIES 9
Read only

Former Member
0 Likes
1,562

may be class or method is abstract. and you should implement that class

or it's method.

another reason is method you want call defined as private or protected method.

Read only

0 Likes
1,562

The class is public and method is instantiated.

Read only

former_member195383
Active Contributor
0 Likes
1,562

create an object of the class and then try to call the method..

Read only

0 Likes
1,562

when i am declaring for create object, i am getting the error as obligatory parameter "TAB_VIS_REF" had no value assigned to it.

Read only

0 Likes
1,562

fill that parameter.

Read only

Former Member
0 Likes
1,562

did you instantiate object? if not, write following:

data o type ref to  CL_SA_TAB_PROJECTDOCU.
create object o.
call method o->UPDATE_NEW_DOC
"importing 
".......
"exporting
"............
.

or if that method is static method you can call it without instantiating object of class:

call method CL_SA_TAB_PROJECTDOCU->UPDATE_NEW_DOC
"importing 
".......
"exporting
"............
.

Read only

Former Member
0 Likes
1,563

Hi,

Please check if the class CL_SA_TAB_PROJECTDOCU has a method called "constructor" or not.

If yes, then there is a possibility that the constructor may have some parameters that needs to be passed.

Just for your info:

Constructor is a method that is called by default while creating the object of the class. If this method has a parameter then that needs to be passed when you create the object.

If no,

then as already mentioned, you have to check if the method has some obligatory parameter that needs to be passed.

But looking at you update it seems you are getting an error while creating the object. So I guess it is related to the constructor.

Regards,

Saurabh

Read only

former_member69765
Contributor
0 Likes
1,562

Dude its simple...

the way you are creating object of the class in not correct.

the constructor of the class is expecting some parameter and you have not passed it. Pass all the obligatory parameters and job done.

For reference read the article Constructors in chapter Object Oriented ABAP on the site

[www.abaplearning.com|www.abaplearning.com]

direct link: http://www.abaplearning.com/index.php?option=com_content&view=section&id=1&Itemid=5

You will have to log in on the site to see the examples and tutorials.

--

Keep Learning

Read only

Former Member
0 Likes
1,562

thanks. i missed the constructor paramters.