简体   繁体   English

方法“GET_DATA_REF”不存在(cl_salv_bs_runtime_info),为什么?

[英]Method "GET_DATA_REF" does not exist (cl_salv_bs_runtime_info), why?

I cannot use cl_salv_bs_runtime_info=>get_data_ref as I get this syntax error:我无法使用cl_salv_bs_runtime_info=>get_data_ref因为我收到此语法错误:

Method "GET_DATA_REF" does not exist.方法“GET_DATA_REF”不存在。 There is however a method with similar name "GET_DATA"然而,有一个类似名称“GET_DATA”的方法

Maybe I am using a newer or an older version of SAP or is it something else?也许我使用的是较新或较旧版本的 SAP 或者是其他什么?

My code:我的代码:

REPORT  ZSAM1.

 TYPES: BEGIN OF ty_report,
          rec_acc TYPE skont,
          vendor TYPE LFA1-LIFNR,
          jan_deb TYPE BSEG-WRBTR,
          jan_cred TYPE BSEG-WRBTR,
          feb_deb TYPE BSEG-WRBTR,
          feb_cred TYPE BSEG-WRBTR,
          mar_deb TYPE BSEG-WRBTR,
          mar_cred TYPE BSEG-WRBTR,
          apr_deb TYPE BSEG-WRBTR,
          apr_cred TYPE BSEG-WRBTR,
          may_deb TYPE BSEG-WRBTR,
          may_cred TYPE BSEG-WRBTR,
          jun_deb TYPE BSEG-WRBTR,
          jun_cred TYPE BSEG-WRBTR,
          jul_deb TYPE BSEG-WRBTR,
          jul_cred TYPE BSEG-WRBTR,
          aug_deb TYPE BSEG-WRBTR,
          aug_cred TYPE BSEG-WRBTR,
          sep_deb TYPE BSEG-WRBTR,
          sep_cred TYPE BSEG-WRBTR,
          oct_deb TYPE BSEG-WRBTR,
          oct_cred TYPE BSEG-WRBTR,
          nov_deb TYPE BSEG-WRBTR,
          nov_cred TYPE BSEG-WRBTR,
          dec_deb TYPE BSEG-WRBTR,
          dec_cred TYPE BSEG-WRBTR,
          acc_bal_deb TYPE BSEG-WRBTR,
          acc_bal_cred TYPE BSEG-WRBTR,
        END OF ty_report,
        tt_report TYPE TABLE OF ty_report.

DATA:  lt_report TYPE tt_report,
       lv_ukurs type tcurr-ukurs,
       Tcurr1 type tcurr,
       fieldname(4) type c,
       fnamedebit(20) type c,
       fnamecredit(20) type c.

FIELD-SYMBOLS: <fs_rep> LIKE LINE OF lt_report.


 select single ukurs from tcurr
        into lv_ukurs
        where fcurr = 'EUR'
        and   tcurr = 'AUD'. "<- your  local currency

DATA: lr_pay_data        TYPE REF TO data,
      lr_pay_data_line   TYPE REF TO data,
      lr_data_descr      TYPE REF TO cl_abap_datadescr,
      lr_data_line_descr TYPE REF TO cl_abap_datadescr.

FIELD-SYMBOLS: <lt_pay_data>      TYPE ANY TABLE,
               <ls_pay_data_line> TYPE ANY TABLE.

  cl_salv_bs_runtime_info=>set(
    EXPORTING display  = abap_false
              metadata = abap_false
              structure = ''
              data     = abap_true ).

SUBMIT RFKSLD00 via SELECTION-SCREEN and return.


cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data_descr = lr_data_descr
     r_data_line_descr = lr_data_line_descr ).

CREATE DATA lr_pay_data TYPE HANDLE lr_data_descr.
CREATE DATA lr_pay_data_line TYPE HANDLE lr_data_descr.

ASSIGN lr_pay_data->* TO <lt_pay_data>.
ASSIGN lr_pay_data_line->* TO <ls_pay_data_line>.

cl_salv_bs_runtime_info=>get_data(
  IMPORTING t_data = <lt_pay_data> 
        t_data_line = <ls_pay_data_line> ).

LOOP AT <lt_pay_data> ASSIGNING <ls_pay_data_line>.

 APPEND INITIAL LINE to lt_report ASSIGNING <fs_rep>.
 MOVE-CORRESPONDING <ls_pay_data_line> TO <fs_rep>.

WRITE: / <ls_pay_data_line>.

ENDLOOP.

Write: 'Program End!'.

The syntax error tells you that the method doesn't exist.语法错误告诉您该方法不存在。 If you look at the concerned class and you don't see that method, then of course it means that it doesn't exist in your system.如果你查看相关的类并且你没有看到那个方法,那么当然这意味着它在你的系统中不存在。

Software keep evolving.软件不断发展。 In new versions there are sometimes new programs, sometimes others are deleted.在新版本中,有时会出现新程序,有时会删除其他程序。 That's life...这就是生活...

PS: note that the class cl_salv_bs_runtime_info is not officially supported. PS:请注意,类cl_salv_bs_runtime_info不受官方支持。 Use it at your own risk.需要您自担风险使用它。

I've recently stumble upon the same problem.我最近偶然发现了同样的问题。

This error is caused by cl_salv_bs_runtime_info version don't have method GET_DATA_REF.此错误是由 cl_salv_bs_runtime_info 版本没有方法 GET_DATA_REF 引起的。

You might want to try to read this article https://blogs.sap.com/2011/07/07/gain-programmatic-access-to-data-of-sapgui-alv-reports/ .您可能想尝试阅读这篇文章https://blogs.sap.com/2011/07/07/gain-programmatic-access-to-data-of-sapgui-alv-reports/

In the near end article they describe the difference between get_data_ref and get_data.在近端文章中,他们描述了 get_data_ref 和 get_data 之间的区别。 Since we do not have get_data_ref, if we want to retrieve alv data from submit program we can only use get_data report.由于我们没有 get_data_ref,如果我们想从提交程序中检索 alv 数据,我们只能使用 get_data 报告。 You might have notice that in this version there is parameter structure in你可能已经注意到,在这个版本中有参数结构

cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false metadata = abap_false structure = '' data = abap_true ). cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false metadata = abap_false structure = '' data = abap_true )。

This is because method get_data can not be used for dynamic table.这是因为方法 get_data 不能用于动态表。 Before retrieving the data we need to know its structure first.在检索数据之前,我们需要先了解其结构。 Since you want to submit standard program RFKSLD00, you can first search for the structure used in them.既然要提交标准程序RFKSLD00,可以先搜索其中用到的结构。 After finding the structure you can put the structure name in structure parameter.找到结构后,您可以将结构名称放在结构参数中。

After that, you can declare an internal table using the structure submitted above and put the internal table in to t_data parameter in get_data method.之后,您可以使用上面提交的结构声明一个内表,并将该内表放入 get_data 方法中的 t_data 参数中。

Hope this answer will help.希望这个答案会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM