我正在将动态创建的内部表导出到内存。
我想知道是否有可能以某种方式(从另一个程序)取回它,此外,虽然第一个程序至少知道我从中动态创建 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'.