*&---------------------------------------------------------------------*
*& Report  ZBOOK_FLIGHT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZBOOK_FLIGHT.

TYPES: BEGIN OF FLTINFO_STRUCTURE,
        FLIGHTTIME(10) TYPE N,
        CITYFROM(20) TYPE C,
        DEPDATE TYPE D,
        DEPTIME TYPE T,
        CITYTO(20) TYPE C,
        ARRDATE TYPE D,
        ARRTIME TYPE T,
  END OF FLTINFO_STRUCTURE.

TYPES: BEGIN OF CONNECTION_INFO_STRUCTURE,
        CONNID(1) TYPE N,
        AIRLINE(20) TYPE C,
        PLANETYPE(10) TYPE C,
        CITYFROM(20) TYPE C,
        DEPDATE TYPE D,
        DEPTIME TYPE T,
        CITYTO(20) TYPE C,
        ARRDATE TYPE D,
        ARRTIME TYPE T,
  END OF CONNECTION_INFO_STRUCTURE.

DATA: RFCDEST LIKE RFCDES-RFCDEST VALUE 'NONE'.

DATA: RFC_MESS(128).

DATA:  TRIPNUMBER(8) TYPE N VALUE '01234567',
       TICKET_PRICE(12) TYPE P DECIMALS 4,
       TICKET_TAX(12) TYPE P DECIMALS 4,
       CURRENCY(5) TYPE C,
       FLTINFO TYPE FLTINFO_STRUCTURE.

DATA:  CONNECTION_INFO TYPE ZCONNECTION_INFO_STRUCTURE.

DATA: INT_CONNECTION_INFO TYPE ZCONNECTION_INFO_TABLE.


PARAMETERS: AGENCYNM(8) TYPE N DEFAULT 00000110,
            CUSTNAME(25) TYPE C DEFAULT 'James Legrand' LOWER CASE,
            FLTDATE TYPE D DEFAULT '20140319',
            DESTFROM(3)   TYPE C DEFAULT 'SFO',
            DESTTO(3)  TYPE C DEFAULT 'FRA',
            PASSFORM(15) TYPE C LOWER CASE,
            PASSNAME(25) TYPE C LOWER CASE,
            PASSBIRT TYPE D.

RFCDEST = 'JCOSERVER01'.

CALL FUNCTION 'BOOK_FLIGHT'
  DESTINATION RFCDEST
  EXPORTING
    CUSTNAME = CUSTNAME
    PASSFORM = PASSFORM
    PASSNAME = PASSNAME
    PASSBIRTH = PASSBIRT
    FLIGHTDATE = FLTDATE
    TRAVELAGENCYNUMBER = AGENCYNM
    DESTINATION_FROM = DESTFROM
    DESTINATION_TO = DESTTO
  IMPORTING
    TRIPNUMBER = TRIPNUMBER
    TICKET_PRICE = TICKET_PRICE
    TICKET_TAX = TICKET_TAX
    CURRENCY = CURRENCY
    PASSFORM = PASSFORM
    PASSNAME = PASSNAME
    PASSBIRTH = PASSBIRT
    FLTINFO = FLTINFO
    CONNINFO = INT_CONNECTION_INFO.

IF SY-SUBRC NE 0.

WRITE: / 'Call ZBOOK_FLIGHT SY-SUBRC = ', SY-SUBRC.
WRITE: / RFC_MESS.

ELSE.

WRITE: / 'Passenger: ', PASSFORM RIGHT-JUSTIFIED, ' ', PASSNAME LEFT-JUSTIFIED.

ULINE.

WRITE:
       / 'Trip Number:  ', TRIPNUMBER LEFT-JUSTIFIED,
       / 'Ticket Price: ', TICKET_PRICE DECIMALS 2 LEFT-JUSTIFIED,
       / 'Ticket Tax: ', TICKET_TAX DECIMALS 2 LEFT-JUSTIFIED,
       / 'Currency: ', CURRENCY LEFT-JUSTIFIED.

ULINE.

WRITE: / 'Flight Information',
       /5 'Flight Time', 25 'Departure City', 55 'Departure Date', 75 'Departure Time', 95 'Arrival City', 125 'Arrival Date', 145 'Arrival Time',
       /5(10) FLTINFO-FLIGHTTIME, 25(20) FLTINFO-CITYFROM, 55(10) FLTINFO-DEPDATE, 75(10) FLTINFO-DEPTIME, 95(20) FLTINFO-CITYTO, 125(10) FLTINFO-ARRDATE, 145(10) FLTINFO-ARRTIME.

ULINE.
WRITE: / 'Flight Connections'.

WRITE: /5 'Connection ID', 20 'Airline', 40 'Plane Type', 60 'Departure City', 90 'Departure Date', 110 'Departure Time', 130 'Arrival City', 160 'Arrival Date', 180 'Arrival Time'.

LOOP AT INT_CONNECTION_INFO INTO CONNECTION_INFO.

WRITE: /5 CONNECTION_INFO-CONNID, 20 CONNECTION_INFO-AIRLINE, 40 CONNECTION_INFO-PLANETYPE, 60 CONNECTION_INFO-CITYFROM, 90 CONNECTION_INFO-DEPDATE, 110 CONNECTION_INFO-DEPTIME, 130 CONNECTION_INFO-CITYTO,
          160 CONNECTION_INFO-ARRDATE, 180 CONNECTION_INFO-ARRTIME.

ENDLOOP.

ENDIF.
