By referencing a row within a table or any variable, changes can be made to that row or variable. Field-symbols cannot be used on their own. A variable needs to be assigned to them. If they are used without being assigned, a dump will occur. Therefore, it is beneficial to perform an assignment check before using them.
data : lv_string type string.
field-symbols : <fs_string> type string.
lv_string = 'This is string.'.
assign lv_string to <fs_string>.
<fs_string> = 'The words is change.'.
write : lv_string.
"The words is change.
Additionally, this assignment can be made by providing the name of the variable as a string.
data : lv_variable_name type string.
data : lv_string type string.
field-symbols : <fs_string> type string.
lv_string = 'This is string.'.
lv_variable_name = 'lv_string'.
assign (lv_variable_name) to <fs_string>.
<fs_string> = 'The words is change.'.
write : lv_string.
"The words is change.
The assignment check is performed as follows.
if <fs_data> is assign.
" assign
else.
" not assign
endif.
If the type of the variable to be assigned is unknown, a field-symbol can be created with the type any
for the assignment.
field-symbols: <fs_data> type any.