Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CLASS zbc_currency_conversion_hana DEFINITION
- PUBLIC
- FINAL
- CREATE PUBLIC .
- PUBLIC SECTION.
- types: BEGIN OF ls_vbak,
- so_id type snwd_so-so_id,
- net_amount type snwd_so-net_amount,
- currency_code type snwd_so-currency_code,
- end of ls_vbak.
- data: lt_vbak type STANDARD TABLE OF ls_vbak.
- data: wa_vbak like line of lt_vbak.
- "Specify the interface that it is a HANA connection class
- INTERFACEs if_amdp_marker_hdb.
- types: lt_amount type standard TABLE OF ZCURR_CONV_HANA.
- METHODS convert_currency_snwd
- IMPORTING
- value(it_conv_prices) like lt_vbak
- value(iv_mandt) type mandt
- value(iv_target_unit) type waerk
- value(iv_ref_date) type char10
- EXPORTING
- value(et_amount) type lt_amount.
- METHODS convert_currency
- IMPORTING
- value(it_conv_prices) type lt_amount
- value(iv_mandt) type mandt
- EXPORTING
- value(et_amount) type lt_amount.
- PROTECTED SECTION.
- PRIVATE SECTION.
- ENDCLASS.
- CLASS ZBC_CURRENCY_CONVERSION_HANA IMPLEMENTATION.
- METHOD convert_currency BY DATABASE PROCEDURE FOR HDB
- LANGUAGE SQLSCRIPT.
- *BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT needs to be typed in to specify that we are using AMDP procedures
- *Start creating the input table for the procedure CE_CONVERSION
- PRICES = select id as id, in_amount as in_amount, source_unit as source_unit, target_unit as target_unit, ref_date as ref_date from :it_conv_prices;
- *Here we call the CE_CONVERSION method and specifying that the result should be stored in the variable lt_uom_std_conv
- lt_uom_std_conv = CE_CONVERSION(:PRICES, [family = 'currency',
- method = 'ERP',
- client = :iv_mandt,
- conversion_type = 'M',
- steps = 'shift,convert,shift_back',
- target_unit_column = target_unit,
- source_unit_column = source_unit,
- reference_date_column = ref_date],
- [ in_amount AS out_amount ] );
- *The select statement for the output table is an inner join using id.
- et_amount =
- select
- lt.id as id,
- dm.in_amount as in_amount,
- lt.out_amount as out_amount,
- dm.source_unit as source_unit,
- dm.target_unit as target_unit,
- dm.ref_date as ref_date
- from :lt_uom_std_conv as lt
- inner join :prices as dm on dm.id=lt.id;
- ENDMETHOD.
- METHOD convert_currency_snwd BY DATABASE PROCEDURE FOR HDB
- LANGUAGE SQLSCRIPT using snwd_so.
- *BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT needs to be typed in to specify that we are using AMDP procedures
- *Start creating the input table for the procedure CE_CONVERSION
- PRICES = select so_id as so_id, net_amount as in_amount, currency_code as source_unit from snwd_so;
- *Here we call the CE_CONVERSION method and specifying that the result should be stored in the variable lt_uom_std_conv
- lt_uom_std_conv = CE_CONVERSION(:PRICES, [family = 'currency',
- method = 'ERP',
- client = :iv_mandt,
- conversion_type = 'M',
- steps = 'shift,convert,shift_back',
- target_unit = :iv_target_unit,
- source_unit_column = source_unit,
- reference_date = :iv_ref_date],
- [ in_amount AS out_amount ] );
- *The select statement for the output table is an inner join using id.
- et_amount =
- select
- lt.so_id as id,
- dm.in_amount as in_amount,
- lt.out_amount as out_amount,
- dm.source_unit as source_unit,
- :iv_target_unit as target_unit,
- :iv_ref_date as ref_date
- from :lt_uom_std_conv as lt
- inner join :prices as dm on dm.so_id=lt.so_id;
- ENDMETHOD.
- ENDCLASS.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement