基于gateway实现odata(2)—-第一个简单的ODATA实现

在ECC的netweaver gateway基础配置激活完成后,就可以使用SEGW事务码来创建ODATA了,

As  you’ve  learned from the previous chapters, each OData service  con –
sists  of  a  data  model definition and a service implementation. At  runt –
ime, the model definiti on  results in  the  service  document  and  the  ser –
vice metadata document,  and  the service implementation results  in  th e
actual functionality  of  the  SAP  NetWeaver Gateway service. For  an  SAP
NetWeaver Gateway OData service using the OData channel develop-
ment  paradigm, the model definition  is  provided via the model  provider
class (MPC). The service implementation  is  provided via the data  pro-
vi der  class (DPC). The  too l that performs  both  of  these tasks is the  SAP
NetWeaver Gateway Service Builder.

一、输入事务码SEGW,并点击新建,创建一个ODATA项目,如图输入ZFIORI,为项目名。

基于gateway实现odata(2)----第一个简单的ODATA实现 - 第1张  | 优通SAP

二、如图,右键点击选择“DDIC Structure”就可以用ECC的一个已有的结构来创建一个ODATA的Data Model.

基于gateway实现odata(2)----第一个简单的ODATA实现 - 第2张  | 优通SAP

三、选择一个表名来如图,创建完成,如图中使用SAP的用户表来生成,并生成如图

基于gateway实现odata(2)----第一个简单的ODATA实现 - 第3张  | 优通SAP

基于gateway实现odata(2)----第一个简单的ODATA实现 - 第4张  | 优通SAP

基于gateway实现odata(2)----第一个简单的ODATA实现 - 第5张  | 优通SAP

基于gateway实现odata(2)----第一个简单的ODATA实现 - 第6张  | 优通SAP

四、如图选中项目,并生成ODATA的代理类。

基于gateway实现odata(2)----第一个简单的ODATA实现 - 第7张  | 优通SAP

五、在类中写入代码,查询出为ODATA提供的数据了,在这里一定是对*GET_ENTITYSET的方法进行重实现,不能是直接双击打开,

基于gateway实现odata(2)----第一个简单的ODATA实现 - 第8张  | 优通SAP

基于gateway实现odata(2)----第一个简单的ODATA实现 - 第9张  | 优通SAP

实现的代码如下:

六、把SEGW项目加入到服务中,以便用外使用,使用事务码/IWFND/MAINT_SERVICE打开,有的系统使用此事务码会报错,此时要吧使用SE93输入此事务码然后再运行,就可以了。

/IWFND/MAINT_SERVICE创建服务并测试,请看一节。

留下一个回复

你的email不会被公开。