Assign SELECT result to field symbol
I don't understand why the commented out request is not working.
REPORT z_hello_world_local.
TYPES: BEGIN OF bkpf_type,
xblnr TYPE bkpf-xblnr,
END OF bkpf_type.
DATA: t_bkpf TYPE TABLE OF bkpf_type.
FIELD-SYMBOLS: <bkpf> TYPE bkpf_type.
*This query does not work?
*SELECT xblnr
* INTO CORRESPONDING FIELDS OF <bkpf> UP TO 1 ROWS
* FROM bkpf
* WHERE belnr = '1800001017'.
* ENDSELECT.
*
DATA: t_xblnr TYPE bkpf-xblnr.
*This query works and in my head it is roughly the same thing.
SELECT SINGLE xblnr
INTO t_xblnr
FROM bkpf
WHERE belnr = '1800001017'.
write 'Done'.
If I run the commented out query, I get the error:
Runtime errors GETWA_NOT_ASSIGNED Date and time
08/26/2009 7:54:19 PMShort text The field symbol has not yet been assigned.
Why am I getting this error at runtime?
+2
source to share
1 answer
I am assuming (based on the error and code snippets that I don't actually see) that you are trying to cast data directly into a field character. You cannot do this. The field symbol is not a memory area, it is (mostly) a pointer.
You can do one of the following:
data: wa_bkpf type bkpf_type.
select xblnr
into corresponding fields of wa_bkpf
up to 1 rows
from bkpf
where xblnr = '1800001017'.
endselect.
or
field-symbols: <bkpf> type bkpf_type.
append initial line to t_bkpf assigning <bkpf>.
select xlbnr
into corresponding fields <bkpf>
up to 1 rows
from bkpf
where xblnr = '1800001017'.
endselect.
In this case, you point the field symbol to a new row added to the internal table.
or
select xblnr
into corresponding fields of table t_bkpf
from bkpf
where xlbnr = '1800001017'.
In this case, you will get all the relevant documents and put them right in the inner table.
+6
source to share