Skip to Content
Author's profile photo Enno Wulff

A Matter Of Getter

When programming classes you will have to think of which class attributes might be of concern to the caller (visible to caller) and which are not (private/ protected data).

If you prefer to make attributes PUBLIC you make your life easy. I prefer to declare attributes that might be used by the caller as PUBLIC. I have no trouble with creating GET-Methods and the caller can use any attribute he likes. The advantage of this is, that I as the designer of the class, do not have to think about if an attribute might be valuable for the caller. Especially when using controls and containers I prefer to make them PUBLIC because these classes have a lot of methods that might be used by the caller and I do not want to re-code all possible methods by local access-methods.

The disadvantage is, that the caller has full access to the attributes (as long as you don’t set them to read-only). I don’t mind.

However. If you like to work with GETTER-Methods in your classes you will have to create a method for each attribute the caller shall have access to.





A simple and clever alternative is to have all your accessable data in a structure. You will then only have one GET-method and still have access to the elements of the structure.

Define a GET-method as usual with a RETURNING-Parameter



  METHODS get_t000 RETURNING VALUE(rs_t000) TYPE t000.


You will then have access to each element of the used structure like this:

IF ref->get_t000( )-mwaer = ‘EUR’.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Naimesh Patel
      Naimesh Patel

      Great that field can be used from returning value, but I still prefer to use Public attribute with Read-Only instead of the GET methods. 😛


      Naimesh Patel

      Author's profile photo Enno Wulff
      Enno Wulff
      Blog Post Author

      So do I! 😉