关于abap:abap-amdp的简单读与写入

49次阅读

共计 856 个字符,预计需要花费 3 分钟才能阅读完成。

CLASS zcl_flight_calc DEFINITION PUBLIC FINAL CREATE PUBLIC.
  PUBLIC SECTION.
* Marker interface with SAP HANA DB as database type
    INTERFACES: if_amdp_marker_hdb.
    METHODS: get_flight_detail
      IMPORTING VALUE(iv_carrid) TYPE sflight-carrid
      EXPORTING VALUE(et_flight) TYPE flighttab.

    METHODS: update_flight IMPORTING VALUE(iv_carrid) TYPE spfli-carrid
                                     VALUE(iv_occ)    TYPE sflight-seatsocc
                                     VALUE(iv_max)    TYPE sflight-seatsmax.
ENDCLASS.

CLASS zcl_flight_calc IMPLEMENTATION.
  METHOD get_flight_detail
                                 BY DATABASE PROCEDURE FOR HDB
                                 LANGUAGE SQLSCRIPT
                                 OPTIONS READ-ONLY
                                 USING sflight.
* Implementation of the procedure in a DB-specific language
    et_flight = SELECT * FROM sflight WHERE mandt = SESSION_CONtext ('CLIENT')
                                          and carrid = iv_carrid;
  ENDMETHOD.

  METHOD update_flight BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT USING
                                    sflight.
    update sflight set seatsocc = iv_occ,
                       seatsmax = iv_max
    where mandt = SESSION_context ('CLIENT')
      and carrid = iv_carrid;
  ENDMETHOD.
ENDCLASS.

正文完
 0