07-23-2019 6:08 PM
I am trying to get a table (BKPF) from the RFKSLD00 that includes the monat (reporting period) field as I need it in the following code:
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
DATA: gt_fkont TYPE STANDARD TABLE OF foap_s_rfksld00_list1,
gt_fkont_sum TYPE STANDARD TABLE OF foap_s_rfksld00_list1,
gt_BKPF TYPE STANDARD TABLE OF BKPF,
lcl_table TYPE REF TO cl_abap_tabledescr,
lcl_struc TYPE REF TO cl_abap_structdescr,
it_fields TYPE abap_compdescr_tab,
wa_fields TYPE abap_compdescr.
FIELD-SYMBOLS: <itab> TYPE ANY,
<pos_data> LIKE LINE OF gt_BKPF.
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 = gt_BKPF ).
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
ENDTRY.
ASSIGN gt_BKPF TO <itab>.
START-OF-SELECTION.
* Get the Table details
lcl_table ?= cl_abap_typedescr=>describe_by_data( <itab> ).
* Get the table line type i.e., structure details
lcl_struc ?= lcl_table->get_table_line_type( ).
* Get the components(fields) of the table line
it_fields = lcl_struc->components.
LOOP AT it_fields INTO wa_fields.
WRITE: / wa_fields-name.
ENDLOOP.
LOOP AT gt_BKPF ASSIGNING <pos_data>.
APPEND INITIAL LINE to lt_report ASSIGNING <fs_rep>.
MOVE-CORRESPONDING <pos_data> TO <fs_rep>.
WRITE: / <pos_data>-monat.
ENDLOOP.
Write: 'Program End!'.
I am getting the following runtime error:
CX_SY_IMPORT_MISMATCH_ERROR
When impoting "T_DATA", the componet 1 in the dataset has a different length from the corresponding component of the target object in the program *CL_SALV_BS_RUNTIME_INFO======CP"
The length is 20 in the data set but 6 in the program
Maybe I cannot access the BKPF table. Any fixes?