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

abap objects qustion

Former Member
0 Likes
837

hallow

i new in oo and i buield this class for training and lets say i wont to call to metod

get_user with pattern but when i call it i have popup that unable to find metod get_user from class c_user <b>or</b> c_user class dosent existent .

how i change it?

CLASS c_user DEFINITION.

PUBLIC SECTION.

CLASS-DATA: instance_count type i.

DATA: id type i.

METHODS: CONSTRUCTOR,

display,

get_user RETURNING value(p_user) like sy-uname.

PRIVATE SECTION.

DATA: a_user like sy-uname.

ENDCLASS.

CLASS c_user IMPLEMENTATION.

METHOD CONSTRUCTOR.

a_user = sy-uname.

ENDMETHOD.

METHOD display.

WRITE 😕 a_user, id, instance_count.

ENDMETHOD.

METHOD get_user.

p_user = a_user.

ENDMETHOD.

ENDCLASS.

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
812

Hi,

How you are calling, can you paste calling code, object creation?

Is it in INCLUDE and check its activated?

6 REPLIES 6
Read only

Former Member
0 Likes
813

Hi,

How you are calling, can you paste calling code, object creation?

Is it in INCLUDE and check its activated?

Read only

0 Likes
812

hi prasad

i copy this code and activated and call it like i cal to function with pettern

in objects i give class name and metod

Regards

Read only

Former Member
0 Likes
812

Hi,

Then how it has got activated?

are you calling like this,

data: obj type ref to c_user.

data: user type sy-uname.

create object obj.

user = obj->get_user( ).

Read only

0 Likes
812

hi prasad

i do like that ,i just wont to now how i b\can call to metod from regular program

thankes

CREATE OBJECT my_obj.

CALL METHOD my_obj->display.

Read only

Former Member
0 Likes
812

Hi Shnya,

The problem is that you are creating Local class rather than Global class.

Define class as Global class using SE24 and then use pattern then you will get the instance of the method into your report.

Thanks,

Vinay

Read only

0 Likes
812

hi Vinaykumar G

thankes

i try to create in se24 but and i write the metod but where i put defntion?

Regards

3000... points great men.