天天看點

用OO将航班資訊顯示出來

 *&---------------------------------------------------------------------*

*&  Include           ZSER45100INC

*&---------------------------------------------------------------------*

    data: begin of ty_cusid,

      id type scustom-id,

      end of ty_cusid.

    data: begin of ty_bookinfo,

      carrid type sbook-carrid,

      connid type sbook-connid,

      fldate type sbook-fldate,

      bookid type sbook-bookid,

      customid type sbook-customid,

      end of ty_bookinfo.

class class_flight definition.

  public section.

    data cusname type scustom-name.

    data lt_cusid like standard table of ty_cusid .

    data lt_bookinfo like standard table of ty_bookinfo.

    methods:

      get_customer_id,

      get_booking_info,

      display_bookings.

endclass.

class class_flight implementation.

    method get_customer_id.

*      cusname = cusname.

      select id

        into corresponding fields of table lt_cusid

        from scustom

        where name eq cusname.

    endmethod.

    method get_booking_info.

      select

        carrid

        connid

        fldate

        bookid

        customid

        into corresponding fields of table lt_bookinfo

        from sbook

        for all entries in lt_cusid

        where bookid eq lt_cusid-id.

    endmethod.

    method display_bookings.

      LOOP AT lt_bookinfo into ty_bookinfo.

        write:/(10) ty_bookinfo-carrid,

               (5)  ty_bookinfo-connid,

               (15) ty_bookinfo-fldate,

               (15) ty_bookinfo-bookid,

               (15) ty_bookinfo-customid.

      ENDLOOP.

    endmethod.

endclass.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

****************report part***************************************************

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

REPORT  ZSER46100.

tables: sflight, sbook, scustom.

include zser45100inc.

data sflight_obj type ref to class_flight.

parameters cusname type scustom-name obligatory.

start-of-selection.

  create object sflight_obj.

  sflight_obj->cusname = cusname.

  call method sflight_obj->get_customer_id.

  call method sflight_obj->get_booking_info.

  call method sflight_obj->display_bookings.  

繼續閱讀