Skip to Content
0
Nov 15, 2013 at 04:00 PM

fill in conditions table with uploading xls

38 Views

Hello Every one,

i make ABAP program to fill in my conditions table with a upload excel file, it's works good, but i have to run this code in background:

report zz_record_upload
no standard page heading line-size 255.

*INCLUDE bdcrecx1.
type-pools: truxs.
types:begin of ty_tax,
kschl type kschl,
kotabnr type kotabnr,
vkorg type vkorg,
vtweg type vtweg,
matkl type matkl,
zztransport type zztransp,
mwsk1 type mwskz,
end of ty_tax.

data: it_tax type table of ty_tax,
wa_tax type ty_tax.
data: it_bdcdata type table of bdcdata,
wa_bdcdata type bdcdata.

start-of-selection.

parameters: p_file type rlgrap-filename. .
data: it_raw type truxs_t_text_data.

at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
field_name = 'P_FILE'
importing
file_name = p_file.

call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = 'C:/record_vk15.xlsx' " 'C:/RECORD_DATA.xls' " "p_file
tables
i_tab_converted_data = it_tax[]
exceptions
conversion_failed = 1
others = 2
.

if sy-subrc eq 0.
message 'Data downloaded successfully' type 'I'.
endif.


loop at it_tax into wa_tax.
perform bdc_dynpro using 'SAPMV13A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RV13A-KOTABNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RV13A-KSCHL'
wa_tax-kschl.
perform bdc_field using 'RV13A-KOTABNR'
wa_tax-kotabnr.
perform bdc_dynpro using 'SAPMV13A' '1558'.
perform bdc_field using 'BDC_CURSOR'
'KOMG-ZZTRANSPORT(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KOMG-VKORG'
wa_tax-vkorg.
perform bdc_field using 'KOMG-VTWEG'
wa_tax-vtweg.
perform bdc_field using 'KOMG-MATKL'
wa_tax-matkl.
perform bdc_field using 'KOMG-ZZTRANSPORT(01)'
wa_tax-zztransport.
perform bdc_dynpro using 'SAPMV13A' '1558'.
perform bdc_field using 'BDC_CURSOR'
'KONP-MWSK1(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KONP-MWSK1(01)'
wa_tax-mwsk1.
perform bdc_dynpro using 'SAPMV13A' '1558'.
perform bdc_field using 'BDC_CURSOR'
'KOMG-ZZTRANSPORT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
*PERFORM bdc_transaction USING 'VK15'.
call transaction 'VK15' using it_bdcdata mode 'A' update 'S'.
refresh it_bdcdata.
endloop.


*PERFORM close_group.

*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
clear wa_bdcdata.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
append wa_bdcdata to it_bdcdata.
endform. "bdc_dynpro

*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
* IF fval <> nodata.
clear wa_bdcdata.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
append wa_bdcdata to it_bdcdata.
* ENDIF.
endform. "bdc_field

*****************************************here is the output***********************************

So every time, i have to click enter to create a record via vk15.

There is no way to do that in background ?

Here is my xls file:

so my Table A558 is filled in with data, that is ok.

Some one has the code to do that in AL11 via a another way ?

Thank u.

Ouail.

Attachments

pastedImage_0.png (16.7 kB)