前面在SEGW中完成了Model的创建工作,接下来我们需要开始写代码,前面说过,在激活Model的时候产生了4个类,MPC两个(Model Provider
),DPC两个(Data Provider
),在实际开发中,主要基于DPC_EXT
进行程序的开发。
GET_ENTITY
以及GET_ENTITYSET
。GET_ENTITYSET
:取得符合筛选条件的多条记录。GET_ENTITY
: 取得根据Key值返回的单条记录。重定义PLANTSET_GET_ENTITYSET
方法
method PLANTSET_GET_ENTITYSET.
SELECT * from t001w
into CORRESPONDING FIELDS OF TABLE et_entityset
UP TO 50 ROWS
where adrnr <> space.
endmethod.
method PLANTSET_GET_ENTITY.
DATA ls_converted_keys LIKE er_entity.
data lv_plant type werks_d.
io_tech_request_context->get_converted_keys(
IMPORTING
es_key_values = ls_converted_keys ).
lv_plant = ls_converted_keys-werks.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_plant
IMPORTING
output = lv_plant.
select single * from t001w into CORRESPONDING FIELDS OF ER_ENTITY
where werks = lv_plant.
endmethod.
method ADDRESSSET_GET_ENTITY.
data: lt_key_tab TYPE /iwbep/t_mgw_tech_pairs,
ls_keys LIKE LINE OF lt_key_tab.
data: lv_adrnr type AD_ADDRNUM,
lv_werks type werks_d.
CALL METHOD io_tech_request_context->get_source_keys
RECEIVING
rt_source_keys = lt_key_tab.
IF lt_key_tab IS INITIAL.
lt_key_tab = io_tech_request_context->get_source_keys( ).
ENDIF.
read table lt_key_tab INTO ls_keys index 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_keys-value
IMPORTING
output = lv_werks.
select single adrnr from t001w into lv_adrnr where werks = lv_werks.
select SINGLE * from adrc into CORRESPONDING FIELDS OF ER_ENTITY
where ADDRNUMBER = lv_adrnr.
endmethod.
method GEOCODESET_GET_ENTITY.
data: lt_key_tab TYPE /iwbep/t_mgw_tech_pairs,
ls_keys LIKE LINE OF lt_key_tab.
data: lv_adrnr type AD_ADDRNUM,
lv_werks type werks_d.
CALL METHOD io_tech_request_context->get_source_keys
RECEIVING
rt_source_keys = lt_key_tab.
.
IF lt_key_tab IS INITIAL.
lt_key_tab = io_tech_request_context->get_source_keys( ).
ENDIF.
read table lt_key_tab INTO ls_keys index 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_keys-value
IMPORTING
output = lv_werks.
select single adrnr from t001w into lv_adrnr where werks = lv_werks.
select SINGLE * from geoloc into CORRESPONDING FIELDS OF ER_ENTITY
where ADDRNUMBER = lv_adrnr.
endmethod.
接下来我们会介绍如何把已经开发的
odata service
注册到Gateway server
上面。