Skip to Content
Author's profile photo Lukas Dietzsch

Generate getter and setter methods in SAP Netweaver by given DDIC structure

The SAP NetWeaver has a considerably wide range of functions. But in its current version this powerful SAP tool works in comparison with other Integrated Development Environments (IDE) pretty wooden. There are missing simple getter and setter generators for example, as it is known from the Eclipse IDE for years. The conceptual background, advantages and benefits of clean encapsulated object attribute access is not the topic of this article.

Such a getter and setter generator has been implemented and this is demonstrated in this article. In the SAP it is useful to create the getters and setters on basis of an existing object from the Data Dictionary (DDIC).

In the first stage of this generator an existing DDIC is specified and its detailed structure is read generic. For this purpose a new separate class is created in which each column represents the DDIC as an attribute. The preferred example DDIC is table SPFLI from the common SAP practice examples.

The structure of the SPFLI table:

The new created class has a corresponding class attribute for each of the above column (field). These attributes are marked directly by the generator as a private one. The attribute access is to be made via the following to create getter and setter methods. The report is now called, and offers the following input options:

The report get the desired source table (DDIC) and the checkboxes for getter and/or setter methods. Additionally the target class name should be defined. In this example, as already mentioned, will be a new class for the SPFLI table created. The target class is created only in the Z namespace and will be called ZCL_MY_OWN_SPFLI. After confirming these entries the report starts with the generation.

The user will have the option to designate the target package, in which the class should be created. In the example case, there is the $ TMP package:

The result can now be seen in Repository Browser for the new class Z_MY_OWN_SPFLI. The aim was to have a class attribute for each column of SPFLI:

Each column was added as an attribute. All columns? No! The client column is missing and was not added. In most cases it is not recommended to set an client field manually. Therefore every client column will be ignored by the generator.

After class generation, the reports reads the new structure again and generates depending on getter and settter choice the new methods. In this example both checkboxes on start screen are checked, see the result:

The example implementation of the getter method for the SPFLI attribute “AIPFROM” is shown here:

And here you can see the new generated setter method. It has instead of returning parameters (cp. getter method) an importing parameter:

This tool is used in present dnsgroup projects and provides good service even at this stage of development. It is not yet final stage. We welcome feedback and feature requests.

For questions and advices we are always happy to help and offer advice and assistance.

kind regards,


Assigned Tags

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

      Useful; it could save a lot of "no value added" coding.

      Could be improved also for auto-generating some checks on setter method (initial value admitted ? value is valid if domain has some restriciton ? Ecc. )

      Author's profile photo Lukas Dietzsch
      Lukas Dietzsch
      Blog Post Author

      Hi Manuel,

      great, thanks for your advice. Such checks will improve data consitency. General checks for initial value and Domain restrictions sound very useful.

      I will work on these extensions.


      Author's profile photo Christian Drumm
      Christian Drumm

      Hi Lukas,

      nice work.

      Are you going to publish the report on Code Exchange so it can be used / extended by others?


      Author's profile photo Lukas Dietzsch
      Lukas Dietzsch
      Blog Post Author

      Hi Christian,

      good advice, thank you! I am going to publish these snippets on code exchange.

      kind regards,


      Author's profile photo Robert Meyer
      Robert Meyer


      Just wanted to ask if this wonderful program is still available somewhere? 🙂