ABAP – The power of the interface

Home / Blog / ABAP – The power of the interface

I recently had one of my programming friends teach me something. He showed me how to use the interface to help me design my free trial software. Now, it’s funny because the whole idea of inheritance is familiar to me. I’ve done programming in Java and other OO langauages, so needless to say, I felt pretty “simple” when the concept was explained to me.
Now, with my products, in order to be able to provide a free trial, without giving away everything, I broke up the code into 2 pieces, common code, and Full version. Well, in my first pass, I just created 2 classes with the same methods, one for free, one for full. I tested it out, and it worked great. Now the drawback of this approach is remembering all of the places in the code that I needed to update from FREE to FULL when I would package up the software.
The interface solves that problem. Thanks to some creativity from my friend Edward, he showed me how to contain all the code in an interface, then using a table entry, I can define if it pulls the FULL version, or just the free version. It’s very slick.
If you aren’t familair, it’s really just creating another class. The difference is that in the interface, it’s only the method definitions. No code. Then you create the class (for me, it was the common or free class). I attach the interface, then add the code into the methods that should work for FREE, and either leave the other empty, or add some message code. Then you do the same thing for the Full version. This time you redefine the methods that are available only in the full version. Using inheritance and interfaces, I was able to cut the manual work down to a table entry. Everything else takes care of itself.
Now, I have one more tool at my disposal.
Thanks for reading,

As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,
Mike

Leave a Reply

Your email address will not be published. Required fields are marked *