打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
一个使用CDS VIEW 的 DEMO
REPORT demo_cds_currency_conversion.


CLASS demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS main.
  PRIVATE SECTION.
    CLASS-METHODS setup.
ENDCLASS.


CLASS demo IMPLEMENTATION.
  METHOD main.
    DATA(out) = cl_demo_output=>new( ).


    DATA currency TYPE c LENGTH 5 VALUE 'USD'.
    cl_demo_input=>request( CHANGING field = currency ).
    currency = to_upper( currency ).
    setup( ).


    SELECT *
           FROM demo_prices
           ORDER BY id
           INTO TABLE @DATA(original_prices).


    out->begin_section( `Original Prices`
      )->write( original_prices
      )->next_section( `Converted Prices` ).


    IF cl_abap_dbfeatures=>use_features(
      EXPORTING
        requested_features =
          VALUE #( ( cl_abap_dbfeatures=>views_with_parameters ) ) ).
      TRY.
          SELECT *
                 FROM demo_cds_currency_conversion(
                        to_currency = @currency, exc_date = @sy-datlo )
                 ORDER BY id
                 INTO TABLE @DATA(converted_prices)
                 ##db_feature_mode[views_with_parameters].
          out->write( converted_prices ).
        CATCH cx_sy_open_sql_db INTO DATA(exc).
          out->write( exc->get_text( ) ).
      ENDTRY.
    ELSE.
      out->write(
            'Database system does not support views with parameters' ).
    ENDIF.


    out->display( ).
  ENDMETHOD.
  METHOD setup.
    DATA prices TYPE SORTED TABLE OF demo_prices
                WITH UNIQUE KEY id.
    prices = VALUE #(
      ( id = 1 amount = '1.00' currency = 'EUR' )
      ( id = 2 amount = '1.00' currency = 'GBP' )
      ( id = 3 amount = '1.00' currency = 'JPY' )
      ( id = 4 amount = '1.00' currency = 'USD' ) ).


    DELETE FROM demo_prices.
    INSERT demo_prices FROM TABLE prices.
  ENDMETHOD.
ENDCLASS.


START-OF-SELECTION.

  demo=>main( ).



本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
色谱积分原理和手动积分的规则
SAP CDS view自学教程之三:ABAP Development Tool里的CDS view源代码如何传递到ABAP后台
让回调函数 showResponse 也带上参数
ABAP Open SQL 分页查询
SMARTY模板的AJAX插件扩展
object c 学习笔记,函数写法研究
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服