cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload data from multiple sheets of excel file

Former Member
0 Kudos

Hi,

I want to upload data from multiple sheets of an excel file and get the data in different internal tables ( one internal table per ever sheet ).

I know how to read data from excel file with single sheet.

Any clue on how to do the same for a file with multiple sheets is highly appreciated.

Thanks,

Ajay

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184578
Active Contributor
0 Kudos

Hi.,

Check this wiki: http://wiki.sdn.sap.com/wiki/display/Snippets/ReadmultiplesheetsofanExcelfileintoSAPthroughABAP

hope this helps u.,

Thanks & Regards,

Kiran

Former Member
0 Kudos

Hi Kiran,

I want a similar approach for Webdynpro. I can't use GUI Front end services as they are not supported from WD framework.

THanks,

Ajay

former_member184578
Active Contributor
0 Kudos

Hi.,

GUI Front End Services are used for getting File Path., In Web Dynpro ABAP no need to use that You just use the File Upload UI., and it automatically give u the file path popup., You just use the logic there for getting data from multiple Sheets of excel

hope this helps u.,

Thanks & Regards,

Kiran

Former Member
0 Kudos

Hi Kiran,

I tried to simulate as per your wiki link.

I retrieved the file path from the File upload UI element.

I am getting a dump from



*CALLING THE CONTAINER TO SELECT THE EXCEL FILE
  CALL METHOD C_OI_CONTAINER_CONTROL_CREATOR=>GET_CONTAINER_CONTROL
    IMPORTING
      CONTROL = IREF_CONTROL
      ERROR   = IREF_ERROR.
  IF IREF_ERROR->HAS_FAILED = 'X'.
    CALL METHOD IREF_ERROR->RAISE_MESSAGE
      EXPORTING
        TYPE = 'E'.
  ENDIF.

as Get_container_control has code


      CALL FUNCTION 'GUI_HAS_ACTIVEX'
          IMPORTING
               return  = has_activex.

      CALL FUNCTION 'GUI_HAS_JAVABEANS'
          IMPORTING
               return  = has_javabean.

      IF ( NOT has_activex IS INITIAL ) OR
          ( NOT has_javabean IS INITIAL ).
        CREATE OBJECT olecontrolobj.
        control = olecontrolobj.
        retcode = c_oi_errors=>ret_ok.
      ELSE.
        retcode = c_oi_errors=>ret_error.
      ENDIF.

and both has_activex and has_javabean are initial, its giving a dump.

Is it dependant on the GUI services again?

Any clue on this is highly appreciated.

If not this approach, do we have any other approach to read multiple sheets data from excel in webdynpro ?

Regards,Ajay

former_member184578
Active Contributor
0 Kudos

Hi.,

Gui Container is for Custom Container.. No need of that.. and remember all started with GUI are all related to SAP GUI not web dynpro.. u need to mannually use that logic in your WDA.

Thanks & Regards,

Kiran

Former Member
0 Kudos

Hi Ajay,

You can use FILE_UPLOAD ui element. For multiple files use that may file upload ui elements.

DATA : conv TYPE REF TO CL_ABAP_CONV_IN_CE.
 
* Creates a Conversion Instance
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING
INPUT = <variable having the xstring data>
ENCODING = 'UTF-8'
REPLACEMENT = '?'
IGNORE_CERR = ABAP_TRUE
RECEIVING
CONV = conv.
 
conv2->READ( importing data =<string data> ).
SPLIT <string data> AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE <int table>.
 
LOOP AT <int_table> ASSIGNING <WA_TABLE>.
* splits string on basis of tabs
SPLIT <wa_TABLE> AT ',' INTO
str_itab-field1 str_itab-field2 str_itab-field3.
APPEND STR_ITAB TO ITAB.
ENDLOOP.                                     // now itab contains the data of csv file.

Cheers,

Kris.

Former Member
0 Kudos

Hi Kris,

Thanks for your reply.

I know the code you mentioned works fine with excel data with one sheet but what if the same file has multiple sheets?

My requirement is to read data from multiple sheets of the same excel file.

Regards,

Ajay

Former Member
0 Kudos

Hi,

Please check this..

Cheers,

Kris.

Former Member
0 Kudos

Hi Kris,

I went thru the thread you mentioned and it speaks about uploading multiple files.

But my problem is i have multiple sheets in one single excel file.

Regards,

Ajay