You are on page 1of 3
ABAP Field Symbols usage ABAP Field Symbols are very powerful. Usage of Field-Symbols would provide performance gain, but for that you must use it correctly otherwise you may run into issues. Field-symbols can provide great performance over using workarea as I have mentioned in my earlier article – Use of Field-symbols vs Work area. I have mentioned many articles using FieldSymbols but wanted to note down the basics as part of this code snippet. Declare a Field Symbols TYPES: tt_mara TYPE STANDARD TABLE OF mara. DATA: t_mara TYPE tt_mara. * FIELD-SYMBOLS: LIKE LINE OF t_mara. " << * " Field symbol without type FIELD-SYMBOLS: TYPE ANY TABLE, TYPE ANY. APPEND and INSERT using Field Symbols * Append line APPEND INITIAL LINE TO t_mara ASSIGNING . -matnr = '123456'. * * insert table INSERT INITIAL LINE INTO t_mara ASSIGNING INDEX 2. -matnr = 'ABCDEF'. Access ITAB rows using Field Symbols * Read table READ TABLE t_mara ASSIGNING WITH KEY matnr = '123456'. IF sy-subrc EQ 0. WRITE: -matnr. ENDIF. * * Access via Loop LOOP AT t_mara ASSIGNING . WRITE: -matnr. ENDLOOP. Modify an entry using Field-Symbols: * READ and MODIFY READ TABLE t_mara ASSIGNING WITH KEY matnr = '123456'. IF sy-subrc EQ 0. -ersda = sy-datum. ENDIF. * * LOOP and MODIFY LOOP AT t_mara ASSIGNING . -ersda = sy-datum + 1 ENDLOOP. CHECK field Symbols using IS ASSIGNED Check if Field Symbol is assigned to a valid reference * Check if Field-Symbol is assigned IF IS ASSIGNED. WRITE: 'Assigned'. ELSE. WRITE: 'Unassigned'. ENDIF. Remove the Reference of the Field Symbols "remvoe the reference UNASSIGN . Field-Symbols on SAP Help