SAP SQL/CDS新功能货币汇率转换CURRENCY_CONVERSION( p1 = a1, p2 = a2, … )

1. 示例

PARAMETERS: p_waers  TYPE mseg-waers OBLIGATORY DEFAULT 'USD'.

SELECT SUM( currency_conversion( amount = a~hsl,    "转换的金额
            source_currency = b~isocd,              "源货币
            target_currency = @p_waers,             "目标货币
            exchange_rate_date = @sy-datum,         "汇率日期
            exchange_rate_type = 'M',               "汇率类型
            round = @abap_true,                     "是否Round
            on_error = @sql_currency_conversion=>c_on_error-fail ) ) AS amount_total
  FROM acdoca AS a
  LEFT JOIN tcurc AS b ON a~rhcur = b~waers
    WHERE a~rhcur = 'RMB'
    INTO TABLE @DATA(lt_data)
    UP TO 100 ROWS.

cl_demo_output=>display( lt_data ).

2. 效果

  • 转换为 USD
    SAP SQL/CDS新功能货币汇率转换CURRENCY_CONVERSION( p1 = a1, p2 = a2, … )_第1张图片
  • 转换为JPY
    SAP SQL/CDS新功能货币汇率转换CURRENCY_CONVERSION( p1 = a1, p2 = a2, … )_第2张图片

你可能感兴趣的:(ABAP开发,sql,前端,linux)