cancel
Showing results for 
Search instead for 
Did you mean: 

uploading from .xls to wd..

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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^

former_member194099
Active Participant
0 Kudos

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

Former Member
0 Kudos

Thnx sagar,

please tell me how do i do this xstring conversion?As i get the data from file upload uielement in a string how do i get it into an xstring?

thnx...

Vinit.B.Mehta

thomas_szcs
Active Contributor
0 Kudos

Hi Vinit,

Just type the context attribute as xstring instead as string.

Best regards,

Thomas

Former Member
0 Kudos

Thnx...i know that actually i wanted to ask that how do i convert xstring to string?

former_member194099
Active Participant
0 Kudos

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

Former Member
0 Kudos

Hie sagar,

i m still working on .xls upload in wd abap.I m stuck up between converting the data from xstring format to csv version and how to convert it to string???A piece of code if any would be a great help...

thnx...

Vinit.B.Mehta

mohammed_anzys
Contributor
0 Kudos

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.

Former Member
0 Kudos

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

mohammed_anzys
Contributor
0 Kudos

You could use HR_RU_CONVERT_HEX_TO_STRING function module.

Thanks

Anzy

Former Member
0 Kudos

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

mohammed_anzys
Contributor
0 Kudos

Hi,

You could take the data in a variable of type xstring and put the data into a table which has an attribute RAW .correct me if i am wrong.

Thanks

Anzy

mohammed_anzys
Contributor
0 Kudos

Hi

DATA: MYFILE TYPE RAWSTRING.

In database the atrribute is RAWSTRING.

Chekc this way

Thanks

Anzy