Flipkart.com

Tuesday, June 14, 2011

Comparing "Function group" and "Class"

Function group is considered to be the closest to the OOPs concept in procedural programing. Knowing similarities and difference between "Function group" and a "Class" can help us understand more about OOPs.

Let us look at similarities
- Like a Class, FG too has attributes and methods (FMs)
- The attributes of a FG can only be accessed through FMs. That is data declared in a FM is global to its methods, but not accessible by FMs of other FGs. Similarly, in a class, its private attributes can only be accessed through its methods. This ensures consistency of data.


Now let us look at the differences
- In a Function group
Variables(attributes) are always Private
Function modules are always Public.

- When a FM is called, an instance of FG is created and the FG attributes are loaded into internal session memory. If you call another FM of the same FG, or call the same FM again, no new instance of FG is created. You have only one instance of the FG. That is an ABAP program can work with several instances of a same class (objects), but it cannot work with several instances of a FG.


Note: Because of the limitations of FG, it is more often used as a modularization technique not as a OO technique. I.e. A programmer rarely uses a FG to declare variables, rather he declares local variables inside a FM. So data gets stored in the calling program and FM is just used to manipulate it.

I will not compare the other OOPs concepts with FG, since FG does not provide any comparable abilities. Hope this article was useful. Let me know your comments.

6 comments:

  1. Thank you for writing such a useful blog.

    ReplyDelete
  2. Nice article for the SAP beginners.Thanks for sharing.Recently I bought the SAP BO videos from http://www.itlearnmore.com/special-offer-bo-dw-package/
    at very low price and I loved the videos

    ReplyDelete
  3. In let us look at similarities :

    If I am not wrong, That is data declared in a Function Group is global to its methods,

    ReplyDelete
  4. Superb explanation & it's too clear to understand the concept as well, keep sharing admin with some updated information with right examples.Keep update more posts.

    SAP HR Training in Chennai

    SAP SD Training in Chennai

    SAP Basis Training in Chennai

    ReplyDelete
  5. Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding sap topic in an effective way.Thank you so much.
    SAP ABAP Training in Chennai
    SAP FICO Training in Chennai

    ReplyDelete