on 05-30-2007 12:27 PM
Hie friends,
I want to upload data from a .xls file to the data base.I have tried similar in normal abap where we took the data in an internal table and from there into the main database.wil it work the same way here as well??
i hav a sample code as well..
will dis work??
please tell me wat should i do..
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\TEST4.xls'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
READ_BY_LINE = 'X'
TABLES
DATA_TAB = IT_OIR0DTFKGOILAMEX1
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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
hi
good
you can't directly pass the xls file as a parameter in the filename,here you have to save the same excel sheet data into a text file with table delimited and than you use the GUI_UPLOAD to upload your data in to the database table,.
thanks
mrutyun^
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
The GUI_UPLOAD is based on CL_GUI_FRONTEND_SERVICES and currently it checks for SAPGUI with no support for WD. Hence it dumps with "Exception condition "CNTL_ERROR" raised".
So somehow XSTRING conversion has to be done as mentioned by me previously. I guess it is just workaround.
Regards
Sagar
HI Vinit,
GUI_UPLOAD function module uses CL_GUI_FRONTEND_SERVICES and it cannot be used to upload files in WebDynpro abap directly.
In WebDynpro ABAP you can use the "File Upload" UI element to upload a file.
This UI element has properties fileName and data. After upload fileName will contain the exact path of the file uploaded. The data will contain the filedata but in XSTRING format. XSTRING can be easily converted to XML if the uploaded file is XML. To use same technique for excel is difficult.
As a workaround I uploaded the CSV version of excel file using this control. Then converted the XSTRING data to STRING and then extracted the data to internal table. Columns of excel are separated by comma and rows by newline.
Hope this helps you.
With Regards
Sagar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
You could use the following code to covert xstring to string.....please correct the sysntax errors.
Thanks
Anzy
IN type XSTRING
OUT type string
CONVRT TYPE REF TO CL_ABAP_CONV_IN_CE
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING INPUT = IN
ENCODING = 'UTF-8'
REPLACEMENT = '?'
IGNORE_CERR = ABAP_TRUE
RECEIVING CONV =CONVRT.
TRY.
CALL METHOD CONVRT->READ
IMPORTING
DATA = OUT.
CATCH CX_SY_CONVERSION_CODEPAGE.
ENDTRY.
hie,thnx for the code.I used the code but the data is coming in hexadeciml form in the structure from the xl file.I need to upload the .xls file to the main database table.Please help me out if you have done somethng similar or u kno any standard program which is similar to this one.
thnx..
Vinit.Mehta
Hey thnx for the reply...i m getting the file name in a proper string format,like i m getting a proper file path.But the file content is not being displayed properly even after the hexadeciml to string format....also i would like to append the data into an internal table and from there into the main database table....do u have ne idea how do i go about it???
thnx and regards...
Vinit.B.Mehta
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.