本文主要是介绍Odata 的Association实现 get update delete URL,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
odata GET,UPDATA,DELETE - Park_SAP - 博客园
1:创建表:YEKKO,YEKPO
2: 导入,YEKKO,YEKPO生成EKKO,EKPO entity type, (Import->DDIC Structure)
3:按提示生成association,如下,
4:执行Runtime Artifactsz生成相关类,
5:实施刚生成的类的方法,
分别redefine ekkoset: getentity, getentityset
Ekposet:getentityset.
METHOD ekkoset_get_entity.
DATA: ls_key TYPE /iwbep/s_mgw_tech_pair,
lt_keys TYPE /iwbep/t_mgw_tech_pairs.
lt_keys = io_tech_request_context->get_keys( ). "注意大小写
READ TABLE lt_keys WITH KEY name = 'EBELN' INTO ls_key.
CHECK sy-subrc = 0.
SELECT SINGLE *
FROM yekko
INTO CORRESPONDING FIELDS OF er_entity
WHERE ebeln = ls_key-value.
ENDMETHOD.
METHOD ekkoset_get_entityset.
DATA:lv_ebeln TYPE yekko-ebeln.
DATA:lt_ekko TYPE TABLE OF yekko.
DATA:ls_filter_pernr TYPE /iwbep/s_mgw_select_option,
ls_option TYPE /iwbep/s_cod_select_option,
ls_ee_option TYPE bapihrselemployee.
LOOP AT it_filter_select_options INTO ls_filter_pernr WHERE property = 'Ebeln'.
LOOP AT ls_filter_pernr-select_options INTO ls_option.
CLEAR ls_ee_option.
lv_ebeln = ls_option-low.
ENDLOOP.
ENDLOOP.
SELECT *
FROM yekko
UP TO 10 ROWS
INTO TABLE lt_ekko
WHERE ebeln = lv_ebeln.
MOVE-CORRESPONDING lt_ekko TO et_entityset.
ENDMETHOD.
METHOD ekposet_get_entityset.
DATA: ls_key TYPE /iwbep/s_mgw_name_value_pair.
DATA:lv_ebeln TYPE ekko-ebeln.
READ TABLE it_key_tab WITH KEY name = 'Ebeln' INTO ls_key.
“it_key_tab KEY的信息是entity type的字段定义,区分大小写
“lt_keys = io_tech_request_context->get_keys( )
” LT_KEYS是SAP表的字段,为大写
CHECK sy-subrc = 0.
lv_ebeln = ls_key-value.
SELECT *
FROM yekpo
INTO CORRESPONDING FIELDS OF TABLE et_entityset
WHERE ebeln = lv_ebeln.
ENDMETHOD.
6:注册并测试。
测试时注意:
/sap/opu/odata/SAP/YPRJ_ASS_01_SRV/EKKOSet(Mandt='200',Ebeln='4500000000')/?$expand=EKPOSet
EKKOSet和EKKOSet内容都显示,会先执行EKKOSet的entity 再执行EKPOSet的ENTITYset
/sap/opu/odata/SAP/YPRJ_ASS_01_SRV/EKKOSet(Mandt='200',Ebeln='4500000000')/EKPOSet
只执行 EKPOSet的ENTITYset,但会加上Mandt='200',Ebeln='4500000000'条件,相当于有条件查询
/sap/opu/odata/SAP/YPRJ_F4_01_SRV/ET_T001Set(Mandt='200',Bukrs='0001')
这篇关于Odata 的Association实现 get update delete URL的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!