You are on page 1of 4

*&---------------------------------------------------------------------*

*& Report ZBDCREPORT


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report ZBDCREPORT.
selection-screen begin of block b1 with frame title text-001.
parameters: filepath type rlgrap-filename obligatory,
beg_row type i obligatory,
end_row type i obligatory,
mode type ctu_mode.
selection-screen end of block b1.
types: begin of t_final,
bukrs type bukrs,
belnr type belnr_d,
gjahr type gjahr,
end of t_final.
data: excell_tab type standard table of alsmex_tabline with header line,
it_final type standard table of t_final with header line,
it_final1 type standard table of t_final with header line,
it_bdcdata type standard table of bdcdata with header line,
it_messtab type standard table of bdcmsgcoll with header line.
at selection-screen on value-request for filepath.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name
= 'FILEPATH'
importing
file_name
= filepath.
start-of-selection.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename
= filepath
i_begin_col
= 1
i_begin_row
= beg_row
i_end_col
= 20
i_end_row
= end_row
tables
intern
= excell_tab
exceptions
inconsistent_parameters = 1

upload_ole
= 2
others
= 3.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
perform final_table1.
perform fill_final_table.
delete adjacent duplicates from it_final1 comparing all fields.
loop at it_final1.
refresh it_bdcdata[].
perform bdc using : 'SAPMF05L'
'0100'
'X',
'BDC_OKCODE' '/00'
' ',
'RF05L-BELNR' it_final1-belnr
' ',
'RF05L-BUKRS' it_final1-bukrs
' ',
'RF05L-GJAHR' it_final1-gjahr
' ',
'SAPMF05L'
'0700'
'X',
'BDC_OKCODE' '=AE'
''.
call transaction 'FB02' using it_bdcdata
mode mode
messages into it_messtab.
endloop.
*&---------------------------------------------------------------------*
*&
Form FINAL_TABLE
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form final_table1 .
clear it_final1.
refresh it_final1[].
loop at excell_tab.
if excell_tab-col = 1.
it_final1-bukrs = excell_tab-value.
elseif excell_tab-col = 2.
it_final1-belnr = excell_tab-value.
elseif excell_tab-col = 3.
it_final1-gjahr = excell_tab-value.
endif.
at end of row.
append it_final1.
clear it_final1.
endat.
endloop.

endform.
" FINAL_TABLE
*&---------------------------------------------------------------------*
*&
Form FILL_FINAL_TABLE
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form fill_final_table .
clear it_final.
refresh it_final[].
loop at excell_tab.
if excell_tab-col = 1.
it_final1-bukrs = excell_tab-value.
elseif excell_tab-col = 2.
it_final1-belnr = excell_tab-value.
elseif excell_tab-col = 3.
it_final1-gjahr = excell_tab-value.
endif.
at end of row.
append it_final1.
clear it_final1.
endat.
endloop.
endform.
" FILL_FINAL_TABLE
*&---------------------------------------------------------------------*
*&
Form BDC
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_0210
text
*
-->P_0211
text
*
-->P_0212
text
*----------------------------------------------------------------------*
form bdc using
val1 val2 flag.
clear it_bdcdata.
if flag = 'X'.
it_bdcdata-program
it_bdcdata-dynpro
it_bdcdata-dynbegin
else.
it_bdcdata-fnam
=
it_bdcdata-fval
=
endif.
append it_bdcdata.

= val1.
= val2.
= 'X'.
val1.
val2.

endform.

" BDC

You might also like