我正在将动态创建的内部表导出到内存。
我想知道是否可以以某种方式(从另一个程序)取回它,此外,第一个程序至少知道我动态创建 itab 的表的名称,而第二个程序没有。
这是我导出 itab 的代码(可以工作:P)。
parameters: pi_tbl(5) type c obligatory. "The table name - input from the user. can be jibberish.
data: gr_tabref type ref to data.
field-symbols:<gfs_tab> type any table.
form create_dynamic_gr_tabref .
data: lo_struct type ref to cl_abap_structdescr,
lo_tabref type ref to cl_abap_tabledescr.
lo_struct ?= cl_abap_typedescr=>describe_by_name( pi_tbl ).
try.
call method cl_abap_tabledescr=>create
exporting
p_line_type = lo_struct
receiving
p_result = lo_tabref
.
catch cx_sy_table_creation .
message 'Couldn''t create the table description. Quitting' type 'E'.
endtry.
create data gr_tabref type handle lo_tabref.
assign gr_tabref->* to <gfs_tab>.
select * from (pi_tbl) into table <gfs_tab> up to 200 rows.
data: lv_memory_id(30) type c.
lv_memory_id = 'MYMEMORYID'.
export itab from <gfs_tab> to memory id lv_memory_id.
endform.
我可以只使用带表名的参数取回数据吗?
我想要的是声明一个通用数据类型,然后将数据放入其中,例如:
Object myObject; import itab to myObject memory id 'MYMEMORYID'.
最佳答案
在第一个程序中替换
export itab from <gfs_tab> to memory id lv_memory_id.
与
cl_salv_bs_runtime_info=>set(
EXPORTING
display = space
metadata = space
data = 'X'
).
cl_salv_bs_runtime_info=>set_data(
EXPORTING
data = <gfs_tab>
).
在第二个程序中这样做:
data lpt_data type ref to data.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING
r_data = lpt_data
).
关于memory - 从ABAP内存导入通用表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12009773/