检查报告是否使用分层 ALV.如何? [英] Checking if a report uses hierarchical ALV or not. How?

查看:23
本文介绍了检查报告是否使用分层 ALV.如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了一种导出分层 ALV 的方法 在这个问题的帮助下.不幸的是,我不知道该报告是否使用分层 ALV.

I found a way to export a hierarchical ALV with the help of this question. Unfortunately I don't know in advanced if the report uses hierarchical ALV or not.

如果我将上述答案的代码应用于报告 RFSKPL00,那么我会在 cl_salv_bs_runtime_info=>get_data() 中得到一个异常:

If I apply the code of above answer to the report RFSKPL00, then I get an exception in cl_salv_bs_runtime_info=>get_data() here:

  if t_data_line is requested.
    import t_data_line to t_data_line from memory id cl_salv_bs_runtime_info=>c_memid_data_line.
    if sy-subrc ne 0.
      raise exception type cx_salv_bs_sc_runtime_info  <=========
        exporting
          textid = 'ERROR'.
    endif.
  endif.

如果报表使用分层 ALV,我如何在 ABAP 中检查?

How can I check in ABAP if a report uses hierarchical ALV or not?

推荐答案

我想要相同的信息,而 Sandra 的回答对我没有帮助/不起作用,因为参数无法填充.但是cl_salv_bs_runtime_info 有另一个功能可以解决我的问题,get_metadata.它有一个按预期填充的参数 is_hierseq.

I wanted the same information and the answer by Sandra didn't help me/didn't work, because the parameters just wouldn't fill. But cl_salv_bs_runtime_info has another function that solved my problem, get_metadata. It has a parameter is_hierseq that gets filled as expected.

DATA: lr_data            TYPE REF TO data,
      lr_data_line       TYPE REF TO data.
FIELD-SYMBOLS: <lt_data>      TYPE ANY TABLE,
               <lt_data_line> TYPE ANY TABLE.
" initialising runtime analysis
cl_salv_bs_runtime_info=>set( EXPORTING display  = abap_false
                                        metadata = abap_true
                                        data     = abap_true ).
* ALV grid / hierarchical output:
CALL TRANSACTION 'MB51'.

* Testing output mode using metadata
DATA(runtime_metadata) = cl_salv_bs_runtime_info=>get_metadata( ).

IF runtime_metadata-is_hierseq IS INITIAL.
  cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data_descr = DATA(lr_data_descr) ).

  CREATE DATA lr_data TYPE HANDLE lr_data_descr.
  ASSIGN lr_data->* TO <lt_data>.

  cl_salv_bs_runtime_info=>get_data( IMPORTING t_data = <lt_data> ).
ELSE. " hierarchical
  cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data_descr      = lr_data_descr
                                                  r_data_line_descr = DATA(lr_data_line_descr) ).

  CREATE DATA lr_data      TYPE HANDLE lr_data_descr.
  CREATE DATA lr_data_line TYPE HANDLE lr_data_line_descr.
  ASSIGN lr_data->* TO <lt_data>.
  ASSIGN lr_data_line->* TO <lt_data_line>.

  cl_salv_bs_runtime_info=>get_data( IMPORTING t_data      = <lt_data>
                                               t_data_line = <lt_data_line> ).
ENDIF.

在简单的 SALV 网格的情况下 var 包含输出,而在分层 ALV 列表的情况下,结果将在 代码>代替.

In the case of a simple SALV grid <lt_data> var contains the output, and in the case of a hierarchical ALV list the result will be in <lt_data_line> instead.

这篇关于检查报告是否使用分层 ALV.如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆