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.

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. 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 …

    (0) 
    1. Mark Huisman 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.

      (0) 
  2. 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

    (0) 
    1. Mark Huisman 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 🙂 .

      (0) 
    2. 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


      (0) 

Leave a Reply