Report with Inner join Condition of Two Tables
REPORT ZREPORT5.
TABLES: SPFLI, SFLIGHT.
TYPES: BEGIN OF ST,
CARRID TYPE SPFLI-CARRID,
CONNID TYPE SPFLI-CONNID,
COUNTRYFR TYPE SPFLI-COUNTRYFR,
CITYFROM TYPE SPFLI-CITYFROM,
FLDATE TYPE SFLIGHT-FLDATE,
PRICE TYPE SFLIGHT-PRICE,
CURRENCY TYPE SFLIGHT-CURRENCY,
END OF ST.
DATA: WA TYPE ST.
DATA: ITAB TYPE STANDARD TABLE OF ST.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: FLIGHTS FOR SPFLI-CARRID,
DATE FOR SFLIGHT-FLDATE.
SELECTION-SCREEN END OF BLOCK B1.
SELECT A~CARRID A~CONNID A~COUNTRYFR A~CITYFROM
B~FLDATE B~PRICE B~CURRENCY
INTO CORRESPONDING FIELDS OF WA
FROM SPFLI AS A INNER JOIN SFLIGHT AS B
ON B~CARRID = A~CARRID
WHERE A~CARRID IN FLIGHTS
AND B~FLDATE IN DATE .
APPEND WA TO ITAB.
ENDSELECT.
LOOP AT ITAB INTO WA.
WRITE: / WA-CARRID, SY-VLINE,
WA-CONNID,SY-VLINE,
WA-COUNTRYFR,SY-VLINE,
WA-CITYFROM,SY-VLINE,
WA-FLDATE,SY-VLINE,
WA-PRICE,SY-VLINE,
WA-CURRENCY,SY-VLINE.
ENDLOOP.
ULINE.
IF SY-SUBRC NE 0.
SKIP.
ULINE.
WRITE : '|', 'DATA NOT FOUND FOR GIVEN CRITERIA' COLOR 7 INVERSE ON , 130 '|'.
ENDIF.
TABLES: SPFLI, SFLIGHT.
TYPES: BEGIN OF ST,
CARRID TYPE SPFLI-CARRID,
CONNID TYPE SPFLI-CONNID,
COUNTRYFR TYPE SPFLI-COUNTRYFR,
CITYFROM TYPE SPFLI-CITYFROM,
FLDATE TYPE SFLIGHT-FLDATE,
PRICE TYPE SFLIGHT-PRICE,
CURRENCY TYPE SFLIGHT-CURRENCY,
END OF ST.
DATA: WA TYPE ST.
DATA: ITAB TYPE STANDARD TABLE OF ST.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: FLIGHTS FOR SPFLI-CARRID,
DATE FOR SFLIGHT-FLDATE.
SELECTION-SCREEN END OF BLOCK B1.
SELECT A~CARRID A~CONNID A~COUNTRYFR A~CITYFROM
B~FLDATE B~PRICE B~CURRENCY
INTO CORRESPONDING FIELDS OF WA
FROM SPFLI AS A INNER JOIN SFLIGHT AS B
ON B~CARRID = A~CARRID
WHERE A~CARRID IN FLIGHTS
AND B~FLDATE IN DATE .
APPEND WA TO ITAB.
ENDSELECT.
LOOP AT ITAB INTO WA.
WRITE: / WA-CARRID, SY-VLINE,
WA-CONNID,SY-VLINE,
WA-COUNTRYFR,SY-VLINE,
WA-CITYFROM,SY-VLINE,
WA-FLDATE,SY-VLINE,
WA-PRICE,SY-VLINE,
WA-CURRENCY,SY-VLINE.
ENDLOOP.
ULINE.
IF SY-SUBRC NE 0.
SKIP.
ULINE.
WRITE : '|', 'DATA NOT FOUND FOR GIVEN CRITERIA' COLOR 7 INVERSE ON , 130 '|'.
ENDIF.
No comments:
Post a Comment