基于gateway实现odata(9)–Create Methods

在之前是按SAP Press – OData and SAP NetWeaver Gateway.pdf学习来操作的,前几天才知道使用的这个文件是老版本的,现已有了新版本的,所以找到了此文件的新版本SAP_Press_-_SAP_Gateway_and_OData_(2ed)2016.pdf,这之后都新此版本来学习操作。———————————————————————————————————————————————————————-
前面几节已学习以下几种取数据方法:
1.重定义GET_ENTITYSET,GET_ENTITY的方法来读取数据,
2.重定义/IWBEP/IF_MGW_APPL_SRV_RUNTIME~EXECUTE_ACTION
3.RCF/BOR Interface的MAPPING到RFC的方法取数据。
———————————————————————————————————————————————————————-
以下开始学习ODATA的Create, Update, and Delete Methods

ODATA学习(SAP_Press_-_SAP_Gateway_and_OData_(2ed)2016.pdf)第6.5.5章节,第299页

CREATE is used whenever you want to create a new entry into the respective
collection. The CREATE operation for the product entity type is handled
by the PRODUCTSET_CREATE_ENTITY method in the DPC.
Similar to the read methods, you need to redefine this method in the
data provider extension class. As an example, use the coding in Usting
6.10.

一、确保前面的几节学习已完成,至少*_DPC_EXT的类已生成,(在此使用前面定义的ZSALE项目的ZCL_ZSALE_DPC_EXT类)
二、重定义ZTSALE_HSET_CREATE_ENTITY方法。

三、对ODATA进行测试,测试时,先用地址/sap/opu/odata/sap/ZSALE_SRV/ZTSALE_H(Gjahr=’2016′,Zsaleid=’1001′)取出一行数据做为模板,然后COPY到左边的传入数据框中,并进行修改,最后执行,如成功就会把数据存调用ZTSALE_HSET_CREATE_ENTITY方法,图中是运行第二次时,由于数据重复,所以就报错了。

基于gateway实现odata(9)--Create Methods - 第1张  | 优通SAP

测试时需要注意把Entity set的CREATEABLE设置成可全能。不然不会进行此方法处理。

 

留下一个回复

你的email不会被公开。