Академический Документы
Профессиональный Документы
Культура Документы
ABOUT
SAPSERVICES
SAPSOLUTIONS
CONSULTANTSBLOG
CONTACT
CATEGORIES
can only access the current internal session, and it can only access data that is declared globally in the programs currently loaded in the
internal session. Fortunately in most programs, those memory locations have a lot of data declarations.
Select Category
[UPDATE] The ABAP statement variants used in this tip are marked forinternal use only by SAP. Therefore, the use of these
programming statements should be done at your own risk.
But what is an internal session? Without going into too much detail, an internal session (sometimes called the roll area) is the main
memory area of a ABAP program. The internal session contains data and objects of all ABAP programs since the start of a program
and remains in memory for the entire duration of the program. The following graphic partially shows how SAP memory is partitioned.
In this example, the purple box of the internal session has two main programs (red boxes) loaded in memory. In this example, the red
main program groups can either be SAP programs, Function Group, or Class Implementations.
ABAP syntax does not allow for the direct access of memory
between SAP programs, but it is possible for code in one main
program group to access any globally dened variable in another
main program group as long as the program you are accessing has
already been loaded in the internal session. In order to access the
data across main program group boundaries, we will be using eldsymbols. ABAP eld-symbols are a powerful coding construct that
points to a memory area. Field-symbols are assigned to memory
locations during program runtime. For a full introduction to eldsymbols, please visit SAP help.
In order to use a eld-symbol, it rst must be assigned to memory
by using the ASSIGN statement. The memory of other main
programs can be accessed by using the following access syntax in
the assignment:
ASSIGN('(MAIN_PROGRAM)VARIABLE[]')TO<FIELDSYMBOL>.
I recently implemented a BADI that was triggered on the AT_SAVE event of BADI of IF_EX_WORKORDER_UPDATE. The logic I was
implementing required data from the reservations associated with the production order. Lucky for me, the data I needed was declared
globally in the top include of function group COBT. That means that it is available toany codethat follows it.
In this example, eld symbol <TAB> is dened as being able to point to anything. The ASSIGN statement sets <TAB> to point to the
entire table RESB_BT in program SAPLCOBT. Once eld-symbol <TAB> is pointing to internal table RESB_BT, we can manipulate the
table like it is dened in the local scope.
DATA:LT_RESBBTYPESTANDARDTABLEOFRESBB,
UNIX Application
L_TABLE_NAME(20)TYPECVALUE'(SAPLCOBT)RESB_BT[]'.
FIELDSYMBOLS:<TAB>TYPEANY,
<WA>TYPERESBB.
ASSIGN(L_TABLE_NAME)TO<TAB>.
LT_RESBB=<TAB>.
LOOPATLT_RESBBASSIGNING<WA>.
...
ENDLOOP.
The following graphic illustrates how my BADI code (implemented in a private method) accesses data declared in the top include for
function group COBT (main program SAPLCOBT).
POPULAR TOPICS
.NET CONNECTOR
2009
ABAP
ABAP DEVELOPMENT
ACCOUNTS RECEIVABLE
I will stress here that in this example, eld symbol <TAB>points to RESB_BT in main program SAPLCOBT. Therefore local variable
ALE
ASUG
BASIS
LT_RESBB also points to the RESB_BT in main program SAPLCOBT. Any changes made to LT_RESBB will be reected in RESB_BT in main
program SAPLCOBT, so please be careful when implementing this logic as to not inadvertently introduce data inconsistencies in your
SAP system.
CFORIA
Field-symbols are a very powerful coding construct in ABAP. If you have any other cool eld-symbol tips or tricks, please share them in
the comments.
BASIS/NETWEAVER
CHRIS CAPARON
CONSULTING
CRAIG STASILA
Tumblr
Google+
DATAXSTREAM
FINANCIALS
IDOC
INTEGRATION
INTERFACE
MIKE SALVO
NCO
NCO 3.0
OMS+
NETWEAVER
PI
POS
PROJECT MANAGEMENT
SAP
SAP .NET CONNECTOR
SAP ABAP
Related Posts
Enhancing SAP Lean Order Management for SAP Retail Part 2: Conguring LOM July 26, 2016
Enhancing SAP Lean Order Management for SAP Retail Part 1 July 26, 2016
Enhancing SAP Lean Order Management for SAP Retail Part 3: Enhancement Framework July 26, 2016
ABAP Tricks: CTRL is the Key for Code Hinting! November 17, 2015
SAP CERTIFICATION
SAP INTEGRATION
SAPPHIRE
SAP PI
SAP PROGRAMMING
SAP RETAIL
SAP TESTING
SAP UPGRADE
SOLUTION MANAGER
3 Comments
TECHED
TIM COOPER
TIMOTHY YATES
Thomas Jung
August 20, 2009 at 9:23 am Reply
The tip you describe here is documented in the ABAP syntax help (under Alternative 1 of ASSIGN dynamic_dobj).
What you failed to mention is that this variant of the syntax using (PROG)DOBJ is marked as internal use only. This
means that SAP doesnt support the use of this variant by customers or partners. It also means that SAP can
remove the statement or alter the way it works in future releases.
Originally this concept was needed by the ABAP debugger. The classic debugger ran in the same session as the
program being debugged and needed a way to inspect the memory values of the debuggee. However when SAP
rewrote the ABAP debugger in 6.40 we split it into a separate session. The Debugger now remotely attaches to the
running session and uses special kernel methods to inspect the memory of the debuggee. At some point SAP might
remove the classic debugger completely and with it, this syntax variant.
Using this approach to access out of scope variables within BADIs is not necessarily a good idea particularly if you
use this approach to change data. The ow of the data into and out of the BADI is designed based upon the logic
surrounding the BADI. If you alter data within the BADI that wasnt expected, it could be too late to process the
correct validation or other important triggering logic.
UPGRADES
VIRTUALIZATION
XI/PI
XI
Ganesan
September 16, 2009 at 2:59 pm Reply
Dangerous but very useful.
Pushpraj Singh
November 24, 2011 at 4:41 am Reply
Thanks to both Craig and Thomas for their great tips!
Leave a reply
Name (required)
E-Mail (required)
Website
SUBMIT COMMENT
CONTACT US
757-345-3437
SEARCH
757-645-2384
www.dataxstream.com