open SQL参照内表条件进行查询:
DATA: begin of xpfli occurs 0,
carrid like spfli-carrid,
connid like spfli-connid,
end of xpfli.
DATA: xflight like table of sflight with header line.
select
carrid connid
into corresponding fields of table xpfli
from spfli
where carrid = 'LH'
if not xpfli[] is initial.
select
*
into corresponding fields of table xflight
from sflight
for all entries in xpfli
where carrid = xpfli-carrid and connid = xpfli-connid
endif.
限制Open SQL获取数据条数:
DATA: lt_spfli like standard table of spfli with header line.
select
*
into corresponding fields of table lt_spfli
from spfli up to 5 rows.
使用up to n rows可读取数据指定前n条,但是不能继续读取数据,使用package size n 可以连续读取数据,每次读取指定条数,但必须使用select - endselect
DATA: lt_spfli like standard table of spfli with header line.
select
*
into corresponding fields of table lt_spfli
from spfli package size 5.
uline.
loop at lt_spfli.
write: / lt_spfli-carrid, lt_spfli-connid.
endloop.
endselect.