1.) Selection screen with check
boxes and
2.) Fetching the data using inner join condition for two tables
REPORT ZREPORT6.
TABLES: SPFLI, SFLIGHT.
DATA: FLAG VALUE 0.
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 SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 25(15) TEXT-002.
PARAMETERS C1 AS CHECKBOX.
*PARAMETERS C1 RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 25(15) TEXT-003.
PARAMETERS C2 AS CHECKBOX.
*PARAMETERS C2 RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK B1.
IF c1 = 'X' AND C2 <> 'X'. FLAG = 1.
ELSEIF c2 = 'X' AND C1 <> 'X'. FLAG = 2.
ELSEIF c1 = 'X' AND c2 = 'X'. FLAG = 3.
ELSEIF c1 <> 'X' AND c2 <> 'X'. FLAG = 4.
ENDIF.
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.
CASE FLAG.
WHEN 1.
LOOP AT ITAB INTO WA.
WRITE: / WA-CARRID,
WA-CONNID,
WA-COUNTRYFR,
WA-CITYFROM.
ENDLOOP.
IF SY-SUBRC NE 0.
SKIP.
ULINE.
WRITE : '|', 'DATA NOT FOUND FOR GIVEN CRITERIA' COLOR 7 INVERSE ON , 130 '|'.
ENDIF.
WHEN 2.
LOOP AT ITAB INTO WA.
WRITE: / WA-FLDATE,
WA-PRICE,
WA-CURRENCY.
ENDLOOP.
IF SY-SUBRC NE 0.
SKIP.
ULINE.
WRITE : '|', 'DATA NOT FOUND FOR GIVEN CRITERIA' COLOR 7 INVERSE ON , 130 '|'.
ENDIF.
WHEN 3.
LOOP AT ITAB INTO WA.
WRITE: / WA-CARRID,
WA-CONNID,
WA-COUNTRYFR,
WA-CITYFROM,
WA-FLDATE,
WA-PRICE,
WA-CURRENCY.
ENDLOOP.
IF SY-SUBRC NE 0.
SKIP.
ULINE.
WRITE : '|', 'DATA NOT FOUND FOR GIVEN CRITERIA' COLOR 7 INVERSE ON , 130 '|'.
ENDIF.
WHEN 4.
WRITE: /
'PLEASE SELECT CHECK BOX C1 FOR FLIGHTS ,C2 FOR DATES'.
ENDCASE.
DATA: FLAG VALUE 0.
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 SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 25(15) TEXT-002.
PARAMETERS C1 AS CHECKBOX.
*PARAMETERS C1 RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 25(15) TEXT-003.
PARAMETERS C2 AS CHECKBOX.
*PARAMETERS C2 RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK B1.
IF c1 = 'X' AND C2 <> 'X'. FLAG = 1.
ELSEIF c2 = 'X' AND C1 <> 'X'. FLAG = 2.
ELSEIF c1 = 'X' AND c2 = 'X'. FLAG = 3.
ELSEIF c1 <> 'X' AND c2 <> 'X'. FLAG = 4.
ENDIF.
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.
CASE FLAG.
WHEN 1.
LOOP AT ITAB INTO WA.
WRITE: / WA-CARRID,
WA-CONNID,
WA-COUNTRYFR,
WA-CITYFROM.
ENDLOOP.
IF SY-SUBRC NE 0.
SKIP.
ULINE.
WRITE : '|', 'DATA NOT FOUND FOR GIVEN CRITERIA' COLOR 7 INVERSE ON , 130 '|'.
ENDIF.
WHEN 2.
LOOP AT ITAB INTO WA.
WRITE: / WA-FLDATE,
WA-PRICE,
WA-CURRENCY.
ENDLOOP.
IF SY-SUBRC NE 0.
SKIP.
ULINE.
WRITE : '|', 'DATA NOT FOUND FOR GIVEN CRITERIA' COLOR 7 INVERSE ON , 130 '|'.
ENDIF.
WHEN 3.
LOOP AT ITAB INTO WA.
WRITE: / WA-CARRID,
WA-CONNID,
WA-COUNTRYFR,
WA-CITYFROM,
WA-FLDATE,
WA-PRICE,
WA-CURRENCY.
ENDLOOP.
IF SY-SUBRC NE 0.
SKIP.
ULINE.
WRITE : '|', 'DATA NOT FOUND FOR GIVEN CRITERIA' COLOR 7 INVERSE ON , 130 '|'.
ENDIF.
WHEN 4.
WRITE: /
'PLEASE SELECT CHECK BOX C1 FOR FLIGHTS ,C2 FOR DATES'.
ENDCASE.
No comments:
Post a Comment