cancel
Showing results for 
Search instead for 
Did you mean: 

CE_CONVERSION in ABAP AMDP method

Former Member
0 Kudos

Hi,

I'm trying to get some knowledge about the usage of the AMDP procedures in the business suite on HANA. I've been trying to create a simple example where i convert a currency from one to another using and AMDP procedure and the CE_CONVERSION.

However i gives me an SQL script error and i can't figure out why.

My source code can be found here: abap_source_code - Pastebin.com

I hope someone can give me a hand

Message was edited by: Tom Flanagan

Accepted Solutions (1)

Accepted Solutions (1)

sagarjoshi
Advisor
Advisor
0 Kudos

In your code you did not assign output of CE_CONVERSION to any temp table.

Here is a code snippet that you can use in your method body.

    PRICES = select 'AA' as id, '100' as in_amount from dummy;

    lt_uom_std_conv = CE_CONVERSION (

      :PRICES,

      [ family             = 'currency',

        method             = 'ERP',

        steps              = 'shift,convert,shift_back',

        target_unit        = 'EUR',

        client             = '800',

        source_unit        = 'USD',

        reference_date     = '01.07.2014',

        error_handling     = 'keep unconverted' ],

      [ in_amount AS out_amount ] );

   et_amount = select out_amount as BAPICURR from :lt_uom_std_conv;

Former Member
0 Kudos

Then i get the following error

SQLScript: Attribute not found in column table: DEMO_PRICES

  prices= CE_CONVERSION(:demo_prices, [family = 'currency',
  method = 'ERP',
  client = '900',
  conversion_type = 'M',
  target_unit = 'EUR',
  source_unit = 'DKK',
  reference_date = "01.07.2014",
  output_unit_column = "BAPICURR"],
  

[ demo_prices AS out_amount ] );

I have also tried the following, but then i get the error: sap column name BAPICURR defined multiple times in output table

  et_amount = CE_CONVERSION(:demo_prices, [family = 'currency',
  method = 'ERP',
  client = '900',
  conversion_type = 'M',
  target_unit = 'EUR',
  source_unit = 'DKK',
  reference_date = "01.07.2014",
  output_unit_column = "BAPICURR"]);
 
sagarjoshi
Advisor
Advisor
0 Kudos

You should not use OUTPUT_UNIT_COLUMN = "BAPICURR" in this if you are hardcoding units otherwise you need to

check what are the columns of conversion units in your table demo_prices;

Here is a example where conversion units are specified

PRICES = select 'AA' as id, '100' as in_amount, 'EUR' as IN_UNIT,'USD' as OUT_UNIT from dummy;

    lt_uom_std_conv = CE_CONVERSION (

      :PRICES,

      [ family             = 'currency',

        method             = 'ERP',

        steps              = 'shift,convert,shift_back',

        client             = '800',

        source_unit_column = 'IN_UNIT',

        target_unit_column        = 'OUT_UNIT',

        reference_date     = '01.07.2014',

        error_handling     = 'keep unconverted' ],

      [ in_amount AS out_amount ] );

   et_amount = select out_amount as BAPICURR from :lt_uom_std_conv;

Former Member
0 Kudos

Hi Sagar,

Thanks so much for your help, i'm have gotten it to work, however i would like to use this method a bit more strategically.

I have an input table with the values

in_amount

out_amount

source_unit

target_unit

ref_date

i use these in my conversion function, however i can't seem to get the data into the out_amount column.

I have tried different methods such as specifying the input as an output as well. as i found in this documentation

CE_CONVERSION - SAP HANA SQLScript Reference - SAP Library

However it still isn't working, can you see what i am missing?

This is the source code for the method.

    PRICES = select id as id, in_amount as in_amount, out_amount as out_amount, source_unit as source_unit, target_unit as target_unit, ref_date as ref_date from :demo_prices;

    et_amount = select * from :demo_prices;

      lt_uom_std_conv  = CE_CONVERSION(:PRICES, [family = 'currency',

      method = 'ERP',

      client = '900',

      conversion_type = 'M',

      steps              = 'shift,convert,shift_back',

      target_unit_column = target_unit,

      source_unit_column = source_unit,

      reference_date_column = ref_date,

      output = 'input,passed_through' ],

      [in_amount as out_amount]);

        et_amount = select id as id, in_amount as in_amount, out_amount as out_amount, source_unit as source_unit, target_unit as target_unit, ref_Date as ref_date from :lt_uom_std_conv;

Former Member
0 Kudos

Ok so i managed to get the wanted output with the following source code

*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 = '900',

      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 :it_conv_prices as dm on dm.id=lt.id;

Answers (0)