Dynamic Programming in ABAP - Part 1 - Introduction To Field Symbols - SAP Blogs
Dynamic Programming in ABAP - Part 1 - Introduction To Field Symbols - SAP Blogs
Products
Products Industries
Industries Support
Support Training
Training Community
Community Developer
Developer Partner
Partner
About
About
Ask a Question Write a Blog Post Login
Former Member
ABAP Development
SAP NetWeaver Application Server for ABAP | abap | dynamic | field | field symbol | introduction | programming | symbol
Follow
https://blogs.sap.com/2017/09/05/dynamic-programming-in-abap-part-1-introduction-to-field-symbols/ 1/8
9/27/2018 Dynamic Programming in ABAP – Part 1 – Introduction to Field Symbols | SAP Blogs
Field symbol is a placeholder for data object, which points to the value present
at the memory address of a data object. It does not reserve any physical
memory space when we declare them. It only points to a data object at run
time. Field symbols are of two types:
NOTE:
Typed field symbols can point to the data objects of specified type only.
After assigning a data object to a field symbol, if we make any changes
to the field symbol value, then the value of corresponding data object is
also updated.
NOTE:
https://blogs.sap.com/2017/09/05/dynamic-programming-in-abap-part-1-introduction-to-field-symbols/ 2/8
9/27/2018 Dynamic Programming in ABAP – Part 1 – Introduction to Field Symbols | SAP Blogs
is because work area stores a copy of the internal table row, whereas
field symbol directly references the internal table row.
Hence processing of internal table with field symbol is faster than the
processing of internal table with work area.
After executing this, the internal table will hold two rows.
NOTE:
Reading internal table – We can read a record of internal table using field
symbol as below:
https://blogs.sap.com/2017/09/05/dynamic-programming-in-abap-part-1-introduction-to-field-symbols/ 3/8
9/27/2018 Dynamic Programming in ABAP – Part 1 – Introduction to Field Symbols | SAP Blogs
TABLE.
Here we can assign any data object to TYPE ANY field symbol whereas TYPE
ANY TABLE field symbol is used for assigning any internal table.
TYPE ANY:
Let us assign a work area of type MARA to a TYPE ANY field symbol and
then populate the work area using field symbol.
NOTE:
https://blogs.sap.com/2017/09/05/dynamic-programming-in-abap-part-1-introduction-to-field-symbols/ 4/8
9/27/2018 Dynamic Programming in ABAP – Part 1 – Introduction to Field Symbols | SAP Blogs
We can assign any internal table to this field symbol. Let us analyze the below
code snippet to understand how we could use such field symbol.
NOTE:
Since <fs_tab> is a generic field symbol, its type will be known only at
runtime, hence we cannot directly write the fields of MARA structure
after WITH KEY, instead we have to write the field name within
parenthesis as shown above.
In ABAP, this parenthesis indicates the compiler that the value of the
operand will be decided at runtime, hence we don’t get any compilation
error.
https://blogs.sap.com/2017/09/05/dynamic-programming-in-abap-part-1-introduction-to-field-symbols/ 5/8
9/27/2018 Dynamic Programming in ABAP – Part 1 – Introduction to Field Symbols | SAP Blogs
In my next blog i have explained about data references and its significance in
dynamic programming. Below is the link for same.
https://blogs.sap.com/2017/09/11/dynamic-programming-in-abap-part-2-
introduction-to-data-reference/
Alert Moderator
6 Comments
You must be Logged on to comment or reply to a post.
Matthew Billingham
I’m not a fan of prefixes related to typing generally, but having FS before each field
symbol seems particularly useless. The names are embedded in angle brackets – we
know it’s an FS without the need for any prefix. Concentrate on meaningful names rather
than prefixes that add zero value.
Jacques Nomssi
Hello Rahul,
https://blogs.sap.com/2017/09/05/dynamic-programming-in-abap-part-1-introduction-to-field-symbols/ 6/8
9/27/2018 Dynamic Programming in ABAP – Part 1 – Introduction to Field Symbols | SAP Blogs
1. there is a static and a dynamic version of the ASSIGN statement. If you recognize a
dynamic case, then check of SY-SUBRC after ASSIGN ( 0 if ok, 4 if error) is enough to
make sure the field symbol valid, so a IS ASSIGNED or subsequent UNASSIGN is not
mandatory.
2. On newer releases, typed field symbols can be declared implicitely, e.g.
I think the VALUE operator will make the use of ASSIGNING as in the idiom
APPEND INITIAL LINE TO .. ASSIGNING less popular.
regards,
JNN
Hi Jacques,
Former Member
https://blogs.sap.com/2017/09/05/dynamic-programming-in-abap-part-1-introduction-to-field-symbols/ 7/8
9/27/2018 Dynamic Programming in ABAP – Part 1 – Introduction to Field Symbols | SAP Blogs
Thanks Tamit
Gopi Srinivasan
Trademark Sitemap
Newsletter
https://blogs.sap.com/2017/09/05/dynamic-programming-in-abap-part-1-introduction-to-field-symbols/ 8/8