cancel
Showing results for 
Search instead for 
Did you mean: 

Excel upload in WD Abap

former_member194099
Active Participant
0 Kudos

Hi Colleages,

Is it possible to upload an excel file through WD ABAP?

The file upload control gives the data in XSTRING format and probably would not be of much help. What I need is the excel data uploaded to my internal table.

Also I tried using the CL_GUI_FRONTEND_SERVICES inside my action but it does not work.

Suggest any way for this.

Accepted Solutions (0)

Answers (4)

Answers (4)

0 Kudos

Hi Sagar,

If you want to upload an excel file and store the information in an internal table, then

do not use file upload control.Instead use a simple button and in its action handler call

"CL_GUI_FRONTEND_SERVICES" methods to show an file open dialog and also store the returning filename and its path in context attribute of type string.

Then you can call GUI_UPLOAD method of the same calss and pass the file name and path as mentioned by "Vijay" in his reply to store it in an internal table.

Thanks,

G.Jayaprakash

former_member194099
Active Participant
0 Kudos

Hi,

I think it will not work.

Please see the following thread for details:

Regards

Sagar

Former Member
0 Kudos

Hie sagar,even i have a similar task that you had.I need to upload the .xls file to the database in wdabap.I have done a similar program in abap by transfering data into an internal table and then into the database.But i dont know how to go about it. Can you please suggest me how do i go about it??

thnx and regards...

Vinit.B.Mehta

Former Member
0 Kudos

Hi Sagar,

Yesterday I tried the same with GUI_UPLOAD. Here i am putting the code will help you about my logic.

Logic:

I create 2 internal table IT_OIR0DTFKGOILAMEX & IT_OIR0DTFKGOILAMEX1.

---> Population information into internal table IT_OIR0DTFKGOILAMEX and download to file C:\TEST4.XLS.

---> Upload the same file into another internal table IT_OIR0DTFKGOILAMEX1.

---> you can check in the debug mode how the data is transferring

Here I am putting the code as follows:

DATA: IT_OIR0DTFKGOILAMEX TYPE TABLE OF alv_t_t2,      " OIR0DTFKGOILAMEX,
IT_OIR0DTFKGOILAMEX1 TYPE TABLE OF alv_t_t2. " OIR0DTFKGOILAMEX." OCCURS 0.

SELECT * FROM sflight INTO corresponding fields of table IT_OIR0DTFKGOILAMEX.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME                        = 'C:TEST4.xls'
    FILETYPE                        = 'ASC'
    WRITE_FIELD_SEPARATOR           = 'X'
  TABLES
    DATA_TAB                        = IT_OIR0DTFKGOILAMEX
IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Refresh IT_OIR0DTFKGOILAMEX1[].

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.

Warm Regards,

Vijay

Former Member
0 Kudos

Hi Sagar,

Check out for the following link:

If you are using the FileUpload element of WDA then you cannot access the GUI services of ABAP. The data in the file you upload will be available in XSTRING format in the 'data' property of the FileUpload element & the corresponding file name in the fileName property of the same.

Bind it to a context attribute of type XSTRING to get the data in the WD Component.

Also, You can have a look at WDR_TEST_EVENTS example application for this UI element.

Hope this will help you.

Cheers,

Darshna.