Sometimes, we don’t have access to all the variables which we are looking for. Especially this happens when we are working with CMOD user-exits, BADI implementation, etc. So, we do it this way:
Access Global Memory using FS
* This code is inside a BADI implementation where global memory * of SAPMV45A is available field-symbols: <fs_xvbap> type standard table of vbapvb. assign '(SAPMV45A)XVBAP)' to <fs_xvbap>. if sy-subrc eq 0. "Further logic to access data from <fs_xvbap> endif.
Where it is used
- This is used frequently in the CMOD userexits, BADI implementations, where we don’t have access to all the memory.
- We can also use this technique inside debugger to quickly access variable and check its content.
Why to refrain using it
It was mainly used to communicate between program and debugger in old debugger. Since introduction to new debugger from ABAP release 640, this technique to access global memory using field-symbols is obsolete. Moreover this statement is system statement, so it may be discontinued at any time. Although it doesn’t appear that it would go away any time soon, but it should be used with extreme care.
It is also dangerous from data integrity perspective since memory is accessed via field symbols, it can be easily changed. If it is used by anyone who is not fully familiar with downline usage of those variables, than it may create serious issues.
Best possible solution
We can use implicit enhancement point in the program from where we want to use the global memory. In this implementation we can save the data in global memory of a function group. And we can get back the values where ever required using another FM in the same FG so we can have access to the data what we have just saved.