2005 Nov 24 10:50 AM
Dear friends,
I'm trying to upload DBF file.
I can easily convert DBF to CSV in excel and upload the CSV file by standard FM. But client wants to upload directly from DBF, no conversion in between.
I resoted to following techniques:-
1. Tried WS_UPLOAD, UPLOAD, GUI_UPLOAD without any successful results.
2. Convert DBF to DAT using include ole2incl but no conversion happening.
The above mentioned ways were of no help. Please suggest a way to crack this problem.
Regards,
Deva Jyothi Singh.
Dear friends,
I'm trying to upload DBF file.
I can easily convert DBF to CSV in excel and upload the CSV file by standard FM. But client wants to upload directly from DBF, no conversion in between.
I resoted to following techniques:-
1. Tried WS_UPLOAD, UPLOAD, GUI_UPLOAD without any successful results.
2. Convert DBF to DAT using include ole2incl but no conversion happening.
The above mentioned ways were of no help. Please suggest a way to crack this problem.
Regards,
Deva Jyothi Singh.
2005 Nov 24 10:57 AM
2005 Nov 24 11:08 AM
Hi Andreas,
Thanx friend. But the static method GUI_UPLOAD of class CL_GUI_FRONTEND_SERVICES uses GUI_UPLOAD FM only.
Regards,
Deva.
2005 Nov 25 7:53 AM
Hi,
RSUT_TABLE_TO_TEXT_FORMAT
Check this FM. I think it may be helpful as there is a parameter I_FORMAT DEFAULT 'ASC'
here i think u can specify the format which you want
2005 Nov 25 11:52 AM
Hi Lavanya,
The FM RSUT_TABLE_TO_TEXT_FORMAT works for converting an ITAB to CSV text. It doesn't convert my local DBF file to CSV.
Thanx for replying.
Regards,
Deva.
2013 Jun 21 11:00 AM
hi,
direct conversion is not possible bec at some level size will issue .
2005 Nov 25 8:05 AM
Hi Deva Jyothi Singh,
Try the below code...
This form does is: opens .dbf in Excel,saves it as .dat file ,uploads .dat file into internal table,deletes .dat file.
&----
*& Form load_dbf_file
&----
text
----
--> p1 text
<-- p2 text
----
FORM load_dbf_file TABLES input_table
USING value(t_filename) LIKE rlgrap-filename.
DATA: application TYPE ole2_object,
workbooks TYPE ole2_object,
fworkbook TYPE ole2_object,
fsheets TYPE ole2_object,
fsheet TYPE ole2_object,
dsheet TYPE ole2_object,
frange TYPE ole2_object,
frow TYPE ole2_object.
DATA: return,
filename(128) TYPE c,
l_filename TYPE string.
Filename conversion
MOVE t_filename TO filename.
TRANSLATE t_filename TO UPPER CASE.
REPLACE '.DBF' WITH '.DAT' INTO t_filename.
IF sy-subrc NE 0.
error - filename extension is not DBF "TODO
MESSAGE w899(f5) WITH 'Error - filename extension is not DBF'.
EXIT.
ENDIF.
check file existence
CALL FUNCTION 'WS_QUERY'
EXPORTING
filename = filename
query = 'FE'
IMPORTING
return = return
EXCEPTIONS
inv_query = 1
no_batch = 2
frontend_error = 3
OTHERS = 4.
IF ( sy-subrc NE 0 ) OR ( return EQ 0 ).
error - file does not exist "TODO
MESSAGE w899(f5) WITH 'Error - file does not exist'.
EXIT.
ENDIF.
Working through OLE (MS Excel) *****
OLE initialization
CREATE OBJECT dsheet 'Excel.Sheet'.
IF sy-subrc NE 0.
error - OLE initialization of MS Excel "TODO
MESSAGE e899(f5) WITH 'Error - OLE initialization of MS Excel'.
EXIT.
ENDIF.
supress messages from MS Excel
CALL METHOD OF dsheet 'Application' = application.
SET PROPERTY OF application 'DisplayAlerts' = 0.
opening DBF-file
CALL METHOD OF application 'Workbooks' = workbooks.
CALL METHOD OF workbooks 'Open' EXPORTING #1 = filename
#2 = 0
#3 = 1.
remove header line from DBF data
GET PROPERTY OF application 'ActiveWorkbook' = fworkbook.
CALL METHOD OF fworkbook 'Sheets' = fsheets.
CALL METHOD OF fsheets 'Item' = fsheet EXPORTING #1 = 1.
GET PROPERTY OF fsheet 'Rows' = frange.
CALL METHOD OF frange 'Item' = frow EXPORTING #1 = 1.
CALL METHOD OF frow 'Delete'.
save as DAT file
CALL METHOD OF fworkbook 'SaveAs' EXPORTING #1 = t_filename
#2 = 20.
close the book without saving
CALL METHOD OF fworkbook 'Close' EXPORTING #1 = 0.
очистка ссылки на OLE-объект
FREE OBJECT dsheet.
Filling internal table with data *****
REFRESH input_table.
l_filename = t_filename.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_filename
has_field_separator = 'X'
TABLES
data_tab = input_table
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 NE 0.
error - loading DAT file "TODO
MESSAGE w899(f5) WITH 'Error - loading DAT file'.
EXIT.
ELSE.
the loading was successfull "TODO
ENDIF.
Delete temporary DAT-file *****
CALL FUNCTION 'GUI_DELETE_FILE'
EXPORTING
file_name = t_filename
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
CALL FUNCTION 'WS_QUERY'
EXPORTING
filename = t_filename
query = 'FE'
IMPORTING
return = return
EXCEPTIONS
inv_query = 1
no_batch = 2
frontend_error = 3
OTHERS = 4.
IF ( sy-subrc NE 0 ) OR ( return EQ 0 ).
EXIT.
ELSE.
error - deleting temporary file "TODO
ENDIF.
ENDIF.
ENDFORM. " load_dbf_file
You can even try this...Foxpro can be output in comma delimetered mode, so why not use it ?
There's a standard foxpro (DBF) export tool for this.
Regards,
Raj
2005 Nov 25 11:53 AM
Hi Raj,
Thanx. I tried this set of code which was earlier posted in SDN. But it doesn't seem to work.
Regards,
Deva.
2007 Mar 22 11:57 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |