Untitled
unknown
plain_text
2 years ago
3.5 kB
4
Indexable
CLASS zamdp_class DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES: if_amdp_marker_hdb, if_oo_adt_classrun. TYPES: BEGIN OF ty_result_line, airline TYPE /dmo/carrier_name, flight_connection TYPE /dmo/connection_id, old_price TYPE /dmo/flight_price, old_currency TYPE /dmo/currency_code, new_price TYPE /dmo/flight_price, new_currency TYPE /dmo/currency_code, END OF ty_result_line, BEGIN OF ty_flights_line, airline TYPE /dmo/carrier_name, flight_connection TYPE /dmo/connection_id, price TYPE /dmo/flight_price, currency TYPE /dmo/currency_code, END OF ty_flights_line, begin of ty_mara_line, matnr type matnr, maktx type maktx, end of TY_MARA_LINE, ty_result_table TYPE STANDARD TABLE OF ty_result_line WITH EMPTY KEY, ty_flights_table TYPE STANDARD TABLE OF ty_flights_line WITH EMPTY KEY, ty_flights TYPE STANDARD TABLE OF /dmo/flight, ty_mara_table type STANDARD TABLE OF ty_mara_line. METHODS: get_flights EXPORTING VALUE(result) TYPE ty_result_table RAISING cx_amdp_execution_error, convert_currency IMPORTING VALUE(flights) TYPE ty_flights_table EXPORTING VALUE(result) TYPE ty_result_table RAISING cx_amdp_execution_error, get_mara EXPORTING value(result) type ty_mara_table raising cx_amdp_execution_error. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. CLASS zamdp_class IMPLEMENTATION. METHOD convert_currency BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY. declare today date; declare new_currency nvarchar(3); select current_date into today from dummy; new_currency := 'EUR'; result = select distinct airline, flight_connection, price as old_price, currency as old_currency, convert_currency( "AMOUNT" => price, "SOURCE_UNIT" => currency, "TARGET_UNIT" => :new_currency, "REFERENCE_DATE" => :today, "CLIENT" => '100', "ERROR_HANDLING" => 'set to null', "SCHEMA" => current_schema ) as new_price, :new_currency as new_currency from :flights; ENDMETHOD. METHOD get_flights BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING /dmo/flight /dmo/carrier zamdp_class=>convert_currency. flights = select distinct c.name as airline, f.connection_id as flight_connection, f.price as price, f.currency_code as currency from "/DMO/FLIGHT" as f inner join "/DMO/CARRIER" as c on f.carrier_id = c.carrier_id; call "ZAMDP_CLASS=>CONVERT_CURRENCY"( :flights, result ); ENDMETHOD. METHOD if_oo_adt_classrun~main. TRY. get_flights( IMPORTING result = DATA(lt_result) ). CATCH cx_amdp_execution_error INTO DATA(lx_amdp). out->write( lx_amdp->get_longtext( ) ). ENDTRY. out->write( lt_result ). ENDMETHOD. METHOD get_mara BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING mara makt. result = SELECT top 100 mara.matnr, makt.maktx from "MARA" as mara inner join makt as makt on makt.matnr = mara.matnr where makt.spras = 'D'; ENDMETHOD. ENDCLASS.
Editor is loading...