我有一个深层结构,我希望将其显示为一个树,其中包含每个字段的值(有点像可以在SE11中使用值的结构的分层显示)。
有没有一个类或函数可以帮你做到这一点?我真的不想去重新发明轮子。
发布于 2011-06-09 21:01:43
嗯,我想说做DIY比搜索一些足够通用的东西来帮助你更快。您可以尝试以下代码作为基础。
它通过变量(表或结构)执行普通的递归,并打印在底部找到的字段……
*&---------------------------------------------------------------------*
*& Form print_structure
*&---------------------------------------------------------------------*
form print_structure using im_data.
data: lr_typeref type ref to cl_abap_typedescr,
lf_ddic_in type fieldname,
lt_dfies type ddfields,
lf_string type c length 200.
field-symbols: <lt_table> type any table,
<ls_table> type any,
<lf_field> type any,
<ls_dfies> like line of lt_dfies.
lr_typeref = cl_abap_typedescr=>describe_by_data( im_data ).
case lr_typeref->type_kind.
when cl_abap_typedescr=>typekind_table. " internal table
assign im_data to <lt_table>.
loop at <lt_table> assigning <ls_table>.
perform print_structure using <ls_table>.
endloop.
when cl_abap_typedescr=>typekind_struct1 or
cl_abap_typedescr=>typekind_struct2. " deep/flat structure
lf_ddic_in = lr_typeref->get_relative_name( ).
call function 'DDIF_FIELDINFO_GET'
exporting
tabname = lf_ddic_in
all_types = 'X'
tables
dfies_tab = lt_dfies
exceptions
not_found = 1
others = 0.
check sy-subrc eq 0.
loop at lt_dfies assigning <ls_dfies>.
assign component <ls_dfies>-fieldname of structure im_data to <lf_field>.
perform print_structure using <lf_field>.
endloop.
when others. " any field
write im_data to lf_string.
write: / lf_string.
endcase.
endform. "print_structure发布于 2011-05-19 22:34:15
ALV树可以工作吗?CL_SALV_TREE
发布于 2011-06-10 14:47:17
我从来没有见过这样的功能,我认为在标准中没有人。在标准中,我记不起应该在什么情况下使用这些功能。在我看来,实现这一点最合适的方式是使用列树。看一看SAPCOLUMN_TREE_CONTROL_DEMO
https://stackoverflow.com/questions/6056782
复制相似问题