SAP NetWeaver AS ABAP Release 751, ©Copyright 2017 SAP AG. All rights reserved.
Field Symbols
Field symbols are placeholders or symbolic names for existing data objects (or parts of existing data objects), declared by the statement FIELD-SYMBOLS or by the declaration operator FIELD-SYMBOL . A memory area is assigned to a field symbol at program runtime. A field symbol does not reserve physical space in the data area of a program like with a data object . Instead, it works as a dynamic name of a memory area, where a specific data object or part of an object is located. A field symbol can be used instead of data objects at operand positions of statements. When a statement of this type is executed, a memory area must be assigned to the field symbol by the statement ASSIGN or the addition ASSIGNING when processing internal tables .
Field symbols can point to almost any data object. A field symbol is the equivalent of a data reference variable dereferenced using ->* . Unlike data reference variables, value semantics are used to access a field symbol Accessing a field symbol is like accessing the named data object (or part of the object). For data reference variables, however, reference semantics apply.
Field symbols are implemented both for generic work with data objects and for explicit casting of data objects (only possible using field symbols).
Programming Guideline
- Field symbols to which data objects or parts of data objects are assigned in the heap are memory-preserving, like heap references .
- From a technical perspective, the field symbols are implemented by references or pointers, which are comparable to references in data reference variables . A data reference variable is declared in the same way as every other data object und the memory area for the reference contained in the variable is located in the data area of the ABAP program. However, the pointer assigned to a field symbol is exclusively managed by the ABAP runtime environment and is located in the memory area, which cannot be accessed directly in an ABAP program.
- Getting started with ABAP
- ABAP GRID List Viewer (ALV)
- ABAP Objects
- Control Flow Statements
- Data Declaration
- Dynamic Programming
- Data references
- Field-Symbols
- RunTime Type Services
- Internal Tables
- Message Classes/MESSAGE keyword
- Naming Conventions
- Regular Expressions
- Template Programs
- Unit testing

ABAP Dynamic Programming Field-Symbols
Fastest entity framework extensions.
Field-Symbols are ABAP's equivalent to pointers, except that Field-Symbols are always dereferenced (it is not possible to change the actual address in memory).
Declaration
To declare a Field-Symbol the keyword FIELD-SYMBOLS must be used. Types can be generic ( ANY [... TABLE] ) to handle a wide variety of variables.
Field-Symbols are unassigned on declaration, which means that they are pointing to nothing. Accessing an unassigned Field-Symbol will lead to an exception, and, if uncaught, to a short dump. Therefore, the state should be checked with IS ASSIGNED :
As they are only references, no real data can be stored inside. So, declared DATA is needed in every case of use.
Unassigning
Sometimes it could be useful to reset a Field-Symbol. This can be done using UNASSIGN .
Use for internal tables
Field-Symbols may be used to modify internal tables.
Attention! Field-Symbols stay assigned even after leaving the loop. If you want to reuse them safely, unassign them immediately.

- Advertise with us
- Privacy Policy
Get monthly updates about new articles, cheatsheets, and tricks.
- Ask a Question
- Write a Blog Post
- Login / Sign-up

Dynamic Programming in ABAP – Part 1 – Introduction to Field Symbols
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:
- Typed Field Symbol
- Generic Field Symbol
Typed Field Symbol – Typed field symbol can be declared as:
The output will be 2 and 4.
- 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.
Field symbol as a replacement of Work area:
Modifying internal table records – We can declare a field symbol of type any structure, which we can use while looping through an internal table.
- If we change any field of structure in field symbol, the corresponding field in internal will get updated. We don’t need to write the MODIFY statement which we would have written if we had used work area. This 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.
Appending to internal table – Now suppose we want to append some values to one internal table, then we can use field symbol as below:
After executing this, the internal table will hold two rows.
- Always perform a check on field symbol that if it is assigned before doing any operation to avoid short dump. Also after doing the operation, unassign the field symbol.
Reading internal table – We can read a record of internal table using field symbol as below:
Generic Field Symbol:
Dynamic programming is actually implemented using generic field symbols. The most commonly used generic types are TYPE ANY and TYPE ANY 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.
Let us assign a work area of type MARA to a TYPE ANY field symbol and then populate the work area using field symbol.
- After assigning lw_mara to <fs_str> , we cannot directly use the ‘-‘ operator on field symbol to access the fields of MARA structure i.e. <fs_str>-matnr would produce syntax error. This is because the field symbol type is declared only at runtime not at compile time.
- So to access the matnr field with field symbol, first we need to assign that field component to a different field symbol and then use the new field symbol to update the matnr field as show in above code snippet.
- After execution of above code snippet, the value of lw_mara-matnr would be MAT001 .
TYPE ANY TABLE:
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.
Reading internal table using generic field symbol:
- 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.
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/
Assigned Tags

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.
- Share Right click and copy the link to share this comment

its for readability.we shud not invent new things just for the heck of it. readability in a program is very important for the portability and management of code.

What “should not invent new things” means, here?
i mean the idea of ditching fs_ from the name of field symbol is against universally accepted standards and its better not to divert bcz it might reduce readability and clarity in complex coding.
I've been telling developers to not use <FS_...> for 20 years. I think all the projects I was working in did not prefix them with FS. Sorry, it's not a universal rule. I don't know who invented this rule of prefixing field symbols with FS. I think those people who invented the prefix FS for field symbols were crazy 😉
"i mean the idea of ditching fs_ from the name of field symbol is against universally accepted standards"
With the greatest possible respect - this is not the case. But just to be sure I checked - twice - and it turns out - I am right. It really isn't the case..
I've been programming in ABAP since 1997. I've also defined the standards for numerous multinationals. Never was <fs_...> permitted. In code reviews, the code would be sent back and the programmer told not to be so silly. Precisely because clarity and readability are so important.
I've also managed to get the current SAP and DSAG recommendations for variable naming included at a couple of global companies. These recommendations follow the general consensus across the entire IT current programming community that clarity and meaningful names are vital to readability, and prefixes reduce clearly and readability and so should be avoided .
Do you also prefix forms with F_
Thanks for sharing ur experience. I’ve always seen field symbols with fs_ in more than 15 years of experience seeing multitude of global MNC systems across geographies . If there are any std sap blogs / document / examples without this convention then it will be good to refer. Maybe within scn site itself . tat is in case it’s worth spending any more time. thanks
Avoid prefixes (documentation “Clean ABAP”, by SAP): https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#avoid-encodings-esp-hungarian-notation-and-prefixes

Personally I don't even consider the 'fs_' part to be a prefix. It's completely useless in my eyes as the '<' & '>' clearly indicate that you're looking at a field-symbol.
A prefix in a field-symbol would be adding a 's_', 't_',.. etc to the name of the field-symbol. At the very least that would add some meaning :).
Also, with regards to the Clean ABAP styleguide, no prefixes works if you adhere to a functional style of programming (smaller 'functions' that do only one thing). Sadly, I still see a lot off wall-of-text code, with both global & local variables.. And anyway, I prefer to see meaningful names.. so rather LV_COMPANY_CODE than LV_BUKRS or gods forbid BUKRS ;).
Last but not least, for a lot of us, it is the customer that decides upon the naming conventions, and it is not that easy to convince them to change these..
Or lv_bukrs for a global variable... (But I only use it locally within methods... ? )
I’ve always seen field symbols with fs_
This is exactly how wrong practices get perpetuated. Nobody challenges the status quo, nobody thinks. And then it becomes the standard - and it's still wrong.

Spot on... I challenge it all the time because that's the road to continuous improvement. One of my least favorite sayings of all time... "That's the way we've always done it".

Hello Rahul,
- 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.

Hi Jacques,
Thanks for putting new points.

Also Rahul, you can refer to this quick reference to understand the latest advancements in ABAP – https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
The full documentation is available at https://help.sap.com/doc/abapdocu_740_index_htm/7.40/en-US/index.htm
With these advancements programming is fun.
Thanks Tamit

Good to begin with field symbols..! Rahul. Cheers.

I ask for information,
rather than
Isn't this better?

I still don't see what the advantage of using field symbols is.
For example, instead of
what's wrong with

I like your example and agree to use that simple code instead of that confusing code with assigning and unassing field symbol.
Insert/edit link
Enter the destination URL
Or link to existing content
- Stack Overflow Public questions & answers
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Talent Build your employer brand
- Advertising Reach developers & technologists worldwide
- About the company
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Assigning Inline declared table to Field Symbols
There is an inline-declared table generated from a SELECT statement as below:
How can lt_result be assigned to a Field Symbol?
I tried the following way:
But I'm not able to call any components in the field symbol inside the loop like:
(syntax error: The data object "<FS_LT_RESULT>" does not have a structure and therefore does not have a component called "CARRID". )
- custom-data-type
3 Answers 3
Inline declaration of a field symbol for an internal table in an ASSIGN statement and inline declaration of a field symbol for the rows of the table in a LOOP.
source: https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenfield-symbol_inline.htm
- 1 To answer the reason why you're "not able to call any components in the FS inside the loop like <fs_lt_result>-base_unit " (in fact it means that you get a syntax error at compile time), this is because you declared the field symbol TYPE ANY, the compiler assumes that the field symbol will reference a data object of any type at runtime, so mentioning the component BASE_UNIT is refused. If you don't use an inline declaration for the field symbol, another way is to declare: FIELD-SYMBOLS <fs_lt_result> LIKE LINE OF lt_result. (after the declaration of lt_result of course) – Sandra Rossi Feb 17, 2018 at 20:00
You declared that the field symbol is of unknown type ( ANY , i.e. the exact type is known only at run time), so the compiler can't be sure that the mentioned component ( CARRID ) exists, hence the syntax error.
If you want to mention a component statically, the compiler must be informed of the exact type (what components exist).
For instance, this would work:
Or use the inline declaration of the field symbol as you proposed in your own answer/solution:
NB: if your internal table had a type decided at run time only, it would be impossible to indicate statically the component name and you'd need to refer to the component dynamically:
EXAMPLE: FIELD SYMBOL : TYPE VBAK. DATA: ITAB TYPE TABLE OF VBAK .
SELECT * FROM VBAK INTO TABLE ITAB UP TO 10 ROWS.
LOOP AT ITAB ASSIGNING WRITE : / -VBELN . (WRITE WHICH OUTPUT YOU WANT TO DISPLAY) ENDLOOP.
- 4 Hellow and welcome to SO, please consider this guideline to improve your answer How to Answer – LuckyLikey Dec 14, 2018 at 6:29
Your Answer
Sign up or log in, post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged abap custom-data-type or ask your own question .
- The Overflow Blog
- How Intuit democratizes AI development across teams through reusability sponsored post
- The nature of simulating nature: A Q&A with IBM Quantum researcher Dr. Jamie...
- Featured on Meta
- We've added a "Necessary cookies only" option to the cookie consent popup
- Launching the CI/CD and R Collectives and community editing features for...
- Staging Ground Beta 1 Recap, and Reviewers needed for Beta 2
- The [amazon] tag is being burninated
- Temporary policy: ChatGPT is banned
Hot Network Questions
- Recovering from a blunder I made while emailing a professor
- Can you write oxidation states with negative Roman numerals?
- How can I check before my flight that the cloud separation requirements in VFR flight rules are met?
- Linear Algebra - Linear transformation question
- Did any DOS compatibility layers exist for any UNIX-like systems before DOS started to become outmoded?
- The difference between the phonemes /p/ and /b/ in Japanese
- Do roots of these polynomials approach the negative of the Euler-Mascheroni constant?
- What can a lawyer do if the client wants him to be acquitted of everything despite serious evidence?
- Rolling cube on an infinite chessboard
- How to tell which packages are held back due to phased updates
- Tips for golfing in SVG
- My code is GPL licensed, can I issue a license to have my code be distributed in a specific MIT licensed project?
- Disconnect between goals and daily tasks...Is it me, or the industry?
- How to handle a hobby that makes income in US
- Acidity of alcohols and basicity of amines
- How can we prove that the supernatural or paranormal doesn't exist?
- Is it suspicious or odd to stand by the gate of a GA airport watching the planes?
- How does fire heat air?
- Replacing broken pins/legs on a DIP IC package
- How is an ETF fee calculated in a trade that ends in less than a year?
- Is the God of a monotheism necessarily omnipotent?
- Lots of pick movement
- Checking system vs. SEPA and the like
- Short story taking place on a toroidal planet or moon involving flying
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .
- Ask a Question
- Write a Blog Post
- Login / Sign-up

Assign field symbols
I have an issue on
FIELD-SYMBOLS :
<itab> TYPE ANY TABLE ,
<wa> TYPE ANY,
I am facing assign error.
How to append values into internal table from WA using field symbols.??
Using Field Symbols To Process Internal Tables
After completing this lesson, you will be able to:
- Process internal tables using field symbols
Using Field Symbols To Access Internal Tables
You have already learned how to iterate over an internal table using a structure as a work area. When you use this technique, the system copies data from the internal table into the work area. You then change the contents of the work area before copying them back into the internal table using the MODIFY statement.

If you use this technique to process a large internal table, you risk causing performance problems because of the costs of copying the data back and forth. You can reduce these costs by replacing the work area with a field symbol.
Replacing a Work Area With a Field Symbol
A field symbol is a pointer. A pointer is a data object that knows the memory address of a different object and allows you to manipulate that object. In the case of internal tables, the pointer allows you to address a line of an internal table without first copying it into a work area. Since you work directly with the table line and not with a work area, you do not have to copy your changes back into the internal table.

To define a field symbol, you use the FIELD-SYMBOLS statement and assign a name to the field symbol. The name must be included in angled brackets. You also assign a type to the field symbol. If you want to use a field symbol to process an internal table, you define the field symbol with the line type of the internal table, just as you would with a work area.
To use the field symbol in a loop over an internal table, you use the ASSIGNING addition in the LOOP statement. In each loop pass, the pointer now points to the corresponding line of the internal table and you can change its contents directly. As the field symbol has the line type of the internal table, you can treat it as you would a corresponding structure. After the name of the field symbol, you can type a dash, followed by the field that you want to change.
Since you are working directly with the internal table and not with a structure, there is no need for the MODIFY statement. By avoiding copying data, you can improve the performance of the loop considerably.
Runtime Comparison

Here you can see the result of a runtime analysis in which an internal table is updated using a MODIFY statement and another is updated using a field symbol. In this case, the field symbol takes 40% less time than the modify statement. As a rule, you can expect to save 25–40% of the runtime when you update an internal table using a field symbol instead of a work area. The performance gain for read operations is smaller.
Try It Out: Using Field Symbols To Access Internal Tables
- Create a new class that implements the interface IF_OO_ADT_CLASSRUN .
- Copy the following code snippet to the implementation part of method if_oo_adt_classrun~main( ) : Code snippet Copy code METHOD if_oo_adt_classrun~main. * Execute this class using Profile As->ABAP Application * In the analysis, look at the comparative runtimes of * the methods loop_work_area( ) and loop_field_symbol( ) data(flights) = new lcl_demo( ). flights->use_work_area( ). flights->use_field_symbol( ). out->write( 'Done' ). Copy code
- Switch to the Local Types tab and copy the following code snippet into the editor: Code snippet Copy code CLASS lcl_demo DEFINITION. PUBLIC SECTION. METHODS use_work_area. METHODS use_field_symbol. PRIVATE SECTION. TYPES t_flights TYPE STANDARD TABLE OF /dmo/flight WITH NON-UNIQUE KEY carrier_id connection_id flight_date. METHODS loop_field_symbol CHANGING c_flights TYPE t_Flights. METHODS loop_Work_area CHANGING c_flights TYPE t_flights. ENDCLASS. CLASS lcl_demo IMPLEMENTATION. METHOD use_field_symbol. DATA flights TYPE t_flights. SELECT FROM /dmo/flight FIELDS * INTO TABLE @flights. loop_field_symbol( CHANGING c_flights = flights ). ENDMETHOD. METHOD use_work_area. DATA flights TYPE t_flights. SELECT FROM /dmo/flight FIELDS * INTO TABLE @flights. loop_work_area( CHANGING c_flights = flights ). ENDMETHOD. METHOD loop_field_symbol. LOOP AT c_flights ASSIGNING FIELD-SYMBOL(). -seats_occupied += 1. ENDLOOP. ENDMETHOD. METHOD loop_work_area. LOOP AT c_flights INTO DATA(flight). flight-seats_occupied += 1. MODIFY c_flights FROM flight. ENDLOOP. ENDMETHOD. ENDCLASS. Copy code
- Select Ctrl + F3 to activate the class.
- Right-click in the Editor and choose Profile As... → ABAP Application (Console) .
- In the Details , uncheck the checkbox SQL database access , and choose Finish .
- Switch to the ABAP Profiler perspective and double-click on the trace item (you may need to refresh the display first) .
- Choose Hit List .
- Compare the runtimes of the methods loop_Work_area( ) and loop_field_symbol( ) .
Save progress to your learning plan by logging in or creating an account

IMAGES
VIDEO
COMMENTS
An inline declaration for a field symbol can only be made once within a context and the field symbol cannot yet be declared there using FIELD-SYMBOLS. If the type of the assigned memory area is defined by reference to a data type in ABAP Dictionary, it is used together with its semantic attributes, such as field help, input help, or conversion ...
Field Symbols. Field symbols are placeholders or symbolic names for existing data objects (or parts of existing data objects), declared by the statement FIELD-SYMBOLS or by the declaration operator FIELD-SYMBOL . A memory area is assigned to a field symbol at program runtime. A field symbol does not reserve physical space in the data area of a ...
FIELD-SYMBOLS: <fs_line> TYPE any, "generic <fs_struct> TYPE kna1. "non-generic Assigning. Field-Symbols are unassigned on declaration, which means that they are pointing to nothing. Accessing an unassigned Field-Symbol will lead to an exception, and, if uncaught, to a short dump.
Mar 20, 2014 at 06:49 AM. hi, As per my understanding you need to populate the column A in the table, where the column B and C are already populated. For this you need to do as follows. Loop at itab assigning <fs>. <fs>-a = "your value". Endloop. where <fs> is the field symbol of type line of itab.
Dynamic programming is actually implemented using generic field symbols. The most commonly used generic types are TYPE ANY and TYPE ANY TABLE. FIELD-SYMBOLS: <fs_str> TYPE ANY. FIELD-SYMBOLS: <fs_tab> TYPE ANY TABLE. Here we can assign any data object to TYPE ANY field symbol whereas TYPE ANY TABLE field symbol is used for assigning any ...
LOOP AT lt_result ASSIGNING FIELD-SYMBOL(<fs_lt_result>). NB: if your internal table had a type decided at run time only, it would be impossible to indicate statically the component name and you'd need to refer to the component dynamically: ASSIGN COMPONENT ('CARRID') OF STRUCTURE <fs_lt_result> TO FIELD-SYMBOL(<field>). IF sy-subrc = 0.
data : lo_ref type data . field-symbols : <lt_table> type any table, <ls_data> type any . create data lo_ref type standard table of ( lv_type ). assign lo_ref->* to <lt_table> .""once u do this <lt_table> has type assigned. append initial line to <lt_table> assigning <ls_data>. Hope this solves your issue.
If you want to use a field symbol to process an internal table, you define the field symbol with the line type of the internal table, just as you would with a work area. To use the field symbol in a loop over an internal table, you use the ASSIGNING addition in the LOOP statement. In each loop pass, the pointer now points to the corresponding ...