-1

I'm trying to retrieve the ALV table that is generated by the program RFKSLD00, but I cannot get cl_salv_bs_runtime_info to work. Here is what I have:

REPORT  ZSAM3.
 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
FIELD-SYMBOLS: <lt_pay_data>   TYPE ANY TABLE,
               <pos_data> TYPE ANY.
DATA lr_pay_data              TYPE REF TO data.
  cl_salv_bs_runtime_info=>set(
    EXPORTING display  = abap_false
              metadata = abap_false
              structure = ''
              data     = abap_true ).
SUBMIT RFKSLD00 via SELECTION-SCREEN and return.
TRY.
      cl_salv_bs_runtime_info=>get_data(
        IMPORTING t_data = lr_pay_data ).
      ASSIGN lr_pay_data->* TO <lt_pay_data>.
    CATCH cx_salv_bs_sc_runtime_info.
      MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
  ENDTRY.
LOOP AT <lt_pay_data> ASSIGNING <pos_data>.
 APPEND INITIAL LINE to lt_report ASSIGNING <fs_rep>.
 MOVE-CORRESPONDING <pos_data> TO <fs_rep>.
 CASE <pos_data>-monat. "<- your period
  WHEN '01'.
   <fs_rep>-jan_deb = w_tab-debit.
   <fs_rep>-jan_cred = w_tab-credit.
   fieldname = 'jan'.
  WHEN '02'.
   <fs_rep>-feb_deb = w_tab-debit.
   <fs_rep>-feb_cred = w_tab-credit.
   fieldname = 'feb'.
  WHEN '03'.
   <fs_rep>-mar_deb = w_tab-debit.
   <fs_rep>-mar_cred = w_tab-credit.
   fieldname = 'mar'.
   WHEN '04'.
   <fs_rep>-apr_deb = w_tab-debit.
   <fs_rep>-apr_cred = w_tab-credit.
   fieldname = 'apr'.
   WHEN '05'.
   <fs_rep>-may_deb = w_tab-debit.
   <fs_rep>-may_cred = w_tab-credit.
   fieldname = 'may'.
   WHEN '06'.
   <fs_rep>-jun_deb = w_tab-debit.
   <fs_rep>-jun_cred = w_tab-credit.
   fieldname = 'jun'.
   WHEN '07'.
   <fs_rep>-jul_deb = w_tab-debit.
   <fs_rep>-jul_cred = w_tab-credit.
   fieldname = 'jul'.
   WHEN '08'.
   <fs_rep>-aug_deb = w_tab-debit.
   <fs_rep>-aug_cred = w_tab-credit.
   fieldname = 'aug'.
   WHEN '09'.
   <fs_rep>-sep_deb = w_tab-debit.
   <fs_rep>-sep_cred = w_tab-credit.
   fieldname = 'sep'.
   WHEN '10'.
   <fs_rep>-oct_deb = w_tab-debit.
   <fs_rep>-oct_cred = w_tab-credit.
   fieldname = 'oct'.
   WHEN '11'.
   <fs_rep>-nov_deb = w_tab-debit.
   <fs_rep>-nov_cred = w_tab-credit.
   fieldname = 'nov'.
   WHEN '12'.
   <fs_rep>-dec_deb = w_tab-debit.
   <fs_rep>-dec_cred = w_tab-credit.
   fieldname = 'dec'.
 ENDCASE.
concatenate '<fs_rep>' fieldname '_deb'into fnamedebit.
concatenate '<fs_rep>' fieldname '_cred'into fnamecredit.
  CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
   EXPORTING
   DATE                    = sy-datum
   FOREIGN_CURRENCY        = 'EUR'
   LOCAL_CURRENCY          = 'AUD'
   FOREIGN_AMOUNT          = <fnamedebit>
   TYPE_OF_RATE            = 'M'
  IMPORTING
   EXCHANGE_RATE           = lv_ukurs
   LOCAL_AMOUNT            = <w_tab-debit>.
   CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
   EXPORTING
   DATE                    = sy-datum
   FOREIGN_CURRENCY        = 'EUR'
   LOCAL_CURRENCY          = 'AUD'
   FOREIGN_AMOUNT          = <fnamecredit>
   TYPE_OF_RATE            = 'M'
  IMPORTING
   EXCHANGE_RATE           = lv_ukurs
   LOCAL_AMOUNT            = <w_tab-credit>.
ENDLOOP.
Write: 'Program End!'.

I had to to specify an obligatory parameter structure in the SET method (which I do not know what value so I just put ''). Also the method GET_DATA_REF did not exist so I used GET_DATA instead and now I am getting:

"LR_PAY_DATA" is not type compatible with formal parameter "T_DATA".

Maybe because there were updates to this or something as other posts did not have these issues.

What am I doing wrong?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
mj1261829
  • 1,200
  • 3
  • 26
  • 53
  • It's unclear if your question is general (how to extract the ALV data from a SUBMITted program) or if it's just about this syntax error. As I know that it's a much general question (general steps to create a program based on a given specification), you should ask another question, explain the whole context, what you searched, what you tried, your doubts and so on. Read stackoverflow help and meta to understand how such questions can be asked. – Sandra Rossi Jul 23 '19 at 17:33

1 Answers1

2

The T_DATA parameter is of a TABLE type and you are trying to pass a REF TO DATA to it.

Parameters

You need to pass a variable that is a table.

In your example it could be done like this.

TRY.
    ASSIGN lr_pay_data->* TO <lt_pay_data>.
    cl_salv_bs_runtime_info=>get_data(
      IMPORTING t_data = <lt_pay_data> ).
  CATCH cx_salv_bs_sc_runtime_info.
    MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
ENDTRY.

Of course first you have to initialize lr_pay_data at some point, becase I do not see it anywhere in your code.

Jagger
  • 10,350
  • 9
  • 51
  • 93
  • How to initialize lr_pay_data ? – mj1261829 Jul 22 '19 at 11:50
  • 1
    @mj1261829 it is initialized by `cl_salv_bs_runtime_info=>get_data` method automatically, if executed without errors, you don't need to do this manually. Of course you need check this (if there were errors) for example with `IF ASSIGNED` – Suncatcher Jul 23 '19 at 02:41