1 在ECPLISE中创建CDSVIEW:
CDS--->Data definition
@AbapCatalog.sqlViewName: 'YDEMO_CDS_V01S'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'DEMO ODATA ENH'
define view YDEMO_CDS_V01
as select from spfli
association [0..1] to scarr as B
on B.carrid = spfli.carrid {
key spfli.carrid,
key B.carrname,
key spfli.connid,
spfli.cityfrom,
spfli.cityto
}
@AbapCatalog.sqlViewName: 'YDEMO_CDS_V02S'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'DEMO ODATA ENH'
define view YDEMO_CDS_V02
as select from spfli
inner join scarr as B
on B.carrid = spfli.carrid {
key spfli.carrid,
key B.carrname,
key spfli.connid,
spfli.cityfrom,
spfli.cityto
}
激活,上面两个方式创建的CDS VIEW在SE11中是一样的,结果不一样
2: 进SAP ,SEGW,创建项目并 Reference --->Data Source
3: Gerenate runtime object
4: : register and test
5: copy YDEMO_CDS_V01_GET_ENTITYSET 的代码,然后Redine这个方法,并把刚才的代码黏贴到refine后的方法中,
if_sadl_gw_dpc_util~get_dpc( )->get_entityset( EXPORTING io_tech_request_context = io_tech_request_context
IMPORTING et_data = et_entityset
es_response_context = es_response_context ).
METHOD ydemo_cds_v01_get_entityset.
if_sadl_gw_dpc_util~get_dpc( )->get_entityset( EXPORTING io_tech_request_context = io_tech_request_context
IMPORTING et_data = et_entityset
es_response_context = es_response_context ).
* 在这里你可以增加新地逻辑
LOOP AT et_entityset ASSIGNING FIELD-SYMBOL(<fs>).
<fs>-cityto = 'TEST CITY TO'.
ENDLOOP.
ENDMETHOD.