*&---------------------------------------------------------------------*
*& Report zabap07
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zabap07.
types : begin of ty_main.
include structure sflight .
types : carrname like scarr-carrname,
countryfr like spfli-countryfr,
countryto like spfli-countryto,
end of ty_main.
data : it_main type table of ty_main,
wa_main like line of it_main.
data : it_scarr type table of scarr,
wa_scarr like line of it_scarr,
it_spfli type table of spfli,
wa_spfli like line of it_spfli.
data :indxloop like SY-tabix.
start-of-SELECTION .
select * into corresponding fields of table it_main from sflight where carrid = 'AA'.
if it_main is not initial.
select * into CORRESPONDING FIELDS OF table it_scarr
from scarr for all entries in it_main
where carrid = it_main-carrid .
select * into CORRESPONDING FIELDS OF table it_spfli
from spfli for all entries in it_main
where carrid = it_main-carrid and
connid = it_main-connid.
endif.
loop at it_main into wa_main.
INDXLOOP = SY-tabix.
if wa_main-connid = '0017'.
delete it_main index indxloop.
continue.
endif.
clear wa_scarr.
read table it_scarr into wa_scarr with key carrid = wa_main-carrid.
if sy-subrc = 0.
wa_main-carrname = wa_scarr-carrname.
endif.
clear wa_spfli.
read table it_spfli into wa_spfli with key carrid = wa_main-carrid
connid = wa_main-connid.
if sy-subrc = 0.
wa_main-countryfr = wa_spfli-countryfr.
wa_main-countryto = wa_spfli-countryto.
endif.
modify it_main from wa_main index indxloop.
endloop.
* delete it_main where connid = '0017' .
loop at it_main into wa_main.
write: / wa_main-carrid,
wa_main-carrname,
wa_main-connid,
wa_main-countryfr,
wa_main-countryto,
wa_main-price.
endloop.