Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

hey all!

can i populate one internal table by taking data from three different databse tables

...... because the internal table contains fields from different tables....???

what kind of sql query it will be.

Tags:
Former Member
Former Member replied

Hi,

You can use JOIN statement. Check the below code.

DATA: BEGIN OF WA,

CARRID TYPE SPFLI-CARRID,

CONNID TYPE SPFLI-CONNID,

FLDATE TYPE SFLIGHT-FLDATE,

BOOKID TYPE SBOOK-BOOKID,

END OF WA,

ITAB LIKE SORTED TABLE OF WA

WITH UNIQUE KEY CARRID CONNID FLDATE BOOKID.

SELECT PCARRID PCONNID FFLDATE BBOOKID

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM ( ( SPFLI AS P

INNER JOIN SFLIGHT AS F ON PCARRID = FCARRID AND

PCONNID = FCONNID )

INNER JOIN SBOOK AS B ON BCARRID = FCARRID AND

BCONNID = FCONNID AND

BFLDATE = FFLDATE )

WHERE P~CITYFROM = 'FRANKFURT' AND

P~CITYTO = 'NEW YORK' AND

FSEATSMAX > FSEATSOCC.

LOOP AT ITAB INTO WA.

AT NEW FLDATE.

WRITE: / WA-CARRID, WA-CONNID, WA-FLDATE.

ENDAT.

WRITE / WA-BOOKID.

ENDLOOP.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question