Today, I came across a declaration-dilemma situation in an old code.
Consider the following snippet:
REPORT ZPROGRAM.
DATA: v_data TYPE field.
FORM code_block.
SELECT SINGLE datum FROM db INTO @v_data WHERE field = @value.
SELECT SINGLE datum FROM db INTO @DATA(v_data) WHERE field = @value.
ENDFORM.
This code holds no error.
Now, the first select statement retrieves the data (sy-subrc = 0) but V_DATA is not populated with the data. I expected V_DATA to reflect the data since it is a global variable at this point.
Does the inline declaration of V_DATA obscure its global definition since both variables are of the same name? But why does it happen since the inline declaration happens after the global variable's visibility?