Code: Alles auswählen.
REPORT z_anlaginv.
TABLES: anla.
DATA: companycode TYPE bapi1022_1-comp_code,
asset TYPE bapi1022_1-assetmaino,
subnumber TYPE bapi1022_1-assetsubno,
timedependentdata TYPE bapi1022_feglg003,
timedependentdatax TYPE bapi1022_feglg003x,
inventory TYPE bapi1022_feglg011,
inventoryx TYPE bapi1022_feglg011x.
DATA: wa_return TYPE bapiret2.
PARAMETERS: p_datei(40) TYPE c.
DATA: BEGIN OF itab_anlaginv OCCURS 10,
bukrs LIKE anla-bukrs,
anhaupt LIKE anla-anln1,
anunter LIKE anla-anln2,
feldname(60),
feldwert(60),
END OF itab_anlaginv.
TYPES: BEGIN OF t_file,
line(255) TYPE c,
END OF t_file.
DATA: gt_file TYPE TABLE OF t_file,
gw_file TYPE t_file.
DATA: wa_anlaginv LIKE LINE OF itab_anlaginv.
DATA: upload TYPE string.
FIELD-SYMBOLS <fs> TYPE ANY.
START-OF-SELECTION.
*###################
upload = p_datei.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = upload
filetype = 'ASC'
TABLES
data_tab = gt_file
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE i040(/sapdmc/lsmw_glo_010).
* Fehler beim Upload der Datei
ENDIF.
LOOP AT gt_file INTO gw_file.
SPLIT gw_file AT ';' INTO itab_anlaginv-bukrs
itab_anlaginv-anhaupt
itab_anlaginv-anunter
itab_anlaginv-feldname
itab_anlaginv-feldwert.
APPEND itab_anlaginv.
ENDLOOP.
SORT itab_anlaginv BY bukrs anhaupt anunter.
LOOP AT itab_anlaginv INTO wa_anlaginv.
AT NEW anunter.
CLEAR timedependentdata.
CLEAR timedependentdatax.
CLEAR inventory.
CLEAR inventoryx.
ENDAT.
ASSIGN (wa_anlaginv-feldname) TO <fs>.
<fs> = wa_anlaginv-feldwert.
AT END OF anunter.
CALL FUNCTION 'BAPI_FIXEDASSET_CHANGE'
EXPORTING
companycode = companycode
asset = asset
subnumber = subnumber
inventory = inventory
inventoryx = inventoryx
timedependentdata = timedependentdata
timedependentdatax = timedependentdatax
IMPORTING
return = wa_return.
IF wa_return IS INITIAL.
MESSAGE i409(merep_00).
* Erfolgreich gesichert
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDAT.
ENDLOOP.
Schau dir das File doch mal genau an (mit einem Editor nicht mit Excel)robin1at hat geschrieben:Nur leider habe ich immer noch das Problem mit dem File einlesen.
Hoffe Ihr könnt mir helfen.
Code: Alles auswählen.
TRANSLATE gw_file USING '" '.
CONDENSE gw_file.