Skip to Content
Author's profile photo Former Member

Get/Set generator for ABAP OO Classes

Since i’m tangled up in quite an extensive project using Abap OO I came across the issue that the ABAP workbench doesn’t allow you to generate getters and setters for class-attributes. After searching a bit on Google I stumbled across Timo John’s blog basically assigning the whole issue, and supplying us with a report.

After playing around a bit, I found that I missed some features:

– The report doesn’t allow you to select which attributes you want to generate the getters/setters for.

– The report doesn’t allow you to easily delete the generated records.

– I use a different standard on naming my attributes, and I wanted a consistent way of naming my parameters.

– I tend to also use constants in my classes, and I don’t want getters and setters for that.

Therefore I took the report he wrote and extended (quite a bit of) it.

Before extending the report, I created a class (for testing puposes) with a few attributes on it.

/wp-content/uploads/2013/09/attributes_fw_288147.png

So, in this case you can see I have a few different type of attributes.

Now I fire up the getter/setter generating program.

Startscreen.fw.png

When pressing F8 it leads me to a second screen in which I can select for which attribute I want to generate/delete the getters and setters.

Generate_methods_for_attribs.fw.png

After generating, opening the class in SE24, you see the getters and setters which have been generated.

/wp-content/uploads/2013/09/methods_generated_fw_288153.png

Including the implementation and the importing/returning parameters.

/wp-content/uploads/2013/09/impemented_class_fw_288154.png

Since the blog doesn’t allow me to attach a SAPLINK nugget, the download is available from here, hopefully this is something where others can also benefit from.

Assigned Tags

      7 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Timo John
      Timo John

      Hi,

      thanks for linking to my first work on GET and SET Methods...

      I thougt, I extended the Post last year but It does not look like.

      I also did some enhancements on the very first version I published back in 2010.

      May be it would make sense to bring it all togehther and share it on google code?

      There has been a project on SAP CodeExchange .. but this is gone:
      https://cw.sdn.sap.com/cw/groups/getter-setter-generator

      I think my idea was to contribute there ...

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      No problem, credits to who invented the original concept.

      I'm open for sharing and collaborating on this code on google code, sharing is key 😉

      Regarding the SAP CodeExchange link, I've also come across it, but found it was gone, that was the main reason I decided to share it trough a blog.

      Author's profile photo Fred Verheul
      Fred Verheul

      Hey Mark,

      Congratulations on your first blog post! The second will be (even) easier, and I'm already waiting for it 🙂 .

      Thanks for sharing this nice functionality. Posting the code on Google Code or Github is a great idea...

      Cheers, Fred

      Author's profile photo Kiran Kumar Valluru
      Kiran Kumar Valluru

      Hi Huisman,

      Congratulations on your first blog. This will be very useful. Good Work 🙂

      Cheers,

      Kiran

      Author's profile photo Thomas Fiedler
      Thomas Fiedler

      Hi Mark,

      wonderful idea. But why not integrate this functionality directly in the IDE? With ABAP in Eclipse there is a SDK available where you can integrate new functionality directly in your development tool without triggering a report. If you want to know more there is a blog from Michael Schneider about it:

      http://scn.sap.com/community/abap/eclipse/blog/2013/05/10/first-version-sdk-for-abap-development-tools

      Kind Regards,

      Thomas.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Basically because the ABAP SDK for Eclipse you are mentioning lives outside of SAP.

      Also, the documentation states that I need either a SAP NetWeaver 7.31 SP8

      or SAP NetWeaver 7.40 SP2 to be able to use it.

      If I look at my tooling, it's a lightweight, 600-lines ABAP which can be easily copied from one system to another, basically supporting SAP ABAP stacks as old as 4.6c (and maybe even older).

      Next to that, most customers I face are not even near the versions mentioned above, so I´m dependant on a small ABAP-program to do this for me.

      Never the less, I´ll look into enhancing the functionality of the eclipse plugin with getter and setter generating functionality.. but i'm not promising anything 🙂 .

      Author's profile photo Timo John
      Timo John

      Hi,

      I would have expected that this kind of features are available out of the box in Eclispse ...

      Is it not as comfortable as it is for java? Where I expect that I only used 10% of the available functions ...

      Anyway I agree with M. Huisman that we should not rely on very latest NW releases...

      I have "only" 7.31 SP6 available ... which is VERY new compared to the ones I worked on before.

      It is difficult to "sell" a complete Enhancement Pack upgrade if you just get some nicer Development tools ...

      I hope i can come up with such a google code project soon.

      KR