动态指定数据库表?是否可以?
我正在编写 BSP,并且根据用户输入,我需要从不同的数据库表中选择数据。这些表位于不同的包中。是否可以根据其路径指定我想要使用的表,如下所示:
data: path1 type string value 'package1/DbTableName',
path2 type string value 'package2/OtherDbTableName',
table_to_use type string.
if some condition
table_to_use = path1.
elseif some condition
table_to_use = path2.
endif.
select *
from table_to_use
...
endselect
I am new to ABAP &打开 SQL,我知道这可能是一个简单/愚蠢的问题:) 任何帮助都将非常感激!
I am writing a BSP and based on user-input I need to select data from different DB tables. These tables are in different packages. Is it possible to specify the table I want to use, based on its path, like this:
data: path1 type string value 'package1/DbTableName',
path2 type string value 'package2/OtherDbTableName',
table_to_use type string.
if some condition
table_to_use = path1.
elseif some condition
table_to_use = path2.
endif.
select *
from table_to_use
...
endselect
I am new to ABAP & Open SQL and am aware this could be an easy/silly question :) Any help at all would be very much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以定义要在变量中使用的表的名称,然后在请求的 FROM close 中使用该变量:
此方法有一些限制,因为稳定不能包含 RAWSTRING、STRING 或 SSTRING 类型的字段。
至于桌子位于不同的包装中,我认为这并不重要。
问候,
You can define the name of the table to use in a variable, and then use the variable in the FROM close of your request :
there are a few limitation to this method, as the stable can not contains fields of type RAWSTRING, STRING or SSTRING.
as for the fact that the table are in different package, i don't think it matters.
Regards,