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
833

Hi,

i learning abap objects and i wont to sample for using private and protected and public definitions .

until now i use Fm and for that i have function group

in top i declare all the global variables and i use it for all the fm in the group what is change.

Regards

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
805

Hello Ricardo

For an instance of a class all attributes, irrespective of whether they are public, protected or private, are global.

In general I would say that most of the class attributes (>70 %) should be either private or protected.

When do I use public attributes?

1) I want to make certain properties of the instance (e.g. a key like MATNR or details like MARA for a material related class) available for the outside. However, these public attributes should be defined as read-only because it makes absolutely no sense that you can change the key of an instance (like MATNR) from outside.

2) Recently I learned about a SAP standard interface (BAdI) for a user-exit where the attribute for an ALV fieldcatalog itab was public and changeable. Here the intention is to give the user of this BAdI an easy way to manipulate the ALV fieldcatalog.

Regards

Uwe

8 REPLIES 8
Read only

amit_khare
Active Contributor
0 Likes
805

Check standard reports in SAP with names starting with BCALV_* they will provide you ample amount of information for learning.

Read only

uwe_schieferstein
Active Contributor
0 Likes
806

Hello Ricardo

For an instance of a class all attributes, irrespective of whether they are public, protected or private, are global.

In general I would say that most of the class attributes (>70 %) should be either private or protected.

When do I use public attributes?

1) I want to make certain properties of the instance (e.g. a key like MATNR or details like MARA for a material related class) available for the outside. However, these public attributes should be defined as read-only because it makes absolutely no sense that you can change the key of an instance (like MATNR) from outside.

2) Recently I learned about a SAP standard interface (BAdI) for a user-exit where the attribute for an ALV fieldcatalog itab was public and changeable. Here the intention is to give the user of this BAdI an easy way to manipulate the ALV fieldcatalog.

Regards

Uwe

Read only

0 Likes
805

Hi Uwe Schieferstein

thanks ,

maybe u can give me simple example it help me a lot.

Regards

Read only

Former Member
0 Likes
805

Hiii!

Check out this link. This link will guide you on ABAP OBJECTS

http://www.sap-press.de/katalog/buecher/htmlleseproben/gp/htmlprobID-28?GalileoSession=22448306A3l7U...

Regards

Abhijeet Kulshreshtha

Read only

former_member69765
Contributor
0 Likes
805

Refer to some tutorials online..

Check out [www.abaplearning.com|www.abaplearning.com]

Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
805

Hi Ricardo,

The Uwe's explanation is correct, you can also take a loo at [ABAP Objects Wiki page|https://wiki.sdn.sap.com/wiki/x/o5k] and [ABAP Objects Examples|https://wiki.sdn.sap.com/wiki/x/Aq] where you can see some examples includind [Visibility Definitions|https://wiki.sdn.sap.com/wiki/x/D60] and [Components Definitions|https://wiki.sdn.sap.com/wiki/x/OKg].

I hope this examples help you !

'Boa Sorte !'

Greetings,

Marcelo Ramos

Read only

Former Member
0 Likes
805

Hey!

Thanks alot Ricardo.