Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Import Excel multiple worksheets to Internal tables

Former Member
0 Kudos

I am running SAP CRM ABAP 6.0 and I need to provide a program for uploading a spreadsheet with multiple worksheets into CRM.

SAP being SAP does not provide the same function modules in CRM as are available in ECC...

I am over the initial hurdle using F4_DXFILENAME_TOPRECURSION to load the file from either the presentation server or application server...

however, none of the standard FMs are available to convert the spreadsheet into internal tables...

I wonder if anyone has successfully done this and can point me to another function module!

I did try and recreate the TEXT_CONVERT_XLS_TO_SAP but was unsuccessful due to missing type pools.....

9 REPLIES 9

Former Member
0 Kudos

Hi,

Use this FM...

ALSM_EXCEL_TO_INTERNAL_TABLE

Regards

Kiran

0 Kudos

Kiran,

Is it possible to upload multiple worksheets in an excel sheet using ALSM_EXCEL.......,if so what are the parameters that needs to be passed to select the worksheets in an excel.

Thanks,

K.Kiran.

0 Kudos

Thank you for your prompt response, however this FM is not available within CRM.

0 Kudos

hi,

For your requirement try out the following function module.

data:
it_text TYPE truxs_t_text_data .


AT SELECTION-SCREEN  ON VALUE-REQUEST FOR p_file.
  CALL FUNCTION 'F4_FILENAME'
   EXPORTING
     program_name        = syst-cprog
*   DYNPRO_NUMBER       = SYST-DYNNR
     field_name          = ' '
   IMPORTING
     file_name           = p_file.

START-OF-SELECTION.

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*   I_FIELD_SEPERATOR          =
*   I_LINE_HEADER              =
      i_tab_raw_data             = it_text
      i_filename                 = p_file
    TABLES
      i_tab_converted_data       = t_cust
  EXCEPTIONS
    conversion_failed          = 1
    OTHERS                     = 2
           .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

Thanks

Sharath

Former Member
0 Kudos

Hi Barry,

For the function module you are using:

TEXT_CONVERT_XLS_TO_SAP

Try using type pool: TRUXS.

it wont give error type pool missing.

Hope it helps

Regrds

Mansi

Former Member
0 Kudos

Thanks everyone, but I am using CRM 6.0. Not ECC.

These function modules are not available in CRM!

0 Kudos

hi,

For more information about Excel to CRM check this link, it might be helpful for your purpose.

[Excel to CRM|;

Thanks

Sharath

0 Kudos

Thanks, but I know what I need to do once I have the data into SAP, it is just getting into SAP and converting it that I am a struggling with!

0 Kudos

Maybe not pretty, but works for me!

TYPES: BEGIN OF T_UPLOAD_DATA,
            DATA TYPE CHAR16384,
           END OF T_UPLOAD_DATA.

  DATA: LT_UPLOAD_DATA TYPE STANDARD TABLE OF T_UPLOAD_DATA,
        LS_UPLOAD_DATA LIKE LINE OF LT_UPLOAD_DATA.

 DATA : LT_FILE_TABLE TYPE FILETABLE,
         LV_RC TYPE I.

  DATA: LV_FILENAME TYPE STRING.


 CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
    CHANGING
      FILE_TABLE              = LT_FILE_TABLE
      RC                      = LV_RC
    EXCEPTIONS
      FILE_OPEN_DIALOG_FAILED = 1
      CNTL_ERROR              = 2
      ERROR_NO_GUI            = 3
      NOT_SUPPORTED_BY_GUI    = 4
      OTHERS                  = 5.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  READ TABLE LT_FILE_TABLE INTO LV_FILENAME INDEX 1.



  CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
    EXPORTING
      FILENAME                = LV_FILENAME
      FILETYPE                = 'DAT'
      HAS_FIELD_SEPARATOR     = ','
      HEADER_LENGTH           = 0
      READ_BY_LINE            = 'X'
    CHANGING
      DATA_TAB                = LT_UPLOAD_DATA
    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
      NOT_SUPPORTED_BY_GUI    = 17
      ERROR_NO_GUI            = 18
      OTHERS                  = 19.