Uploading data from excel sheets through BDC's into sap system

hi guys,
can you please help me with this. As we use gui_upload to upload data from flat file to sap system, which function module you use to upload data from Excel sheet to sap system through bdc's

hello pavan,
welcome to SDN
check the below program
REPORT ZEXCEL_TO_INTERNAL .
data: begin of itab occurs 0,
      name(20) type c,
      addre(20) type c,
      end of itab.
DATA : ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
DATA : B1 TYPE I VALUE 1,
       C1 TYPE I VALUE 1,
       B2 TYPE I VALUE 100,
       C2 TYPE I VALUE 9999.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    FILENAME                   =
    'C:\Documents and Settings\administrator\Desktop\ppcon001bd_24.xls'
    I_BEGIN_COL                   = B1
    I_BEGIN_ROW                   = C1
    I_END_COL                     = B2
    I_END_ROW                     = C2
  TABLES
    INTERN                        = itab1
EXCEPTIONS
   INCONSISTENT_PARAMETERS       = 1
   UPLOAD_OLE                    = 2
   OTHERS                        = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at itab1.
write:/ itab1.
Endlop.
Regards,
Naveen

Similar Messages

  • Upload data in excel sheet through BDC

    Dear all,
    How do we upload data in excel sheet through BDC?
    Thanks in advance.
    Regards,
    Sandra.

    Hi,
         The sample code is as given below:
    REPORT  upload_supply_area.
    *include for dispaying icons in error log
    INCLUDE <icon>.
    *Declaration of structure.
    TYPES:BEGIN OF x_struct,
          werks TYPE v_pvbe-werks,          "Plant
          prvbe TYPE v_pvbe-prvbe,          "Supply Area
          pvbtx TYPE v_pvbe-pvbtx,          "Production supply area description
          lgort TYPE v_pvbe-lgort,          "Storage Location
          rgver TYPE v_pvbe-rgver,          "Person responsible for one or more supply areas
          END OF x_struct.
    TYPES:BEGIN OF x_messages,
           msgtyp(1) type c,
           werks TYPE v_pvbe-werks,          "Plant
           prvbe TYPE v_pvbe-prvbe,          "Supply Area
           message(120) type c,
           END OF x_messages.
    DATA: it_messages  TYPE STANDARD TABLE OF x_messages .
    DATA: wa_messages TYPE x_messages.
    DATA:it_msgtab TYPE STANDARD TABLE OF bdcmsgcoll,
         wa_msgtab TYPE bdcmsgcoll.
    *internal table for BDC
    DATA: it_bdcdata TYPE STANDARD TABLE OF bdcdata.
    DATA: wa_bdcdata TYPE bdcdata.
    DATA:it_file TYPE STANDARD TABLE OF x_struct.        "internal table which has same structure as file
    DATA:wa_file TYPE x_struct.                          "work area which has same structure as file
    DATA: it_excel TYPE STANDARD TABLE OF alsmex_tabline,
          wa_excel TYPE alsmex_tabline.
    DATA: x_ctuprms TYPE ctu_params.
    DATA:nodata TYPE c VALUE '/'.
    data:con(50) type c.
    data:con1(50) type c.
    *selection screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    *Enter file name on presentation server
    PARAMETERS:  p_file TYPE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    *Function which enables the user to browse the files on hard disk
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          program_name  = syst-repid
          static        = 'X'
        CHANGING
          file_name     = p_file
        EXCEPTIONS
          mask_too_long = 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.
    START-OF-SELECTION.
    *Subroutine to upload excel file and read it
      PERFORM upload.
    *Subroutine to upload supply area data
      PERFORM fill.
    *&      Form  bdc_dynpro
          Fill the BDC table
    FORM bdc_dynpro USING program dynpro.                       "#EC *
      CLEAR wa_bdcdata.
      wa_bdcdata-program  = program.
      wa_bdcdata-dynpro   = dynpro.
      wa_bdcdata-dynbegin = 'X'.
      APPEND wa_bdcdata TO it_bdcdata.
    ENDFORM.                    "BDC_DYNPRO
    *&      Form  bdc_field
           Fill the BDC table
    FORM bdc_field USING fnam fval.                             "#EC *
      IF fval <> nodata.
        CLEAR wa_bdcdata.
        wa_bdcdata-fnam = fnam.
        wa_bdcdata-fval = fval.
        APPEND wa_bdcdata TO it_bdcdata.                        "#EC
      ENDIF.
    ENDFORM.                    "BDC_FIELD
    *&      Form  collect_messages
          Collect the messages from transaction
    FORM collect_messages .                                     "#EC *
      DATA: w_msg(100).
      LOOP AT it_msgtab INTO wa_msgtab.
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            id        = wa_msgtab-msgid
            lang      = wa_msgtab-msgspra
            no        = wa_msgtab-msgnr
            v1        = wa_msgtab-msgv1
            v2        = wa_msgtab-msgv2
          IMPORTING
            msg       = w_msg
          EXCEPTIONS
            not_found = 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.
        CONDENSE w_msg.
        CLEAR wa_messages.
        wa_messages-msgtyp = wa_msgtab-msgtyp.
        wa_messages-message = w_msg.
        wa_messages-werks = wa_file-werks.
        wa_messages-prvbe = wa_file-prvbe.
    if wa_messages-message eq 'Formatting error in the field V_PVBE-RGVER; see next message'.
    wa_messages-message = 'Invalid name of the person responsible'.
    endif.
    if wa_messages-message eq 'Formatting error in the field V_PVBE-LGORT; see next message'.
    wa_messages-message = 'Enter the storage location'.
    endif.
        APPEND wa_messages TO it_messages .
      ENDLOOP.
      REFRESH it_msgtab.
    ENDFORM.                    "collect_messages
    *&      Form  write_messages
          Display the messages
    FORM write_messages .
      DELETE ADJACENT DUPLICATES FROM it_messages COMPARING werks prvbe.
      LOOP AT it_messages INTO wa_messages .
        WRITE:/1 sy-vline.
        IF wa_messages-msgtyp = 'S'.
          WRITE: 10 icon_green_light.
        ELSEIF wa_messages-msgtyp = 'E'.
          WRITE: 10 icon_red_light.
        ELSEIF wa_messages-msgtyp = 'W'.
          WRITE: 10 icon_yellow_light.
        ENDIF.
        WRITE: 20 sy-vline.
        WRITE : 30 'Plant-', wa_messages-werks .                "#EC NOTEXT
        WRITE: 48 sy-vline.
        WRITE : 49 'Supply Area-', wa_messages-prvbe .          "#EC NOTEXT
        WRITE: 79 sy-vline.
        WRITE : 80 wa_messages-message .
        WRITE: 180 sy-vline.
        WRITE:/1 sy-vline.
        ULINE 1(180).
      ENDLOOP.
    ENDFORM.                    " write_m
    *&      Form  fill_params
          Processing mode for the transaction
    FORM fill_params .
      x_ctuprms-dismode = 'N'.
      x_ctuprms-updmode = 'A'.
      x_ctuprms-defsize = 'X'.
    ENDFORM.                    "fill_params
    *&      Form  upload
          Upload the excel file and read the data
    FORM upload .
    *Function to upload excel file
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = 1
          i_begin_row             = 2
          i_end_col               = 5
          i_end_row               = 9999
        TABLES
          intern                  = it_excel
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CLEAR wa_file.
    *Read the file row-wise
      LOOP AT it_excel INTO wa_excel.
        CASE wa_excel-col .
    *Read plant
          WHEN '1'.
            wa_file-werks = wa_excel-value.
    *Read supply area
          WHEN '2'.
            wa_file-prvbe = wa_excel-value.
    *Read decription
          WHEN '3'.
            wa_file-pvbtx = wa_excel-value.
    *Read storage location
          WHEN '4'.
            wa_file-lgort = wa_excel-value.
    *Read Person responsible
          WHEN '5'.
            IF STRLEN( wa_excel-value ) = 1.
              CONCATENATE '00' wa_excel-value INTO con.
              wa_file-rgver = con.
            ELSEIF STRLEN( wa_excel-value ) = 2.
              CONCATENATE '0' wa_excel-value INTO con1.
              wa_file-rgver = con1.
            ELSE.
              wa_file-rgver = wa_excel-value.
            ENDIF.
        ENDCASE.
        AT END OF row.
          CONDENSE:wa_file-werks,wa_file-prvbe,wa_file-pvbtx,wa_file-lgort,wa_file-rgver.
          APPEND wa_file TO it_file.
          CLEAR wa_file.
        ENDAT .
      ENDLOOP.
    ENDFORM.                    " upload
    *&      Form  fill
          Call the transaction 'PK05'
    FORM fill .
    *Upload the data through transaction 'PK05'
      PERFORM fill_params.
      LOOP AT it_file INTO wa_file.
        PERFORM bdc_dynpro      USING 'SAPLSVIX' '0100'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'D0100_FIELD_TAB-LOWER_LIMIT(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=OKAY'.
        PERFORM bdc_dynpro      USING 'SAPL0PK1' '0020'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'V_PVBE-PVBTX(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=NEWL'.
        PERFORM bdc_dynpro      USING 'SAPL0PK1' '0021'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'V_PVBE-RGVER'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'V_PVBE-WERKS'
                                      wa_file-werks.
        PERFORM bdc_field       USING 'V_PVBE-PRVBE'
                                      wa_file-prvbe.
        PERFORM bdc_field       USING 'V_PVBE-PVBTX'
                                      wa_file-pvbtx.
        PERFORM bdc_field       USING 'V_PVBE-LGORT'
                                      wa_file-lgort.
        PERFORM bdc_field       USING 'V_PVBE-RGVER'
                                      wa_file-rgver.
        PERFORM bdc_dynpro      USING 'SAPL0PK1' '0021'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'V_PVBE-WERKS'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=SAVE'.
        PERFORM bdc_field       USING 'V_PVBE-WERKS'
                                      wa_file-werks.
        PERFORM bdc_field       USING 'V_PVBE-PRVBE'
                                      wa_file-prvbe.
        PERFORM bdc_field       USING 'V_PVBE-PVBTX'
                                      wa_file-pvbtx.
        PERFORM bdc_field       USING 'V_PVBE-LGORT'
                                      wa_file-lgort.
        PERFORM bdc_field       USING 'V_PVBE-RGVER'
                                      wa_file-rgver.
        CALL TRANSACTION 'PK05'
                           USING it_bdcdata
                           OPTIONS FROM x_ctuprms
                           MESSAGES INTO it_msgtab.
        REFRESH it_bdcdata.
        PERFORM collect_messages.
        CLEAR wa_file.
      ENDLOOP.
      PERFORM write_messages.
    ENDFORM.                    " fill

  • How to upload datas in excel sheet through BDC

    Hi,
        I know how to upload datas in Text format  through BDC...Suppose even when datas are in .xls format,I saved that file as Text(tab delimited) format...then file become text format and it can be easily uploaded....
        So, I want to know How to upload datas in excel sheet through BDC

    hi,
    try this Example, hope useful to u, assign me point.
    report ZMSV1_BDC_CALL
           no standard page heading line-size 255.
    *include bdcrecx1.
    *parameters: dataset(132) lower case.
       DO NOT CHANGE - the generated data section - DO NOT CHANGE    ***
      If it is nessesary to change the data section use the rules:
      1.) Each definition of a field exists of two lines
      2.) The first line shows exactly the comment
          '* data element: ' followed with the data element
          which describes the field.
          If you don't have a data element use the
          comment without a data element name
      3.) The second line shows the fieldname of the
          structure, the fieldname must consist of
          a fieldname and optional the character '_' and
          three numbers and the field length in brackets
      4.) Each field must be type C.
    Generated data section with specific formatting - DO NOT CHANGE  ***
    data: begin of record,
    data element: BUKRS
            BUKRS_001(004),
    data element: KTOKK
            KTOKK_002(004),
    data element: NAME1_GP
            NAME1_003(035),
    data element: SORTL
            SORTL_004(010),
    data element: ORT01_GP
            ORT01_005(035),
    data element: LAND1_GP
            LAND1_006(003),
    data element: SPRAS
            SPRAS_007(002),
    data element: BANKS
            BANKS_01_008(003),
    data element: BANKK
            BANKL_01_009(015),
    data element: BANKN
            BANKN_01_010(018),
          end of record.
    End generated data section ***
    data: itab like record occurs 0 .
    data: it_bdc type bdcdata occurs 0 with header line.
    data: it_msg type bdcmsgcoll occurs 0 with header line.
    parameter p_file type rlgrap-filename default 'c:\vendor.txt' obligatory
    start-of-selection.
    perform open_dataset using p_file.
    perform open_group.
    *perform close_group.
    *perform close_dataset using dataset.
    *&      Form  open_dataset
          text
         -->P_P_FILE  text
    form open_dataset  using    p_p_file.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
      CODEPAGE                      = ' '
      FILENAME                      = p_file
      FILETYPE                      = 'DAT'
      HEADLEN                       = ' '
      LINE_EXIT                     = ' '
      TRUNCLEN                      = ' '
      USER_FORM                     = ' '
      USER_PROG                     = ' '
      DAT_D_FORMAT                  = ' '
    IMPORTING
      FILELENGTH                    =
      TABLES
        data_tab                      = itab
    EXCEPTIONS
      CONVERSION_ERROR              = 1
      FILE_OPEN_ERROR               = 2
      FILE_READ_ERROR               = 3
      INVALID_TYPE                  = 4
      NO_BATCH                      = 5
      UNKNOWN_ERROR                 = 6
      INVALID_TABLE_WIDTH           = 7
      GUI_REFUSE_FILETRANSFER       = 8
      CUSTOMER_ERROR                = 9
      NO_AUTHORITY                  = 10
      OTHERS                        = 11
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    endform.                    " open_dataset
    *&      Form  open_group
          text
    -->  p1        text
    <--  p2        text
    form open_group .
    loop at itab into record.
    perform bdc_dynpro      using 'SAPMF02K' '0105'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF02K-KTOKK'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RF02K-BUKRS'
                                  record-BUKRS_001.
    perform bdc_field       using 'RF02K-KTOKK'
                                  record-KTOKK_002.
    perform bdc_dynpro      using 'SAPMF02K' '0110'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-ORT01'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFA1-NAME1'
                                  record-NAME1_003.
    perform bdc_field       using 'LFA1-SORTL'
                                  record-SORTL_004.
    perform bdc_field       using 'LFA1-ORT01'
                                  record-ORT01_005.
    perform bdc_field       using 'LFA1-LAND1'
                                  record-LAND1_006.
    perform bdc_field       using 'LFA1-SPRAS'
                                  record-SPRAS_007.
    perform bdc_dynpro      using 'SAPMF02K' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-KUNNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0130'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFBK-KOINH(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'LFBK-BANKS(01)'
                                  record-BANKS_01_008.
    perform bdc_field       using 'LFBK-BANKL(01)'
                                  record-BANKL_01_009.
    perform bdc_field       using 'LFBK-BANKN(01)'
                                  record-BANKN_01_010.
    perform bdc_dynpro      using 'SAPMF02K' '0130'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFBK-BANKS(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_dynpro      using 'SAPMF02K' '0210'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-AKONT'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0215'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-ZTERM'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0220'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB5-MAHNA'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    call transaction 'FK01' using it_bdc mode 'A' update 'S'
                                 messages into it_msg.
      write:/ sy-subrc.
        perform message_formatwrite.
    refresh it_bdc.
    clear it_bdc.
    endloop.
    endform.                    " open_group
    *&      Form  message_formatwrite
          text
    -->  p1        text
    <--  p2        text
    form message_formatwrite .
    data:l_msg(10).
    loop at it_msg.
    CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
       ID              = SY-MSGID
       LANG            = sy-langu
       NO              = SY-MSGNO
       V1              = SY-MSGV1
       V2              = SY-MSGV2
       V3              = SY-MSGV3
       V4              = SY-MSGV4
    IMPORTING
       MSG             = l_msg
    EXCEPTIONS
       NOT_FOUND       = 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.
    endloop.
    endform.                    " message_formatwrite
    *&      Form  bdc_dynpro
          text
         -->P_0112   text
         -->P_0113   text
    form bdc_dynpro  using    value(p_0112)
                              value(p_0113).
    it_bdc-program = p_0112.
      it_bdc-dynpro = p_0113.
      it_bdc-dynbegin = 'X'.
      append it_bdc.
      clear it_bdc.
    endform.                    " bdc_dynpro
    *&      Form  bdc_field
          text
         -->P_0117   text
         -->P_0118   text
    form bdc_field  using    value(p_0117)
                             value(p_0118).
    it_bdc-fnam = p_0117.
      it_bdc-fval = p_0118.
      append it_bdc.
      clear it_bdc.
    endform.                    " bdc_field
    Regards
    fareedas

  • Upload data from excel (not the excle file) into SAP

    Guys,
    how can we upload data from excel sheet into SAP? I mean just the data not the entire file,
    I have a requirement where user press a button in excel sheet and the data in the sheet will get uploaded into SAP.
    I am sure we have to use BAPI and some VB programming for macros, I will really appriciate if anyone can help how to achive this.
    some sample code exampe will help.
    Cheers!

    I think u r writing BDC for Uploading the data from excel flile to sap. for this is the code I am sending u can use then for Uploading data from excel to sap.
    DATA: lv_filename TYPE rlgrap-filename.
    FIELD-SYMBOLS : <fs>.
    DATA : l_intern TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
    DATA : l_index TYPE i.
    PARAMETERS : startcol TYPE i ,
          startrow TYPE i ,
          endcol TYPE i ,
          endrow TYPE i .
    PARAMETERS: p_flnam LIKE rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_flnam.
      CALL FUNCTION 'F4_FILENAME'
    EXPORTING
       program_name        = sy-repid
      FIELD_NAME          = ' '
       IMPORTING
         file_name           = p_flnam .
      MOVE p_flnam TO lv_filename.
    Uploading the flat file from the desktop
    START-OF-SELECTION.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                      = lv_filename
          i_begin_col                   = startcol
          i_begin_row                   = startrow
          i_end_col                     = endcol
          i_end_row                     = endrow
        TABLES
          intern                        = l_intern
    EXCEPTIONS
      INCONSISTENT_PARAMETERS       = 1
      UPLOAD_OLE                    = 2
      OTHERS                        = 3
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      SORT l_intern BY row col.
      LOOP AT l_intern.
        MOVE l_intern-col TO l_index.
        ASSIGN COMPONENT l_index OF STRUCTURE itab TO <fs>.
        MOVE l_intern-value TO <fs>.
        AT END OF row.
          APPEND itab.
          CLEAR itab.
        ENDAT.
      ENDLOOP.
    I hope it will help u.
    Regards
    Nayan

  • Uploading data from excel sheet

    HI,
         Can anyone provide me the details to upload vendor data from excel sheet to database through bdc?
    Thankyou.

    upload the excel file in your internal table and then use BDC to updated the database table.
    FM's to upload Excel:
    GUI_UPLOAD
    KCD_EXCEL_OLE_TO_INT_CONVERT
    ALSM_EXCEL_TO_INTERNALTABLE
    refer to the link:
    http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table-2/
    http://www.sap-img.com/abap/learning-bdc-programming.htm
    With luck,
    Pritam.

  • Upload data from excel sheet into md61

    Hi Gurus,
                    Can anybody please tell me the solution like how to upload the data from excel sheet into the MD61
    if u suggest me to write an ABAP code then its fine or any other way would be great
    and can u also send me the abap code i would be thankful to all

    Hi,
    I can be done in 2 ways.
    1. Using LSMW you can upload your MD61 demand thru Excel sheet.
    2. You can use BDC to upload the demand from Excel. For this you need to take help from the ABAP. You need to record the macro usinf SHDB and the table maintenance will be taken care by the developer.
    For LSMW you need not depend on your developer, as a functional consultant you can do it yourself.
    Regards,
    V. Suresh

  • How to get data from excel sheet present in the client(local) system?

    hi,
    I have to upload the data from an excel sheet present in the local system(not on the server) to the table using webdynpro.
    i donot want to upload the excel file
    if it is necessary to upload the file then it should be on temporary basis and it should be deleted automatically.
    i can get the data from excel sheet which is present in the km using HSSF api but how to do the same if it is in local system?
    if anyone has the sample application of this type please give me the link.
    thanks

    You can use the FM ALSM_EXCEL_TO_INTERNAL_TABLE with Web Dynpro ABAP.

  • Create a visual web part which get data from excel sheet and import it into sql server database in sharepoint 2010 (development)

    Hi,
    I want to create a visual webpart which will read data from excel sheet and import it in to sql server database.(using sharepoint development)
    I want to do it using visual webpart.
    Please help to solve the issue.
    Thanks in advance!
    Regards
    Rajni

    Hi  Rajni,
    Microsoft.Office.Interop.Excel assembly provides class to read excel file data, in your web part solution, reference the assembly, and following blog contains samples about how to read the excel file data,
    and import it to SQL  database.
    1.Create a Visual Web Part Project:Create
    Visual Web Parts in SharePoint 2010
    2.Read the excel workbook by using SPFile class:
    http://alancejacob.blogspot.in/2012/06/read-data-from-excel-file-and-insert-in.html
    http://stackoverflow.com/questions/14496608/read-excel-file-stored-in-sharepoint-document-library
    3.Export the excel workbook to SQL Server:
    http://www.c-sharpcorner.com/UploadFile/99bb20/import-excel-data-to-sql-server-in-Asp-Net/
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Regarding uploading data from excel sheet to internal table

    hi,
    while executing the code im getting the output one by one but i want it to be displayed in a table format can any one help me regarding this issue.
    thanks and regards,
    siri

    Hi Sirisha,
    Through this FM we can't get the data in tabular format. After getting data from this FM we have to convert to tabular format. As far as i know there is no FM for Excel upload which directly gives data in tabular format.
    Check below sample code which uploads 3 columns from excel file.
    U can add as many case statements as the number of fields.
    PARAMETERS: po_file TYPE rlgrap-filename DEFAULT 'E:test.xls'.
    TYPES: BEGIN OF t_final,
              empno(10) TYPE c,
              name(30) TYPE c,
              state(25) TYPE c,
           END OF t_final.
    DATA: i_tab    TYPE STANDARD TABLE OF alsmex_tabline,
          i_final  TYPE STANDARD TABLE OF t_final,
          wa_tab   TYPE alsmex_tabline,
          wa_final TYPE t_final.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR po_file.
    PERFORM open_folder.
    START-OF-SELECTION.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
         EXPORTING
              filename                = po_file
              i_begin_col             = 1
              i_begin_row             = 1
              i_end_col               = 3
              i_end_row               = 65256
         TABLES
              intern                  = i_tab
         EXCEPTIONS
              inconsistent_parameters = 1
              upload_ole              = 2
              OTHERS                  = 3.
    CHECK NOT i_tab[] IS INITIAL.
    LOOP AT i_tab INTO wa_tab.
      CASE wa_tab-col.
        WHEN 1.
          wa_final-empno = wa_tab-value.
        WHEN 2.
          wa_final-name = wa_tab-value.
        WHEN 3.
          wa_final-state = wa_tab-value.
      ENDCASE.
      AT END OF row.
        APPEND wa_final TO i_final.
        CLEAR wa_final.
      ENDAT.
    ENDLOOP.
    FORM open_folder .
      DATA: li_file  TYPE TABLE OF sdokpath,
            lwa_file TYPE sdokpath.
      CLEAR: po_file, lwa_file.
      REFRESH li_file[].
      CALL FUNCTION 'TMP_GUI_FILE_OPEN_DIALOG'
           TABLES
                file_table = li_file
           EXCEPTIONS
                cntl_error = 1
                OTHERS     = 2.
      IF sy-subrc IS INITIAL.
        READ TABLE li_file INTO lwa_file INDEX 1.
        IF sy-subrc IS INITIAL.
          po_file = lwa_file-pathname.
        ENDIF.
      ENDIF.
    ENDFORM.                    " open_folder
    Just try executing above code in debug mode. U will understand the functionality.
    Thanks,
    Vinod.

  • Uploading data from Excel sheet into SAP.

    Dear All,
    I want to upload data existing in Excel sheet into SAP. Is there any possibility with the following requirements?
    1) Excel file contains serial numbers with different values.Like power(230Wp),Voc,Isc,Vmp and Imp.
    2) We need to upload the same data into SAP with validations.
    3) Validations are like no serial number should be repeated.
    4) And depending on the Power value, the serial number should be assigned to different batches.Eg:The batches are as follows:
         201 - 210
         210 - 220
         220 - 230
       and if the Pmax of the serial number is 205.It should be assigned to batch 201 - 210 .
    5) At present we are using MB31 to post the serial numbers which are existing in the flat file.
    Thanks and Regards,
    Varun Siddharth

    Hi,
    Refer to the following code:
    DATA: lv_filetype(10) TYPE c,
            lv_gui_sep TYPE c,
            lv_file_name TYPE string.
      lv_filetype = 'ASC'.
      lv_gui_sep = 'X'.
      lv_file_name = pa_dfile.
    FM call to upload file
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = lv_file_name
          filetype                = lv_filetype
          has_field_separator     = lv_gui_sep
        TABLES
          data_tab                = gi_zhralcon_file
        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.
    The excel file must be a tab delimited file.
    Hope it helps.
    Regards,
    Rajesh Kumar

  • Uploading Data From Excel Sheet to SAP Database Tables

    Dear Friends,
    We are having an Excel Sheet with 90 different columns. Now we want only 2 of the columns to be uploaded in the database tables. So, Plz tell me which function module will be suitable for this. And plz help me with the code also.
    Thanks,
    Nishant Jain

    Hi Nishu,
    A sample for the same..
    data it_excel like table of ALSMEX_TABLINE with header line.
    here we retrieve only 2 cols directly..
    now itab will contain only 2 cols of all rows seperated by comma ..
    data str(1000).
    data itab like table of str with  header line.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = 'C:sample1.xls'
        i_begin_col                   = 1
        i_begin_row                   = 1
        i_end_col                     = 2
        i_end_row                     = 100
      tables
        intern                        =  it_excel
      LOOP AT it_excel.
        AT NEW row.
          CLEAR itab.
        ENDAT.
        IF itab IS INITIAL.
          MOVE it_excel-value TO itab.
        ELSE.
          CONCATENATE itab ',' it_excel-value INTO itab.
        ENDIF.
        AT END OF row.
          APPEND itab.
        ENDAT.
      ENDLOOP.
    regards
    satesh

  • Uploading data from excel sheet using BAPI (BAPI_ACC_MANUAL_ALLOC_POST)

    Hi,
    I am Using BAPI_ACC_MANUAL_ALLOC_POST (Manual cost allocation) for uploading into database. But i am getting the error "DO NOT USE COST ELEMENT xxxxxxxx FOR REPOST COSTS".
    can anyone explain me the possible reasons for  this error.
    any help will be rewarded.
    Thanks and Regards,
    Gautham Paspala

    Hi,
    Refer to the following code:
    DATA: lv_filetype(10) TYPE c,
            lv_gui_sep TYPE c,
            lv_file_name TYPE string.
      lv_filetype = 'ASC'.
      lv_gui_sep = 'X'.
      lv_file_name = pa_dfile.
    FM call to upload file
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = lv_file_name
          filetype                = lv_filetype
          has_field_separator     = lv_gui_sep
        TABLES
          data_tab                = gi_zhralcon_file
        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.
    The excel file must be a tab delimited file.
    Hope it helps.
    Regards,
    Rajesh Kumar

  • Upload data from excel to Ztable with statistics

    Hi,
    I have a requirement to upload data from excel sheet to ztable .
    Here i need tp provide the user with the execution statistics like
    1.Number of records read from the Excel spread-sheet
    2. Number records processed successfully
    3. Number records with Error
    4. Name and location of Error Log-file (text-file format)
    5. Name and location of the file containing error records (Excel spread-sheet format)
    I would appreciate if any of you have code written for the same

    See the below example code to upload from xl file to sap
    REPORT ZLWMI151_UPLOAD no standard page heading
                           line-size 100 line-count 60.
    *tables : zbatch_cross_ref.
    data : begin of t_text occurs 0,
           werks(4) type c,
           cmatnr(15) type c,
           srlno(12) type n,
           matnr(7) type n,
           charg(10) type n,
           end of t_text.
    data: begin of t_zbatch occurs 0,
          werks like zbatch_cross_ref-werks,
          cmatnr like zbatch_cross_ref-cmatnr,
          srlno like zbatch_cross_ref-srlno,
          matnr like zbatch_cross_ref-matnr,
          charg like zbatch_cross_ref-charg,
          end of t_zbatch.
    data : g_repid like sy-repid,
           g_line like sy-index,
           g_line1 like sy-index,
           $v_start_col         type i value '1',
           $v_start_row         type i value '2',
           $v_end_col           type i value '256',
           $v_end_row           type i value '65536',
           gd_currentrow type i.
    data: itab like alsmex_tabline occurs 0 with header line.
    data : t_final like zbatch_cross_ref occurs 0 with header line.
    selection-screen : begin of block blk with frame title text.
    parameters : p_file like rlgrap-filename obligatory.
    selection-screen : end of block blk.
    initialization.
      g_repid = sy-repid.
    at selection-screen on value-request for p_file.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                PROGRAM_NAME = g_repid
           IMPORTING
                FILE_NAME    = p_file.
    start-of-selection.
    Uploading the data into Internal Table
      perform upload_data.
      perform modify_table.
    top-of-page.
      CALL FUNCTION 'Z_HEADER'
      EXPORTING
        FLEX_TEXT1       =
        FLEX_TEXT2       =
        FLEX_TEXT3       =
    *&      Form  upload_data
          text
    FORM upload_data.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                FILENAME                = p_file
                I_BEGIN_COL             = $v_start_col
                I_BEGIN_ROW             = $v_start_row
                I_END_COL               = $v_end_col
                I_END_ROW               = $v_end_row
           TABLES
                INTERN                  = itab
           EXCEPTIONS
                INCONSISTENT_PARAMETERS = 1
                UPLOAD_OLE              = 2
                OTHERS                  = 3.
      IF SY-SUBRC <> 0.
        write:/10 'File '.
      ENDIF.
      if sy-subrc eq 0.
        read table itab index 1.
        gd_currentrow = itab-row.
        loop at itab.
          if itab-row ne gd_currentrow.
            append t_text.
            clear t_text.
            gd_currentrow = itab-row.
          endif.
          case itab-col.
            when '0001'.
              t_text-werks = itab-value.
            when '0002'.
              t_text-cmatnr = itab-value.
            when '0003'.
              t_text-srlno = itab-value.
            when '0004'.
              t_text-matnr = itab-value.
            when '0005'.
              t_text-charg = itab-value.
          endcase.
        endloop.
      endif.
      append t_text.
    ENDFORM.                    " upload_data
    *&      Form  modify_table
          Modify the table ZBATCH_CROSS_REF
    FORM modify_table.
      loop at t_text.
        t_final-werks = t_text-werks.
        t_final-cmatnr = t_text-cmatnr.
        t_final-srlno = t_text-srlno.
        t_final-matnr = t_text-matnr.
        t_final-charg = t_text-charg.
        t_final-erdat = sy-datum.
        t_final-erzet = sy-uzeit.
        t_final-ernam = sy-uname.
        t_final-rstat = 'U'.
        append t_final.
        clear t_final.
      endloop.
      delete t_final where werks = ''.
      describe table t_final lines g_line.
      sort t_final by werks cmatnr srlno.
    Deleting the Duplicate Records
      perform select_data.
      describe table t_final lines g_line1.
      modify zbatch_cross_ref from table t_final.
      if sy-subrc ne 0.
        write:/ 'Updation failed'.
      else.
        Skip 1.
        Write:/12 'Updation has been Completed Sucessfully'.
        skip 1.
        Write:/12 'Records in file ',42 g_line .
        write:/12 'Updated records in Table',42 g_line1.
      endif.
      delete from zbatch_cross_ref where werks = ''.
    ENDFORM.                    " modify_table
    *&      Form  select_data
          Deleting the duplicate records
    FORM select_data.
      select werks
             cmatnr
             srlno from zbatch_cross_ref
             into table t_zbatch for all entries in t_final
             where werks = t_final-werks
             and  cmatnr = t_final-cmatnr
             and srlno = t_final-srlno.
      sort t_zbatch by werks cmatnr srlno.
      loop at t_zbatch.
        read table t_final with key werks = t_zbatch-werks
                                    cmatnr = t_zbatch-cmatnr
                                    srlno = t_zbatch-srlno.
        if sy-subrc eq 0.
          delete table t_final .
        endif.
        clear: t_zbatch,
               t_final.
      endloop.
    ENDFORM.                    " select_data
    Reward Points if it is helpful
    Thanks
    Seshu

  • Upload data from excel where one column has text of 3000 characters

    Guyz,
    I have a query. One of my requirments is to upload data from excel sheet & create a material. In the excel sheet one of the columns has text for BASIC DATA TEXT under ADDITIONAL DATA of a Material. This is a text of running length.
    the selection screen has feature of file upload & the users will upload excel files from their respective presentation servers.
    Now my problem is that I need a function module which can convert this column in excel sheet into an internal table & later call the BAPI for MM creation.
    I have used TEXT_CONVERT_XLS_TO_SAP & when i read my internal table to check this column length, it shows only 255 characters where as data in the excel sheet has 3000 characters (say for eg.)
    Can anybody throw some light on this.
    Thanks in advance
    GPK

    Hi,
    You can try using this function module and see that whether all your data is coming into the internal table properly.
    MS_EXCEL_OLE_STANDARD_DAT
    For the other part you needed to convert the internal table data into the structure as need by the BAPI and then call the create BAPI to create the materials in the SAP System.
    Hope this helps.
    Thanks,
    Samantak.

  • Upload data from excel file -URGENT

    Hi All,
    Advanced thanks to ur reply
    How to upload data from excel sheet to itab
    what are the functional modules we are using for that
    Please help me
    i look forward to ur reply
    Regards
    Raja Sekhar.T

    Hi,
         TYPE-POOLS: truxs.
    DATA: i_text_data       TYPE truxs_t_text_data,
          v_filename_string TYPE string.
    DATA: BEGIN OF itab OCCURS 0,
            Name(30),
            Phone(15),
            Fax(500).
    DATA: END OF itab.
    PARAMETERS: p_file LIKE rlgrap-filename.
    START-OF-SELECTION.
      v_filename_string = p_file.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                      = v_filename_string
          filetype                      = 'ASC'
          has_field_separator           = 'X'
        HEADER_LENGTH                 = 0
        READ_BY_LINE                  = 'X'
          dat_mode                      = ''
      IMPORTING
        FILELENGTH                    =
        HEADER                        =
        TABLES
          data_tab                      = i_text_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
          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.
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_field_seperator          = 'X'
        I_LINE_HEADER              =
          i_tab_raw_data             = i_text_data
          i_filename                 = p_file
        TABLES
          i_tab_converted_data       = itab
        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.
    I think this code will help u.
    With Regards,
    Ranganathan

Maybe you are looking for