Application Development and Automation 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: 
Read only

uploading excel file

Former Member
0 Likes
789

hi experts,

i had an requirement to upload excel file data to bdc and i found an example but in that why we will use the type-pools truxs

and there r two records but while uploading it is showing only the second record

Edited by: k.vinu.karthik on Jun 25, 2010 11:07 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
762

Hi,

The example you have seen there the FM TEXT_CONVERT_XLS_TO_SAP is used to upload the data from excel file.

The type-pools truxs is used because, the type of export parameter of the FM is defined in the type-pools truxs.


  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*   I_FIELD_SEPERATOR          =
      i_line_header              = 'X'    " If your excel file has header then put X, otherwise leave blank
      i_tab_raw_data             = it_raw
      i_filename                 = p_v_file
    TABLES
      i_tab_converted_data       = p_it_data
 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.

You have passed value 'X' to parameter i_line_header, so the 1st line is not displaying.

Regards

DKS

4 REPLIES 4
Read only

Former Member
0 Likes
762

Hi,

try to use the FM ALSM_EXCEL_TO_INTERNAL_TABLE . This will transfer the data from excel file to an internal table ...which further u can use.

Thanks & regards,

Preetesh

Read only

OttoGold
Active Contributor
0 Likes
762

Check the FM mentioned in the blog: /people/otto.gold/blog/2010/06/23/happy-reporting-with-excel-iii-there-and-back

FUNCTION text_convert_xls_to_sap.

Otto

Read only

Former Member
0 Likes
763

Hi,

The example you have seen there the FM TEXT_CONVERT_XLS_TO_SAP is used to upload the data from excel file.

The type-pools truxs is used because, the type of export parameter of the FM is defined in the type-pools truxs.


  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*   I_FIELD_SEPERATOR          =
      i_line_header              = 'X'    " If your excel file has header then put X, otherwise leave blank
      i_tab_raw_data             = it_raw
      i_filename                 = p_v_file
    TABLES
      i_tab_converted_data       = p_it_data
 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.

You have passed value 'X' to parameter i_line_header, so the 1st line is not displaying.

Regards

DKS

Read only

Noorie
Active Participant
0 Likes
762

Hi,

There are may function modules for load data from Excel to SAP internal table.

few of them are

1. 'TEXT_CONVERT_XLS_TO_SAP'.

2. ALSM_EXCEL_TO_INTERNAL_TABLE,

3. GUI_UPLOAD with delimited as tab.

sample code:

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

  • EXPORTING

  • FILENAME = P_FILE

  • I_BEGIN_COL = '1'

  • I_BEGIN_ROW = '3'

  • I_END_COL = '300'

  • I_END_ROW = '5000'

  • TABLES

  • INTERN = EXCL

  • EXCEPTIONS

  • INCONSISTENT_PARAMETERS = 1

  • UPLOAD_OLE = 2

  • OTHERS = 3.

LOOP AT EXCL.

  • CASE EXCL-COL.

  • WHEN '0001'.

  • WA_MAIN-MATNR = EXCL-VALUE.

*

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

  • EXPORTING

  • INPUT = WA_MAIN-MATNR

  • IMPORTING

  • OUTPUT = WA_MAIN-MATNR.

*

  • WHEN '0002'.

  • WA_MAIN-AENNR = EXCL-VALUE.

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

  • EXPORTING

  • INPUT = WA_MAIN-AENNR

  • IMPORTING

  • OUTPUT = WA_MAIN-AENNR.

  • WHEN '0003'.

  • WA_MAIN-WERKS = EXCL-VALUE.

  • WHEN '0004'.

  • WA_MAIN-VERID = EXCL-VALUE.

  • WHEN '0005'.

  • WA_MAIN-TEXT1 = EXCL-VALUE.

  • WHEN '0006'.

  • WA_MAIN-ADATU = EXCL-VALUE.

  • WHEN '0007'.

  • WA_MAIN-BDATU = EXCL-VALUE.

  • WHEN '0008'.

  • WA_MAIN-PLNTY = EXCL-VALUE.

  • WHEN '0009'.

  • WA_MAIN-PLNNR = EXCL-VALUE.

  • WHEN '0010'.

  • WA_MAIN-ALNAL = EXCL-VALUE.

  • WHEN '0011'.

  • WA_MAIN-STLAL = EXCL-VALUE.

  • WHEN '0012'.

  • WA_MAIN-STLAN = EXCL-VALUE.

  • ENDCASE.

*

  • AT END OF ROW.

  • APPEND WA_MAIN TO IT_MAIN.

  • CLEAR : WA_MAIN.

  • ENDAT.

  • ENDLOOP.