abap for all entries 和read table联用查表用法详解
abap for all entries 和read table联用查表用法详解
用实例最能说明问题:
PARAMETERS p_city TYPE spfli-cityfrom.
TYPES:
BEGIN OF entry_tab_type,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
END OF entry_tab_type.
DATA: entry_tab TYPE TABLE OF entry_tab_type,
gwa_sflight TYPE sflight ,
sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate.
SELECT carrid connid
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE entry_tab
WHERE cityfrom = p_city.
SELECT carrid connid fldate
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE sflight_tab
FOR ALL ENTRIES IN entry_tab“看这里的效果,能直接与内表的字段进行匹配
WHERE carrid = entry_tab-carrid AND
connid = entry_tab-connid.
至于READ TABLE, 一次只能读取一条记录,最好将结果放入工作区!
例:
READ TABLEsflight_tab INTOgwa_sflight .
.
直接就可以使用用工作区的数据了.