基于gateway实现odata(8)–调用RFC函数的ODATA

今天看到Generation via RFC/BOR Interface,我的理解就是调用RFC函数生成ODATA的Entity ,并用此RFC对数据的查询处理,

ODATA学习(SAP Press – OData and SAP NetWeaver Gateway)第7.1章节,第333页

we introduced the process of data model definition by
importing the OData model from an RFC/BOR interface. This approach
is commonly used because most SAP NetWeaver Gateway OData services
are based on remote function modules. In this section, we’ll show
you how to implement the service by simply mapping the interfaces of
the RFC function modules to the operations of the OData service (as
opposed to the code-based approach taken in Chapter 6).
You’ll start the service generation process by creating a new project,
ZRFC1, in the Service Builder and defining a data model (Section 7.1.1).
The model will consist of two entity types: Sa 1 esOrderHeader and Sa 1 e sOrder
Line Item. Both entity type definitions will be imported from the
corresponding sample function modules that are part of the SAP Enterprise
Procurement Model (EPM). EPM is a test application that serves as a
proxy for SAP’s real-world SAP Business Suite applications.

没完成理解文中的意思,所以只能使用文中的例子一步步的试一下。

我自己建立了一个RFC 函数,函数的功能是,传入一些参数,然后按参数出自定义表的数据,比如传入,销售单号,创建人,销售人,出货仓库等。——————————————————————————————————————————————————————————————–

一、新建RCF函数:ZFRC_READ_SALE,注意,这里必需要建立的是Remote-Enabled Module,的函数.代码如下:

二、引用RFC函数生成Entity,            在Data Model 上点右键,Import->RCF/BOR Interface,创建名称ZFRC_READ_SALE,其中的Data Source Attributes需要设成为TYPE:Remote Function Call ,Name:ZFRC_READ_SALE(前一步创建的RFC),在下一步Create Entity TYPE中,我只选择了IT_DATA及IT_DATA_I,再后在还要设置KEY,这也是需要的,最后生成对你;

三、这时候,如使用地址:http://bwnep:8917/sap/opu/odata/sap/ZSALE_SRV/?$format=xml打开,会发现多了上一步选择的两个Entity了,但如使用地址:http://bwnep:8917/sap/opu/odata/sap/ZSALE_SRV/ItDataSet还是没的数据返回,并报错,可以在RCF函数ZFRC_READ_SALE设置断点,发现此时并没有运行RFC函数;

四、MAP TO DATA SOURCE,此步骤把Entity set的输出MAPING到RFC函数上,这样在显示ODATA的Entity时就会调用对应的RFC函数了。
         在 Service Implementation下面选择需要MAPING的Entity set,在此SET 下面的GetEntitySet(Query)上点击右键,选择“MAP TO DATA SOURCE”,其中的Data Source Attributes需要设成为TYPE:Remote Function Call ,Name:ZFRC_READ_SALE,点击完成后,在此下面就会多出一个MAPING了,在此例子中我选择在ItDataSet下面创建MAPING.
最后在打开生成的MAPING,点击工具栏上的“Propose Mapping”.

五、最后保存,并生成此项目。
我们使用地址http://bwnep:8917/sap/opu/odata/sap/ZSALE_SRV/ItDataSet,发现没报错了,DEBUG调试也已时了自己的RFC函数,可没有数据返回,折腾人啊,搞了好久也没找到问题,
最后我使用标准的BAPI_EPM_SO_GET_LIST函数如此操作又能生成正常的ODATA,并查询出数据来,
所以可能是自己的FRC那里还有问题,再得再查找一下。

留下一个回复

你的email不会被公开。