The document discusses advanced usage of ABAP field symbols including copying data between internal tables using field symbols, assigning data from one field symbol to another, and dynamically accessing structure components by name or component number using field symbols. It provides code examples for copying data between tables using two field symbols, assigning data from one table line to another using field symbols, and dynamically accessing a structure component by name or number assigned to a field symbol.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
46 views3 pages
Field-Symbols - 2
The document discusses advanced usage of ABAP field symbols including copying data between internal tables using field symbols, assigning data from one field symbol to another, and dynamically accessing structure components by name or component number using field symbols. It provides code examples for copying data between tables using two field symbols, assigning data from one table line to another using field symbols, and dynamically accessing a structure component by name or number assigned to a field symbol.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3
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.
In this second part of the FS usage code snippet, check out the advanced usage – Like Copy ITAB to ITAB, Dynamic Component access. Check out ABAP Field Symbols usage for first part of this.
Page Contents [hide]
1 Copy Internal Tables using two field-symbols o 1.1 2 Assign data using two field-symbols o 2.1 3 Field Symbol to access component by Name o 3.1 4 Field Symbol to access component by Component Number o 4.1
Copy Internal Tables using two field-symbols
DATA: lt_1 TYPE STANDARD TABLE OF t100.
DATA: lt_2 TYPE STANDARD TABLE OF t100. FIELD-SYMBOLS: <lt_1> TYPE ANY TABLE. FIELD-SYMBOLS: <lt_2> TYPE ANY TABLE. * ASSIGN lt_1 TO <lt_1>. * SELECT * FROM t100 INTO TABLE <lt_1> UP TO 10 ROWS. * ASSIGN lt_2 TO <lt_2>. <lt_2> = <lt_1>. * DATA: lv_lines TYPE i. lv_lines = LINES( lt_2 ). WRITE: lv_lines.
Assign data using two field-symbols
DATA: lt_1 TYPE STANDARD TABLE OF t100.
DATA: lt_2 TYPE STANDARD TABLE OF t100. FIELD-SYMBOLS: <ls_1> TYPE t100. FIELD-SYMBOLS: <ls_2> TYPE t100. * SELECT * FROM t100 INTO TABLE lt_1 UP TO 10 ROWS. * LOOP AT lt_1 ASSIGNING <ls_1>. APPEND INITIAL LINE TO lt_2 ASSIGNING <ls_2>. <ls_2> = <ls_1>. ENDLOOP. * DATA: lv_lines TYPE i. lv_lines = LINES( lt_2 ). WRITE: lv_lines.
Field Symbol to access component by Name
DATA: lt_1 TYPE STANDARD TABLE OF t100.
FIELD-SYMBOLS: <ls_1> LIKE LINE OF lt_1. * SELECT * FROM t100 INTO TABLE lt_1 UP TO 10 ROWS. * * dynamic access DATA: lv_field TYPE char30. FIELD-SYMBOLS: <lv_field> TYPE ANY. lv_field = 'TEXT'. LOOP AT lt_1 ASSIGNING <ls_1>. ASSIGN COMPONENT lv_field OF STRUCTURE <ls_1> TO <lv_field>. CHECK <lv_field> IS ASSIGNED. WRITE: / <lv_field>. ENDLOOP.
Field Symbol to access component by Component Number
DATA: lt_1 TYPE STANDARD TABLE OF t100. FIELD-SYMBOLS: <ls_1> LIKE LINE OF lt_1. * SELECT * FROM t100 INTO TABLE lt_1 UP TO 10 ROWS. * * dynamic access DATA: lv_comp_number TYPE i. FIELD-SYMBOLS: <lv_field> TYPE ANY. lv_comp_number = 4. LOOP AT lt_1 ASSIGNING <ls_1>. ASSIGN COMPONENT lv_comp_number OF STRUCTURE <ls_1> TO <lv_field>. CHECK <lv_field> IS ASSIGNED. WRITE: / <lv_field>. ENDLOOP.