‎2009 Feb 06 3:36 AM
Hi Friends,
I am new to BAPI,How to upload data(flat file and excel file) from legacy system to R/3 system using BAPI?
Thanks in advance,
Kishore
‎2009 Feb 06 5:03 AM
first you need to get the data from desk top or application server using
If the Presentation Server is selected on the selection screen
call function 'GUI_UPLOAD'
exporting
filename = gv_file
filetype = gc_filetype
tables
data_tab = gt_text_file
Read the data from Application Server
open dataset gv_file for input in text mode encoding default
with smart linefeed.
read dataset gv_file into gv_str.
close dataset gv_file.
split gv_str at gc_comma into wa_text_tablev-objectid
wa_text_tablev-lifnr.
then you have to pass the values into BAPI
‎2009 Feb 06 5:05 AM
Hi kishor,
You can't directly upload data using BAPI.
You have to use the existing function module for uploading the DATA from text file or excel file and then use the desire BAPI and pass the data you get it from Function module.
If the data is in excel sheet use this FM.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 17
I_END_ROW = 3000
TABLES
INTERN = itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
.
It will read the data from excel sheet column wise and then store it in ITAB.
In case of Text file use FM GUI_UPLOAD. and then call the BAPI and pass the data to BAPI structures/input parameters.
Sachin
‎2012 Mar 08 4:38 PM
Hi,
I am also working on the data upload from non sap sytem lagecy file to sap system through bapi. I
am using function
gui_upload.
do u know step by step procedure to upload a flat file from non sap system to sap system then do let me know to.
Thanks
‎2012 Mar 09 9:43 AM
HI shilpa,
Try to use below code
DATA : lv_file_name TYPE string. "File name
lv_file_name = pv_file.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lv_file_name
filetype = gc_asc
has_field_separator = gc_x
CHANGING
data_tab = gt_upload[]
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
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Thanks,
Amol
‎2012 Mar 08 10:28 PM
I think you should go for LSMW for data load from legacy to SAP system. This is less programming and less time consuming (performance wise).
Transaction code: LSMW
For what object do you want to upload data?