Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

A confusing aspect of ABAP function group and module

Former Member
0 Kudos

Hi everyone,

These days I found a strange problem of ABAP. When you test one function module, other function modules in the same group must have no syntex error. Or the test will fail. This is very confusing because there're no relationship between these function modules. How can such situation happen? Are there anyone can explain this to me?Then I'll be very thankful.

Regards

Golden

5 REPLIES 5

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

The function modules are related, because they are all included into one main program. The main program is the function group. If you look at the main program, you will see a series of includes, each include contants a function module. This is the reason for syntax errors in one function module preventing an execution of another in the same function group.

Regards,

Rich Heilman

0 Kudos

Think of a function group and function modules as a class with methods. If you have a syntax error in one method, this causes problems for the entire class, right?

Remember, when executing a function module, then entire function group is loaded into the runtime memory.

Regards,

Rich Heilman

0 Kudos

Hi Heilman,

Thanks for your answer. But I'm still confusing why ABAP takes this way? The function modules in one function group may have no relationship between each other. We asign them into one group just because they may relate to some common topic. They should still be independent. What's more a function group isn't a class. It can't store any state. Function modules in one group also won't share the same object. At least they can't keep the changing of some variable like what can achieved in a class. I'm wondering the motivation of this way. Do you know the motivation?

Thanks + Regards

Golden

0 Kudos

No, they are not a class, your right! I just mentioned that as a comparison. The function modules within a function group can share "Global" data between them during the same session.

Please read the following, it will back up my story a bit.

http://help.sap.com/saphelp_470/helpdata/en/9f/db992335c111d1829f0000e829fbfe/frameset.htm

http://help.sap.com/saphelp_470/helpdata/en/c3/225b5954f411d194a60000e8353423/frameset.htm

Regards,

Rich Heilman

0 Kudos

Golden,

The idea behind having a function group is to seggregate the functionality and at the same time incorporate some reusability.

Now, think of this, I create a function to do processing of my Pruchase order / Sales Orders. So, I create two different function group one for PO and one for SO.

So, with in the PO function group, I can write functions to change / create / get details etc etc functions and as most of these use the same structures I can have top include, where the variables are used across the functions.

So, finally it boils down to the developer how we want to design the function groups.

Hope this clarifies a little bit.

Regards,

Ravi

Note : Please mark the helpful answers