Übung zu Kapitel 4 (Teil 2) am 18. November 2015 - Lösungen A1 bis A4

REPORT ZZ_##_REPORTS.

DATA mycarrid LIKE sbook-carrid.
DATA myconnid LIKE sbook-connid.
DATA myfldate LIKE sbook-fldate.
DATA myluggweight LIKE sbook-luggweight.
*
SELECT carrid connid AVG( luggweight )
FROM sbook
INTO (mycarrid, myconnid, myluggweight)
GROUP BY carrid connid.
WRITE: / mycarrid, myconnid, myluggweight.
ENDSELECT.
*
WRITE: / '*** ENDE ***'.
*
SKIP.

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

DATA mycustomid LIKE sbook-customid.
DATA myname LIKE scustom-name.
DATA mycount TYPE i.
DATA anzahl TYPE i VALUE 0.
*
SELECT sbook~customid scustom~name COUNT( * )
FROM sbook INNER JOIN scustom ON sbook~customid = scustom~id
INTO (mycustomid, myname, mycount)
GROUP BY sbook~customid scustom~name
ORDER BY scustom~name sbook~customid.
WRITE: / myname, mycount.
ADD mycount TO anzahl.
ENDSELECT.
*
WRITE: /(25) '*** SUMME ***', anzahl.
WRITE: / '*** ENDE ***'.
*
SKIP.

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

PARAMETER custom LIKE sbook-customid.
*
DATA myname2 LIKE scustom-name.
DATA mycity LIKE scustom-city.
DATA myfldate2 LIKE sbook-fldate.
DATA mycityfrom LIKE spfli-cityfrom.
DATA mycityto LIKE spfli-cityto.
DATA mycarrname LIKE scarr-carrname.
*
SELECT SINGLE name city FROM scustom INTO (myname2, mycity) WHERE id = custom.
WRITE: / 'Kunde:', myname2, '/', mycity.
*
SELECT sbook~fldate spfli~cityfrom spfli~cityto scarr~carrname
FROM sbook
INNER JOIN spfli ON sbook~carrid = spfli~carrid AND sbook~connid = spfli~connid
INNER JOIN scarr ON spfli~carrid = scarr~carrid
INTO (myfldate2, mycityfrom, mycityto, mycarrname)
WHERE sbook~customid = custom.
WRITE: / myfldate2, mycityfrom, mycityto, mycarrname.
ENDSELECT.
*
WRITE / '*** ENDE ***'.
*
SKIP.

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

PARAMETER carrier LIKE smenu-carrid.
*
DATA mymenunumber LIKE smenu-menunumber.
*
DATA mystarter_d LIKE smealt-text.
DATA mystarter_e LIKE smealt-text.
DATA mymaincourse_d LIKE smealt-text.
DATA mymaincourse_e LIKE smealt-text.
DATA mydessert_d LIKE smealt-text.
DATA mydessert_e LIKE smealt-text.
*
WRITE: 'Fluggesellschaft:', carrier.
ULINE /(81).
*
SELECT a~menunumber b~text c~text d~text e~text f~text g~text
FROM smenu AS a
INNER JOIN smealt AS b ON a~carrid = b~carrid AND a~starter = b~mealnumber AND b~sprache = 'D'
INNER JOIN smealt AS c ON a~carrid = c~carrid AND a~starter = c~mealnumber AND c~sprache = 'E'
INNER JOIN smealt AS d ON a~carrid = d~carrid AND a~maincourse = d~mealnumber AND d~sprache = 'D'
INNER JOIN smealt AS e ON a~carrid = e~carrid AND a~maincourse = e~mealnumber AND e~sprache = 'E'
INNER JOIN smealt AS f ON a~carrid = f~carrid AND a~dessert = f~mealnumber AND f~sprache = 'D'
INNER JOIN smealt AS g ON a~carrid = g~carrid AND a~dessert = g~mealnumber AND g~sprache = 'E'
INTO (mymenunumber,
mystarter_d, mystarter_e,
mymaincourse_d, mymaincourse_e,
mydessert_d, mydessert_e)
WHERE a~carrid = carrier
ORDER BY a~menunumber.
WRITE: / 'Menue:', mymenunumber.
WRITE: / mystarter_d, mystarter_e.
WRITE: / mymaincourse_d, mymaincourse_e.
WRITE: / mydessert_d, mydessert_e.
ULINE /(81).
ENDSELECT.
*
WRITE / '*** ENDE ***'.