调用 RFC_READ_TABLE 时出现 DATA_BUFFER_EXCEEDED 错误?

发布于 2024-10-02 11:54:53 字数 431 浏览 3 评论 0 原文

我的 java/groovy 程序从用户输入接收表名和表字段,它查询 SAP 中的表并返回其内容。

用户输入可能涉及表CDPOSCDHDR。在阅读 SAP 文档和谷歌搜索后,我发现这些是存储更改文档日志的表。但我没有找到任何可以在java中使用远程调用函数来执行此类查询。

然后我使用了已弃用的 RFC 功能模块 RFC_READ_TABLE 并尝试仅根据此 RFC 构建自定义查询。但是,我发现如果传递给此 RFC 的所需字段数量超过 2,即使我限制了最大行数,我也总是会收到 DATA_BUFFER_EXCEEDED 错误。

我没有被授权成为SAP系统中的ABAP开发人员,无法在现有系统中添加任何FM,所以我只能用JAVA编写代码来完成这个需求。

我做错了什么吗?你能给我一些关于这个问题的提示吗?

My java/groovy program receives table names and table fields from the user input, it queries the tables in SAP and returns its contents.

The user input may concern the tables CDPOS and CDHDR. After reading the SAP documentations and googling, I found these are tables storing change document logs. But I did not find any remote call functions that can be used in java to perform this kind of queries.

Then I used the deprecated RFC Function Module RFC_READ_TABLE and tried to build up customized queries only depending on this RFC. However, I found if the number of desired fields I passed to this RFC are more than 2, I always got the DATA_BUFFER_EXCEEDED error even if I limit the max rows.

I am not authorized to be an ABAP developer in the SAP system and can not add any FM to existing systems, so I can only write code to accomplish this requirement in JAVA.

Am I doing something wrong? Could you give me some hints on that issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

潦草背影 2024-10-09 11:54:54

使用 BBP_RFC_READ_TABLE 代替

Use BBP_RFC_READ_TABLE instead

ˇ宁静的妩媚 2024-10-09 11:54:54

有一种方法可以解决 DATA_BUFFER_EXCEED 错误。尽管根据 SAP OSS 注释 382318,此函数并未发布供客户使用,但您可以通过更改向此函数传递参数的方式来解决此问题。它不是导致错误的单个字段,但如果数据行超过 512 字节,则会引发此错误。 CDPOS肯定会有这个问题!

如果您知道如何使用 Jco 调用函数并传递表参数,解决方法是指定您想要返回的确切字段。然后,您可以将返回的结果保持在 512 字节限制以下。

使用表 CDPOS 的示例,指定类似这样的内容,您应该可以开始...(小心,CDPOS 可能会变得很大!您应该指定并传递一个 where 子句!)

FIELDS = 'OBJECTCLAS'...
FIELDS = 'OBJECTID'

在 Java 中可以表示为..

listParams.setValue(this.getpObjectclas(), "OBJECTCLAS");

通过限制您返回的字段,您可以避免此错误。

There is a way around the DATA_BUFFER_EXCEED error. Although this function is not released for customer use as per SAP OSS note 382318, you can get around this issue with changes to the way you pass parameters to this function. Its not a single field that is causing your error, but if the row of data exceeds 512 bytes this error will be raised. CDPOS will have this issue for sure!

The work around if you know how to call the function using Jco and pass table parameters is to specify the exact fields you want returned. You then can keep your returned results under the 512 byte limit.

Using your example of table CDPOS, specify something like this and you should be good to go...(be careful, CDPOS can get massive! You should specify and pass a where clause!)

FIELDS = 'OBJECTCLAS'....
FIELDS = 'OBJECTID'

In Java it can be expressed as..

listParams.setValue(this.getpObjectclas(), "OBJECTCLAS");

By limiting the fields you are returning you can avoid this error.

裸钻 2024-10-09 11:54:53

仅当您要读取的字段的总宽度超过 DATA 参数的宽度时,DATA_BUFFER_EXCEEDED 才会发生,该宽度可能因 SAP 的不同而异版本 - 当前系统为 512 个字符。它与行数无关,而是与单个数据集的大小有关。

那么问题来了:FIELDS参数的内容是什么?如果为空,则意味着“读取所有字段”。 CDHDR 的宽度为 192 个字符,因此我假设问题是 CDPOS 的宽度为 774 个字符。主要问题是字段 VALUE_OLDVALUE_NEW,均为 245 个字符。

即使您没有获得开发人员访问权限,您也应该敦促某人获得只读字典访问权限,以便能够详细检查结构。

无耻的插件:RCER 包含一个 RFC_READ_TABLE 的包装类,负责字段处理和确保所选字段的总宽度低于功能模块施加的限制。

另请注意,这些表在生产环境中可能会很大 - 想想数十亿个条目。通过对这些表执行过多的读取操作,您可以轻松地使数据库陷入瘫痪。

PS:根据 SAP 说明 RFC_READ_TABLE 未发布供客户使用>382318,注释758278建议创建您的拥有自己的功能模块,并提供了逻辑改进的模板。

DATA_BUFFER_EXCEEDED only happens if the total width of the fields you want to read exceeds the width of the DATA parameter, which may vary depending on the SAP release - 512 characters for current systems. It has nothing to do with the number of rows, but the size of a single dataset.

So the question is: What are the contents of the FIELDS parameter? If it's empty, this means "read all fields." CDHDR is 192 characters in width, so I'd assume that the problem is CDPOS which is 774 characters wide. The main issue would be the fields VALUE_OLD and VALUE_NEW, both 245 Characters.

Even if you don't get developer access, you should prod someone to get read-only dictionary access to be able to examine the structures in detail.

Shameless plug: RCER contains a wrapper class for RFC_READ_TABLE that takes care of field handling and ensures that the total width of the selected fields is below the limit imposed by the function module.

Also be aware that these tables can be HUGE in production environments - think billions of entries. You can easily bring your database to a grinding halt by performing excessive read operations on these tables.

PS: RFC_READ_TABLE is not released for customer use as per SAP note 382318, and the note 758278 recommends to create your own function module and provides a template with an improved logic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文