SAP ABAP测试程序开发SQL问题
*
INTO CORRESPONDING FIELDS OF TABLE ITAB2
FROM SCUSTOM
INNER JOIN SBOOK ON SCUSTOM~ID = SBOOK~CUSTOMID
INNER JOIN SFLIGHT ON SFLIGHT~CARRID = SBOOK~CARRID
INNER JOIN SCARR ON SFLIGHT~CARRID = SCARR~CARRID
WHERE SCUSTOM~ID IN S_ID AND SFLIGHT~FLDATE IN S_FLDATE.
这是一段sql语句 我的本意是想通过SCUSTOM表的ID来查询其他3个表关联的信息的 但是这样的代码出来的结果不尽如人意。有大神帮忙修改吗?
这是一个飞机航班表。
SCUSTOM和SBOOK关联的字段为ID
SFLIGHT里面和SCARR关联的字段为CARRID
SBOOK和SFLIGHT关联的字段为CARRID
也就是在选择屏幕上我打出001结果就是id为001的用户和另外3个表关联的相关数据显示出来
答出来追加。。 展开
好呀。。。
我测试了一下,我把代码贴出来,以及结果。。。你看看。。再提出你想要的结果呢。
REPORT ztest03.
DATA:BEGIN OF w_wa,
id TYPE scustom-id,
name TYPE scustom-name,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
currcode TYPE scarr-currcode,
url TYPE scarr-url,
connid TYPE sbook-connid,
fldate TYPE sbook-fldate,
bookid TYPE sbook-bookid,
price TYPE sflight-price,
currency TYPE sflight-currency,
planetype TYPE sflight-planetype,
END OF w_wa,
itab LIKE TABLE OF w_wa.
DATA s_id TYPE scustom-id VALUE '00000003'.
DATA s_fldate TYPE RANGE OF sflight-fldate WITH HEADER LINE.
s_fldate-low = '19950101'.
s_fldate-high = '20140312'.
s_fldate-option = 'BT'.
s_fldate-sign = 'I'.
APPEND s_fldate.
SELECT * INTO CORRESPONDING FIELDS OF TABLE itab
FROM scustom
INNER JOIN sbook ON scustom~mandt = sbook~mandt AND scustom~id = sbook~customid
INNER JOIN sflight ON sflight~mandt = sbook~mandt AND sflight~carrid = sbook~carrid AND sflight~connid = sbook~connid
INNER JOIN scarr ON sflight~mandt = scarr~mandt AND sflight~carrid = scarr~carrid
WHERE scustom~id EQ s_id AND sflight~fldate IN s_fldate[].
BREAK-POINT.
2023-08-15 广告
2014-07-17