You are on page 1of 3

(a)

types: BEGIN OF ty_airline,


carrier_id(2) TYPE c,
connection_id(4) TYPE n,
seats_occu TYPE i,
max_seats TYPE i,
END OF ty_airline.

data: it type TABLE OF ty_airline,


it1 TYPE TABLE OF ty_airline,
char(2) TYPE c,
wa TYPE ty_airline.

do 8 TIMES.

if sy-index mod 2 ne 0 and sy-index le 4 .


wa-carrier_id = 'AA'.
wa-connection_id = '0017'.
wa-seats_occu = 200.
wa-max_seats = 200.

APPEND wa to it.
CLEAR wa.

ELSEIF sy-index mod 2 eq 0 and sy-index le 4.


wa-carrier_id = 'DL'.
wa-connection_id = '0009'.
wa-seats_occu = 100.
wa-max_seats = 150.

append wa to it.
CLEAR wa.

ELSEIF sy-index mod 2 ne 0 and sy-index gt 4.


wa-carrier_id = 'UA'.
wa-connection_id = '1914'.
wa-seats_occu = 300.
wa-max_seats = 300.

append wa to it.
CLEAR wa.

else.
wa-carrier_id = 'LH'.
wa-connection_id = '0941'.
wa-seats_occu = 195.
wa-max_seats = 200.

append wa to it.
CLEAR wa.

ENDIF.

ENDDO.

do 2 times.
if sy-index = 1.
char = 'DL'.
else.
char = 'UA'.
ENDIF.

read TABLE it INTO wa WITH KEY carrier_id = char.

if sy-subrc eq 0.

DO 2 TIMES.

APPEND wa to it1.

ENDDO.

ENDIF.
ENDDO.

LOOP at it1 INTO wa.

write: / wa-carrier_id,wa-connection_id,wa-seats_occu,wa-max_seats.

ENDLOOP.

***************************************************************************

(b)

types: BEGIN OF ty_airline,


carrier_id(2) TYPE c,
connection_id(4) TYPE n,
seats_occu TYPE i,
max_seats TYPE i,
END OF ty_airline.

data: it type TABLE OF ty_airline,


it1 TYPE TABLE OF ty_airline,
char(2) TYPE c,
wa TYPE ty_airline.

do 8 TIMES.

if sy-index mod 2 ne 0 and sy-index le 4 .


wa-carrier_id = 'AA'.
wa-connection_id = '0017'.
wa-seats_occu = 200.
wa-max_seats = 200.

APPEND wa to it.
CLEAR wa.

ELSEIF sy-index mod 2 eq 0 and sy-index le 4.


wa-carrier_id = 'DL'.
wa-connection_id = '0009'.
wa-seats_occu = 100.
wa-max_seats = 150.

append wa to it.
CLEAR wa.

ELSEIF sy-index mod 2 ne 0 and sy-index gt 4.


wa-carrier_id = 'UA'.
wa-connection_id = '1914'.
wa-seats_occu = 300.
wa-max_seats = 300.

append wa to it.
CLEAR wa.

else.
wa-carrier_id = 'LH'.
wa-connection_id = '0941'.
wa-seats_occu = 195.
wa-max_seats = 200.

append wa to it.
CLEAR wa.

ENDIF.

ENDDO.

sort it by carrier_id.

delete ADJACENT DUPLICATES FROM it COMPARING carrier_id.

LOOP at it INTO wa.

write: / wa-carrier_id,wa-connection_id,wa-seats_occu,wa-max_seats.

ENDLOOP.

You might also like