Question

I am confused as to why the commented out query doesn't work.


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 19:54:19

Short text Field symbol has not yet been assigned.

Why do I get this runtime error?

Was it helpful?

Solution

I assume (based on the error and the pieces of code that I can't actually see) that you're trying to select data directly into a field symbol. You can't do that. A field symbol is not a memory area, it is (basically) a pointer.

You could 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 are pointing the field symbol to a new line that you've 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 retrieve all documents that match and place them directly into your internal table.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top