天天看點

Global variable in ABAP function group

Function group is loaded into runtime memory by the FIRST call of a function module inside this function group.

See example below:

I have a global variable defined in function group in X3C/504:

Global variable in ABAP function group

Before I call any of the function module in this function group, this global variable is not available - this make senses because the whole function group is NOT loaded into memory.

When the first function module is called, the function group is loaded into memory - global variable available:

I insert one entry to this table:

Now function1 execution is finished, when I entry function module2, this global variable is still available, because the lifetime scope of function group is application level - which means it will always stay in the memory until the application terminates.

概括成一句話:function module裡定義的局部變量,作用域是function module scope,即module執行完變量就失效,但定義在function group級别的全局變量,生命周期是整個應用,即應用不關閉之前,一直有效。

繼續閱讀