一个使用CDS VIEW 的 DEMO

一个使用CDS VIEW 的demo

 1 REPORT demo_cds_currency_conversion.
 2 
 3 CLASS demo DEFINITION.
 4   PUBLIC SECTION.
 5     CLASS-METHODS main.
 6   PRIVATE SECTION.
 7     CLASS-METHODS setup.
 8 ENDCLASS.
 9 
10 CLASS demo IMPLEMENTATION.
11   METHOD main.
12     DATA(out) = cl_demo_output=>new( ).
13 
14     DATA currency TYPE c LENGTH 5 VALUE 'USD'.
15     cl_demo_input=>request( CHANGING field = currency ).
16     currency = to_upper( currency ).
17     setup( ).
18 
19     SELECT *
20            FROM demo_prices
21            ORDER BY id
22            INTO TABLE @DATA(original_prices).
23 
24     out->begin_section( `Original Prices`
25       )->write( original_prices
26       )->next_section( `Converted Prices` ).
27 
28     IF cl_abap_dbfeatures=>use_features(
29       EXPORTING
30         requested_features =
31           VALUE #( ( cl_abap_dbfeatures=>views_with_parameters ) ) ).
32       TRY.
33           SELECT *
34                  FROM demo_cds_currency_conversion(
35                         to_currency = @currency, exc_date = @sy-datlo )
36                  ORDER BY id
37                  INTO TABLE @DATA(converted_prices)
38                  ##db_feature_mode[views_with_parameters].
39           out->write( converted_prices ).
40         CATCH cx_sy_open_sql_db INTO DATA(exc).
41           out->write( exc->get_text( ) ).
42       ENDTRY.
43     ELSE.
44       out->write(
45             'Database system does not support views with parameters' ).
46     ENDIF.
47 
48     out->display( ).
49   ENDMETHOD.
50   METHOD setup.
51     DATA prices TYPE SORTED TABLE OF demo_prices
52                 WITH UNIQUE KEY id.
53     prices = VALUE #(
54       ( id = 1 amount = '1.00' currency = 'EUR' )
55       ( id = 2 amount = '1.00' currency = 'GBP' )
56       ( id = 3 amount = '1.00' currency = 'JPY' )
57       ( id = 4 amount = '1.00' currency = 'USD' ) ).
58 
59     DELETE FROM demo_prices.
60     INSERT demo_prices FROM TABLE prices.
61   ENDMETHOD.
62 ENDCLASS.
63 
64 START-OF-SELECTION.
65   demo=>main( ).

 

----------------凑字数-------------------------

励志美文、《抉择》
  
人的一生常处于抉择之中,如:念哪一间大学?选哪一种职业?娶哪一种女子?……等等伤脑筋的事情。一个人抉择力的有无,可以显示其人格成熟与否。
  
倒是哪些胸无主见的人,不受抉择之苦。因为逢到需要决定的时候,他总是求询别人说:"嘿,你看怎么做?"
  
大凡能够成大功业的人,都是抉择力甚强的人。他知道事之成败,全在乎已没有人可以代劳,更没有人能代你决定。
  
在抉择的哪一刻,成败实已露出端倪。
原文地址:https://www.cnblogs.com/mingdashu/p/5802128.html