How to upload a excel file using BDC

how should i upload a file using BDC
i have downloaded a excel file containing the values of  table A006 a X server.
now i hav to upload it into new server Y server using BDC , how do i do it?
wat all things one shud consider ?

Hi,
This is very simple, follow the below mention steps to do so:
1.Declare an internal table having same structure as db table, but take all the fields type as 'C' and length same as defined in the table.
TYPES:BEGIN OF it,
  key(20) TYPE c,
  indicator(20) TYPE c,
  bldat(20) TYPE c,"bkpf-bldat
  budat(20) TYPE c,"bkpf-budat
  END OF it.
DATA: itab TYPE STANDARD TABLE OF it,
      wa TYPE it.
2.Include TRUX as type pool and declare a variable of type trux_t_text_data to be passed in the FM that actually reads data from excel sheet into above declared intrenal table.
TYPE-POOLS: truxs.
DATA: it_raw TYPE truxs_t_text_data.
3. Call the FM 'TEXT_CONVERT_XLS_TO_SAP' and pass the file name and the internal table name into the parameter
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*    I_FIELD_SEPERATOR          = 'X'
     i_line_header              = 'X'
      i_tab_raw_data             = it_raw
      i_filename                 = p_file "name of the excel file
    TABLES
      i_tab_converted_data       = itab[] "internal table where data will be stored
   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.
4. loop at internal table and modify the ztable/dbtable where data to be upload .
Hope this solve your problem.
Pooja

Similar Messages

  • How to upload an excel file using ABAP.

    Hi,
    Can anyone please help me in understanding how to upload an excel file using ABAP.
    Thanks!!

    http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table/
    check the link
    TYPES: Begin of t_record,
    name1 like itab-value,
    name2 like itab-value,
    age   like itab-value,
    End of t_record.
    DATA: it_record type standard table of t_record initial size 0,
    wa_record type t_record.
    DATA: gd_currentrow type i.
    *Selection Screen Declaration
    PARAMETER p_infile like rlgrap-filename.
    *START OF SELECTION
    call function ‘ALSM_EXCEL_TO_INTERNAL_TABLE’
    exporting
    filename                = p_infile
    i_begin_col             = ‘1&#8242;
    i_begin_row             = ‘2&#8242;  “Do not require headings
    i_end_col               = ‘14&#8242;
    i_end_row               = ‘31&#8242;
    tables
    intern                  = itab
    exceptions
    inconsistent_parameters = 1
    upload_ole              = 2
    others                  = 3.
    if sy-subrc <> 0.
    message e010(zz) with text-001. “Problem uploading Excel Spreadsheet
    endif.
    Sort table by rows and colums
    sort itab by row col.
    Get first row retrieved
    read table itab index 1.
    Set first row retrieved to current row
    gd_currentrow = itab-row.
    loop at itab.
      Reset values for next row
    if itab-row ne gd_currentrow.
    append wa_record to it_record.
    clear wa_record.
    gd_currentrow = itab-row.
    endif.
    case itab-col.
    when ‘0001&#8242;.                              “First name
    wa_record-name1 = itab-value.
    when ‘0002&#8242;.                              “Surname
    wa_record-name2 = itab-value.
    when ‘0003&#8242;.                              “Age
    wa_record-age   = itab-value.
    endcase.
    endloop.
    append wa_record to it_record.
    *!! Excel data is now contained within the internal table IT_RECORD
    Display report data for illustration purposes
    loop at it_record into wa_record.
    write:/     sy-vline,
    (10) wa_record-name1, sy-vline,
    (10) wa_record-name2, sy-vline,
    (10) wa_record-age, sy-vline.
    endloop.

  • CRM ABAP How to upload an Excel file into an internal table?

    How to upload an Excel file using GUI_UPLOAD?? what should be the values of the parameters? The function modules ALSM_EXCEL_TO_INTERNAL_TABLE and KCD_EXCEL_OLE_TO_INT are not present in CRM. Please suggest me a way out!

    Hi saurabh,
    you can try the folowing sample..
    and make modifications according to your requirement..
    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.
    this is a sample code that uploads a excel file using GUI_UPLOAD, but uses another function module to convert that uploaded data into an internal table..
    regards
    satesh

  • How to upload normal excell file to ztable

    Hi All there,
    Can anybody tell me how to upload normal excell file to ztable directly.
    pl provide detail coding
    Regards
    Sagar

    Hi Sagar,
       first upload the excel data into your internal table using a FM than upload the data to your ZTABLE using BDC.
    parameters:
      p_file type rlgrap-filename          " File name
      data:
        lw_file  type string.              " File Path
    data:
      t_bdcdata type
       standard table
             of bdcdata,
      fs_bdcdata type bdcdata.             " Work area for bdcdata
    * Messages of call transaction
    data:
      t_messtab type
       standard table
             of bdcmsgcoll,
      fs_messtab type bdcmsgcoll.          " Work area for messtab
    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.
      lw_file = p_file.
      call function 'GUI_UPLOAD'
        exporting
          filename                    = lw_file
          filetype                    = 'ASC'
          has_field_separator         = 'X'
          dat_mode                    = 'X'
        tables
          data_tab                    = t_final_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.                               " IF SY-SUBRC <> 0
      if t_final_data is initial.
        message 'File not found'(003) type 'E'.
      endif.                               " IF T_FINAL_DATA IS INITIAL
    end-of-selection.
      perform upload_0585_data_using_bdc.  " populate the bdcdata table using tcode SHDB
      call transaction 'PA30' using t_bdcdata
                               mode 'A'
                           messages into t_messtab.
    form upload_0585_data_using_bdc.
      loop at t_final_data into fs_final_data.
    perform bdc_field       using 'Q0585-ACNTR(07)'
                                   w_curr.
    perform bdc_field       using 'Q0585-ACOPC'
                                   lw_flag.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=UPD'.
    perform bdc_dynpro      using 'MP058500' '2000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/EBCK'.
    perform bdc_dynpro      using 'SAPMP50A' '1000'.
    endloop.
    *        Start new screen                                              *
    form bdc_dynpro using program dynpro.
      clear fs_bdcdata.
      fs_bdcdata-program  = program.
      fs_bdcdata-dynpro   = dynpro.
      fs_bdcdata-dynbegin = 'X'.
      append fs_bdcdata to t_bdcdata.
    endform.                               " Form bdc_dynpro using program...
    *        Insert field                                                  *
    form bdc_field using fnam fval.
        clear fs_bdcdata.
        fs_bdcdata-fnam = fnam.
        fs_bdcdata-fval = fval.
        append fs_bdcdata to t_bdcdata.
    endform.                               " Form bdc_field using fnam fval
    With luck,
    Pritam.

  • I would like to upload a excel file using jsp

    Hi,
    I would like to upload the excel file using jsp in my netbeans ide. Please help.
    I don Know what is the error in this jsp file. It is not showing any thing and the file is also not getting uploaded.
    Please gothru the code below.
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ page import="java.io.*" errorPage="err.jsp"%>
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="<html:rewrite page="/design.css" />" rel="stylesheet" type="text/css">
    <title>Upload Page</title>
    </head>
    <body onKeyDown="DisablingBackFunctionality()" onLoad="DisablingBackFunctionality()">
    <html:form action="download" >
    <div style="position:absolute; left:100;top:200;">Select an excel File :<input type="file" name="uploadfile"></div>
    <div style="position:absolute; left:190;top:250;"><input type="submit" name="Submit" value="Read"></div>
    <div style="position:absolute; left:336;top:250;"><input type="reset" name="Reset" value="Clear"></div>
    mainmenu
    </html:form>
    </body>
    </html>
    <%
    String contentType = request.getContentType();
    if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
    DataInputStream in = new DataInputStream(request.getInputStream());
    int formDataLength = request.getContentLength();
    byte dataBytes[] = new byte[formDataLength];
    int byteRead = 0;
    int totalBytesRead = 0;
    while (totalBytesRead < formDataLength) {
    byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
    totalBytesRead += byteRead;
    String file = new String(dataBytes);
    //out.println("<br> file :"+file);
    String saveFile = file.substring(file.indexOf("filename=\"") + 10);
    //out.println("<br> savefile :"+saveFile);
    saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
    //out.println("<br> now file1 :"+saveFile);
    saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1, saveFile.indexOf("\""));
    //out.println("<br> now file2 :"+saveFile);
    //out.print(dataBytes);
    String ext = "";
    if (saveFile.indexOf(".") != -1) {
    ext = saveFile.substring(saveFile.lastIndexOf("."));
    int lastIndex = contentType.lastIndexOf("=");
    //out.println("<br>lst index of"+lastIndex);
    String boundary = contentType.substring(lastIndex + 1, contentType.length());
    //out.println("<br> boundary"+boundary);
    //out.println("<br> file :"+file);
    int pos;
    pos = file.indexOf("filename=\"");
    //out.println("<br> now 0 :"+pos);
    pos = file.indexOf("\n", pos) + 1;
    //out.println("<br>now 1 :"+pos);
    pos = file.indexOf("\n", pos) + 1;
    //out.println("<br>now 2 :"+pos);
    pos = file.indexOf("\n", pos) + 1;
    //out.println("<br>now 3"+pos);
    int boundaryLocation = file.indexOf(boundary, pos) - 4;
    int startPos = ((file.substring(0, pos)).getBytes()).length;
    int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
    FileOutputStream fileOut = new FileOutputStream("D:\\" + saveFile);
    //FileOutputStream fileOut = new FileOutputStream(saveFile);
    //fileOut.write(dataBytes);
    fileOut.write(dataBytes, startPos, (endPos - startPos));
    fileOut.flush();
    fileOut.close();
    session.setAttribute("fil", saveFile);
    //out.println("File saved as " +saveFile);
    %>
    <script type="text/javascript" >
    function DisablingBackFunctionality()
    var URL;
    var i ;
    var QryStrValue;
    URL=window.location.href ;
    i=URL.indexOf("?");
    QryStrValue=URL.substring(i+1);
    if (QryStrValue!='X')
    window.location=URL + "?X";
    </script>
    Please let me know the result as soon as possible. Its my very urgent.
    Thanking Yu,
    Muthu Kumar.R

    No.
    Mylenium

  • How to upload a multistructured file in BDC program using gui_upload?

    I want to upload a multistructured file in BDC program...in which some structures are repeating for multiple records..how to do this..
    BP_GEN_DATA     FR0100270154                         FR12345678902
    BP_PAYMENT     FR     0123456789     01234567890          
    BP_UNLOAD     MARSEILLE     X     FR                    
    BP_UNLOAD     PARIS          FR                         
    Here BP_GEN_DATA is root structure and BP_UNLOAD is lower level structure which is repeating

    Resolved

  • How to read the excel file using webdynpro abap?

    Hi,
    how to read and modify excel file using webdynpro abap?
    Regards,
    Pavani

    For reading excel file follow the steps :
    1. Use a File upload UI element and bind it with xstring.
    2. Now your excel will be uploaded and stored in Xstring.
    3. Convert Xstring to String data using FM 'HR_KR_XSTRING_TO_STRING'.
    4. Now split the string at new line so as to make an internal table .
      Ex . SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE it_table.
      here it_table is type table of string.
    5.now loop at the internal table and separate the content of this table separated by tab.
      Ex. SPLIT wa_table AT cl_abap_char_utilities=>horizontal_tab INTO TABLE it_new.
    it_new type string_table.
    6. For more info , refer this thread :
    Re: How to upload excel file in Webdynpro application using ABAP

  • How to upload  a excel file in webdynpro? Please help!

    Hi Experts,
        I have a requirement where I need to upload a  excel file in my webdynpro for ABAP report.
        I have used the fileupload UI element in my view and a upload button.
        However when I test the application I found that it is getting file data as some junk value like below:
        ###ࡱ#################>########################################################################################################################################################################################################################################
      Why is that so?
      Is there any limitation with fileuplaod reading excel file?
      Do i have to use any encoding option?
      What is the alternative option to read excel file in ABAP webdynpro?
    Thanks
    Gopal

    Hi,
    Check this.. Write this code in Upload button 's method
    ********** Reading data from flat file ****************
      DATA lo_el_context TYPE REF TO if_wd_context_element.
      DATA ls_context    TYPE wd_this->element_context.
      DATA lv_datasource type xstring.
    * get element via lead selection
      lo_el_context = wd_context->get_element(  ).
    * get single attribute
      lo_el_context->get_attribute(
        EXPORTING
          name =  `DATASOURCE`
        IMPORTING
          value = lv_datasource ).
       CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
        EXPORTING
    *   FROM_CODEPAGE       = '8500'
          IN_XSTRING          = LV_DATASOURCE
    *   OUT_LEN             = '1'
       IMPORTING
         OUT_STRING          = LV_STRING.
    SPLIT LV_STRING AT CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO TABLE IT_STR.
      LOOP AT IT_STR INTO LV_STRING.
        SPLIT LV_STRING AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO TABLE FIELDS.
        READ TABLE FIELDS INTO LV_FIELD INDEX 1.                 " Reading 1st field
        ls_header-STATU = LV_FIELD.
         clear LV_FIELD.
        READ TABLE FIELDS INTO LV_FIELD INDEX 2.                " Reading 2st field
         ls_header-LIFNR = LV_FIELD.
         clear LV_FIELD.
        READ TABLE FIELDS INTO LV_FIELD INDEX 3.
         ls_header-BSART = LV_FIELD.
         clear LV_FIELD.
        READ TABLE FIELDS INTO LV_FIELD INDEX 4.
         ls_header-EKORG = LV_FIELD.
         clear LV_FIELD.
        READ TABLE FIELDS INTO LV_FIELD INDEX 5.
         ls_header-EKGRP = LV_FIELD.
         clear LV_FIELD.
        READ TABLE FIELDS INTO LV_FIELD INDEX 6.
         ls_header-BUKRS = LV_FIELD.
         clear LV_FIELD.
         APPEND wa to it.
        append ls_header to lt_header.
        clear: ls_header,wa.
        endloop.
        lo_nd_header->BIND_TABLE( lt_header ).
    Thanks,
    Ramesh
    Edited by: Rameshkumar Raamasamy on Dec 20, 2010 11:16 AM

  • How to extract the excel file using web dynapro

    Hi Expert,
       I want to know how to generate an excel file to extract the internal  data. Please give me your help.
      Thanks in advance.

    I think you you can use File download UI element. Refer following link for more info:
    [FileDownload|http://help.sap.com/saphelp_tm60/helpdata/en/09/a5884121a41c09e10000000a155106/content.htm]
    Regards,
    Saket

  • How to format a excel file use java.

    hi,
    everyone, i meet a problem.i want to write a excel file use java.i can use .csv input the date to excel.but i want to know how to format it.
    thanks
    Jove

    hi,
    everyone, i meet a problem.i want to write a excel
    el file use java.i can use .csv input the date to
    excel.but i want to know how to format it.
    thanks
    JoveIf I understand your question correctly you need to know the format of a .csv file for use in an Excel spreadsheet. A .csv file is a comma-delimited file so all that you need to do is write your data elements to the file with commas in between them. Having done something similar in the past, let me warn you that when Excel is reading your file, it uses some characters other than commas as field delimiters. for example, / : and ; are treated as commas. To defeat this, you will need to surround fields containing those characters in double quotes.
    Hope that helps
    Mark

  • Upload an excel file using servlet

    want to upload an excel file read it and do some updates and then again build an excel sheet
    step 1: display an Excel sheet inside the browser
    step 2: edit the sheet
    step 3: send the sheet data to a Servlet to read it.
    i am using POI to read an excel file and use POIFS
    when i upload an excel file and get servletinputstream it gives the header+data+tailor
    stand alon i have done it but using servlet i failed
    can anybody give me an simple example to upload an excel file and shoe it
    plz help me

    Surprise! Look what the forum says...
    BEFORE YOU POST A TOPIC HERE: Please be sure your topic is related to features or functionality of this site. This forum is not for general technology questions. Not sure which forum to use? Try searching for your topic in the "Search Forums" element on the left panel.Please post your question on http://forum.java.sun.com/forum.jspa?forumID=33
    Do not reply here.

  • Can anybody help how to upload an excel file into sap-crm urgent

    hi guys,
    i need the right function module to upload the excel file from the presentation server in to sap-crm.
    1) I know we use the function module 'ALSM_EXCEL_TO_INT_TABLE' in sap-r/3 but this function module is not exist in sap-crm.
    2) i tried with the function moduel 'GUI_UPLOAD' but its not uploading correctly i am gettting hases(#).
    Please can any one provide the right function module to upload the excel into sap-crm with an sample code.
    thanks
    viswa guntha

    Hi Visma,
    Please check this link for sample custom FM.
    Re: function mudule for MS excel file to sap crm
    Hope this will help.
    Regards,
    Ferry Lianto
    Please reward points if helpful as away to say thanks.

  • How to upload a image file using JSP

    hello to all.
    i am in the learning stage please help me to upload a image file
    using jsp. give the explanation to the code also if possible.
    thanks in advance
    sincerely
    Chezhian

    You may find the following articles useful for the JSP/Servlet part:
    Uploading files: http://balusc.blogspot.com/2007/11/multipartfilter.html
    Downloading files: http://balusc.blogspot.com/2007/07/fileservlet.html

  • How to upload all excel files data from one folder into internal table.

    Dear All,
    I have one requirement, It is like I want to upload the frontend file data into my internal table, But here my scenario is;
    If I have one folder ( Called : Temp) in my frontend system, in this folder ( Called : Temp)  I have 100 excel files. In each excel file I have some 1000u2019s of entries. All these data of every file I want to take into my internal table.
    If I have one file I can go for, CALL METHOD cl_gui_frontend_services=>file_open_dialog and then upload method to upload. But I want to take all these excel files from that folder at a time, is there any class or any thing is there..? plz help..
    Thanks...
    Edited by: satishsuri on Jan 11, 2011 9:33 AM

    Hi satishsuri ,
    You will have to use 3 methods together :
    CALL METHOD cl_gui_frontend_services=>directory_browse "Browse the Directory
    CALL METHOD cl_gui_frontend_services=>directory_list_files "Get all the files from the directory
    CALL METHOD cl_gui_frontend_services=>gui_upload "Upload each file in a loop
    Example:
    TYPES: BEGIN OF ty_data,
             line TYPE string,
          END OF ty_data.
    DATA: str_file TYPE string,
          str_dir TYPE string,
          it_file_table TYPE STANDARD TABLE OF file_info,
          wa_file_table TYPE file_info,
          v_count TYPE i,
          it_data TYPE STANDARD TABLE OF ty_data,
          wa_data TYPE ty_data.
    CALL METHOD cl_gui_frontend_services=>directory_browse
      CHANGING
        selected_folder = str_dir.
    CALL METHOD cl_gui_frontend_services=>directory_list_files
      EXPORTING
        directory  = str_dir
      CHANGING
        file_table = it_file_table
        count      = v_count.
    LOOP AT it_file_table INTO wa_file_table.
      CONCATENATE str_dir wa_file_table-filename INTO str_file SEPARATED BY '\'.
      CALL METHOD cl_gui_frontend_services=>gui_upload
        EXPORTING
          filename = str_file
          filetype = 'ASC'
        CHANGING
          data_tab = it_data.
      LOOP AT it_data INTO wa_data.
        WRITE : / wa_data-line.
      ENDLOOP.
      ULINE.
    ENDLOOP.
    Regards,
    Jovito

  • How to upload a pdf file using webdynpro abap

    Hi Experts,
    I need to upload pdf files using webdynpro abap.my question is where to upload this files and how to upload this files, and how to display this pdf file.
    Please Provide Requried Information.
    Waiting for Reply.
    Thanks & Regards.
    Bhushan.

    Hi,
    There is a UI element with the type 'File Upload'.
    You can use that in your view.
    For further details and coding, please refer to
    [http://www.****************/Tutorials/WebDynproABAP/Upload/Page1.htm]
    Hope this helps you.
    Regards,
    Dolly

Maybe you are looking for