범용SQL
(<-> Native SQL: 특정DB 맞춤 SQL)ABAP에서
사용하는 SQLSELECT <FIELD1> <FIELD2> <FIELD3> ...
INTO CORRESPONDING FIELDS OF TABLE <ITAB>
FROM <DB_TABLE>.
WHERE <FIELD1> = '<값1>'
AND <FIELD2> = '<값2>'
AND ( <FIELD3> = '<값3>' OR <FIELD4> <> '<값4>' )
MANDT
를 포함한다.순서가 같다고 가정
한다.BEGIN OF
문으로 새로운 스트럭처를 만들어야 한다.자동 매칭
해 값을 넣어준다.필드명만 같으면
문제가 없다.OPTIONAL
필수가 아닌 선택 사항이다.
OR
AND
와 OR
주의사항
DATA : BEGIN OF gs_spfli,
carrid TYPE SPFLI-CARRID,
connid TYPE SPFLI-CONNID,
countryfr TYPE SPFLI-COUNTRYFR,
cityfrom TYPE SPFLI-CITYFROM,
airpfrom TYPE SPFLI-AIRPFROM,
countryto TYPE SPFLI-COUNTRYTO,
cityto TYPE SPFLI-CITYTO,
fltime TYPE SPFLI-FLTIME,
fltype TYPE SPFLI-FLTYPE,
END OF gs_spfli,
gt_spfli LIKE TABLE OF gs_spfli.
CLEAR gs_spfil.
REFRESH gt_spfli.
SELECT carrid connid countryfr cityfrom
airpfrom countryto cityto fltime fltype
INTO CORRESPONDING FIELDS OF TABLE gt_spfli
FROM spfli
WHERE carrid EQ 'LH'
AND countryto EQ 'DE'.
cl_demo_output=>display( gt_sflight ).
DATA : BEGIN OF gs_sflight,
carrid TYPE SFLIGHT-CARRID,
connid TYPE SFLIGHT-CONNID,
fldate TYPE SFLIGHT-FLDATE,
currency TYPE SFLIGHT-CURRENCY,
planetype TYPE SFLIGHT-PLANETYPE,
END OF gs_sflight,
gt_sflight LIKE TABLE OF gs_sflight.
CLEAR gs_sflight.
REFRESH gt_sflight.
SELECT carrid connid fldate currency planetype
INTO CORRESPONDING FIELDS OF TABLE gT_sflight
FROM SFLIGHT
WHERE CURRENCY EQ 'USD'
AND PLANETYPE EQ '747-400'.
cl_demo_output=>display( gt_sflight ).
DATA : BEGIN OF gs_sbook,
carrid TYPE SBOOK-CARRID,
connid TYPE SBOOK-CONNID,
fldate TYPE SBOOK-FLDATE,
bookid TYPE SBOOK-BOOKID,
customid TYPE SBOOK-CUSTOMID,
custtype TYPE SBOOK-CUSTTYPE,
END OF gs_sbook,
gt_sbook LIKE TABLE OF gs_sbook.
CLEAR : gs_sbook.
REFRESH : gt_sbook.
SELECT carrid connid fldate bookid customid custtype
INTO CORRESPONDING FIELDS OF TABLE gt_sbook
FROM sbook
WHERE carrid = 'LH'
AND connid = '0401'
AND customid = '25'.
cl_demo_output=>display( gt_sbook ). ㅁ