FUNCTION z_bapi_create_booking.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(FLUG) TYPE  ZFLUG
*"     VALUE(CUSTOMID) TYPE  SCUSTOM-ID
*"  EXPORTING
*"     VALUE(BOOKID) TYPE  S_BOOK_ID
*"  TABLES
*"      RETURN STRUCTURE  BAPIRET2 OPTIONAL
*"----------------------------------------------------------------------

  DATA:
    book_wa LIKE bapisbonew,
    airlineid TYPE bapisbokey-airlineid,
    bookingnumber TYPE bapisbokey-bookingid.
* globale Daten in wa für BAPI transportieren
  book_wa-airlineid  = flug-carrid.
  book_wa-connectid  = flug-connid.
  book_wa-flightdate = flug-fldate.
  book_wa-customerid = customid.

*  book_wa-class      = scustom-class.
* Je nach aktuellen Datenwerten: counter oder agencynum nehmen!
  book_wa-counter    = 1. "scustom-counter.
*  book_wa-agencynum  = 1." scustom-agencynum.
*  book_wa-passname   = scustom-passname.
*  book_wa-passbirth  = scustom-passbirth.
*  book_wa-passform   = scustom-passform.

  CALL FUNCTION 'BAPI_FLBOOKING_CREATEFROMDATA'
    EXPORTING
      booking_data        = book_wa
    IMPORTING
      airlineid           = airlineid
      bookingnumber       = bookingnumber
*   TICKET_PRICE        =
    TABLES
      return              = return.

  bookid = bookingnumber.

ENDFUNCTION.