abapOpenChecks icon indicating copy to clipboard operation
abapOpenChecks copied to clipboard

Read Table: if read into variable, check variable type

Open g-back opened this issue 4 years ago • 0 comments

Example:

Structure read into regular variable, will probably cause false results. Compiler allows this:

" TYPES: BEGIN OF ty_buffer
"              input  TYPE erdat,
"              output TYPE syst_datum,
"            END OF ty_buffer.
" DATA buffer_foo TYPE TABLE OF ty_buffer.

DATA r_date TYPE syst_datum.
r_date = VALUE #( buffer_foo[ input = i_input ] OPTIONAL ).
" correct would be:
" r_date = VALUE #( buffer_foo[ input = i_input ]-output OPTIONAL ).

Same with Read Table:

READ TABLE buffer_foo INTO r_date WITH KEY input = i_input.

g-back avatar May 12 '20 08:05 g-back