10-07-2007 9:15 AM
how to upload flat file data into sap table . before upload mapping is also there in some filds . any one can give me some steps how to upload and mapping . ?
10-07-2007 12:25 PM
Hi
See the sample code
REPORT zmmupload.
Internal Table for Upload Data
DATA: i_mara like MARA occurs 0 with header line
PARAMETERS: p_file LIKE ibipparms-path. " Filename
At selection-screen on Value Request for file Name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
Get the F4 Values for the File
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
Upload the File into internal Table
CALL FUNCTION 'UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT'
TABLES
data_tab = i_mara
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Upload the Data from Internal Table
MODIFY MARA from TABLE i_MARA.
Regards
Anji.
10-07-2007 9:31 AM
hi,
first prepare internal table with the flat file structure,
upload the flat file to internal table using gui_upload fm.
then use modify statemet to upload the data from internal table to sap table.
before that check the fields in internal table are existing in sap table.
regards
siva
10-07-2007 12:25 PM
Hi
See the sample code
REPORT zmmupload.
Internal Table for Upload Data
DATA: i_mara like MARA occurs 0 with header line
PARAMETERS: p_file LIKE ibipparms-path. " Filename
At selection-screen on Value Request for file Name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
Get the F4 Values for the File
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
Upload the File into internal Table
CALL FUNCTION 'UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT'
TABLES
data_tab = i_mara
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Upload the Data from Internal Table
MODIFY MARA from TABLE i_MARA.
Regards
Anji.
10-07-2007 9:12 PM
Hello Naveesh
If the data in your flat file are already organized like the DDIC structure you are using for upload then you can use SAP standard function modules or classes, e.g.:
- <b>TEXT_CONVERT_CSV_TO_SAP</b> (converts comma separated file to ABAP itab)
- <b>CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD</b> (for uploading TAB separated flat files)
Regards
Uwe
10-08-2007 6:59 AM
hi,
gui_upload or ws_upload can be used to upload data from a flat file into an internal table,
from there it can be copied into a database table.
sample code :
report zrm_guiupload.
data: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
call function 'GUI_UPLOAD'
exporting
filename = 'D:\PROGRAM FILES\SAPFILE1.TXT'
filetype = 'ASC'
tables
data_tab = it_datatab
exceptions
file_open_error = 1
others = 2.
loop at it_datatab.
write:/ it_datatab-row.
endloop.
10-08-2007 7:17 AM
hi
good
as far as mapping is concerned you do the mapping in LSMW not in BDC,In bdc you do the recording using the tcode SHDB and you use the GUI_UPLOAD function module to upload your flat file data into the table,.
go through this link for LSMW,.
http://www.sap-img.com/sap-data-migration.htm
thanks
mrutyun^