Skip to Content

How to read excel data into internal table in sap crm

Hi Friends,

We are working on a program where in we need to read the data from an excel file into an internal table. I have written the below code and is not working. Not sure what is missing in this piece of code.

Any pointers on this would be of great help. I tried checking with Filetype values 'asc','DAT'..

The function module ALSM_EXCEL_TO_INTERNAL_TABLE is not available in CRM.

Thanks,

Udaya

EPORT  ZTESTUDAY6.
TYPES : BEGIN OF gs_upload,                                                 " Structure to store the record from a text file
          title          TYPE string,
          first_name     TYPE string,

        END OF gs_upload.
data  lv_tab  ."#EC *
data lt_gs_upload                 TYPE   STANDARD TABLE OF gs_upload.
lv_tab = cl_abap_char_utilities=>horizontal_tab.

  CALL METHOD cl_gui_frontend_services=>gui_upload
  EXPORTING
    FILENAME                      = 'C:\Users\udayabhaskar_p\Desktop\t1.xls'
    FILETYPE                      = 'DAT'
*   HAS_FIELD_SEPARATOR           = LV_TAB
**   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   CHECK_BOM                     = ' '
*   VIRUS_SCAN_PROFILE            =
*   NO_AUTH_CHECK                 = ' '
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
 CHANGING
      data_tab                = lt_gs_upload.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Jul 07, 2010 at 11:42 AM

    Hi Udaya

    You should save your excel file as a tab-delimited text file first,

    use Save As > Text (Tab Delimited) option of microsoft excel.

    Than declare your internal table with the same columns as excel in your abap program.

    Now u can upload from this tab-delimited file with method

    cl_gui_frontend_services=>gui_upload or the function 'WS_UPLOAD'.

    Beware of filetype parameter sould be set to 'DAT'

    Let me know encounter a problem.

    Hi hope it helps.

    Bulent

    Edited by: Bulent Balci on Jul 7, 2010 1:42 PM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Udaya Bhaskar Perecharla

      Use the above FM : ALSM_EXCEL_TO_INTERNAL_TABLE will directly pass the xlsx data to the internal table defined .

      make sure the sequence of the fields given in the excel and the internal table declared are same .

      Please make sure the excel fiel is having correct format character and number should be properly maintained....!!!

      Regards

      Swapnil

  • Posted on Jul 07, 2010 at 08:56 AM

    Hi,

    Use this Function Module TEXT_CONVERT_XLS_TO_SAP

    to update the Excel sheet value into an Internal Table.

    If you give the I_LINE_HEADER = 'X' it will not read the first line in the excel sheet.

    Hope this might solve your Problem.

    With Regards,

    Sumodh.P

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 22, 2011 at 02:57 AM

    HI Udaya,

    Did u get any solution to your problem? I also have a similar requirement in CRM.

    Kindly give the solution if you have.

    Thanks & Regards

    Gopal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 09, 2013 at 02:18 PM

    Hi,

    Try the code snippet from the below link. It will help you to upload excel file(*.xsl) into SAP CRM.

    Its working fine, customize it as you need.

    http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP+-+Upload+data+from+Excel+to+Sap+using+OO

    Thank you.

    Regards,

    Swadini Sujanaranjan.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Udaya Bhaskar Perecharla


      Hi Bhaskar,

      I also have a similar requirement in CRM, I have to upload excel file to cancel near 3000 sales orders in crm for crmd_order.

      Did u get any solution to your problem?

      Kindly share your valuable suggestions.

      Thanks & Regards

      Rajasekhar S

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.