Uploading an Excel File with an ITS page

Hi All,
how can I do to provide a functionality to Upload Excel or TXT Files in a ITS Page ? I try to use functions GUI_UPLOAD, but it calls a Screen that I doesn't want that apears.
With another solution I make a BSP aplication that is called from my ITS page, in BSP aplication I use <input file... ...> to get content of File and transfer it to an internal table, but I had problem to transfer back this data to ITS aplication, then I solve this problem using EXPORT DATABASE. I believe that is not the corectly solution.
Somebony knows another way to solve this problem ?
Thanks

Hi Regis,
When i tried to upload a file it won't allow you to select a file in your local drive.
If you use the frontend services in SAPGUI for HTML,interim screens are shown because of technical reasons.
You need <b> Java Applet </b> to be iniated before the page loads.IS Java installed on ur PC ?
<b> REFER the SAP note : 893567 .</b>
Rgds,
J
Do award pts & close the thread, if you got the soln.

Similar Messages

  • Upload of Excel File with variable columns

    Hi All,
    I have a requirement where i have to upload xls file into SAP. This xls file has 10 rows fixed but the columns may vary from 20 to 400.
    For Ex : My xls file has 10 rows and 27 columns filled at present. But in future columns can vary to 400 or more than that also.
    So when i use ALSM_EXCEL_TO_INTERNAL_TABLE as
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        FILENAME                      = p_fname
        I_BEGIN_COL                   = 1
        I_BEGIN_ROW                   = 1
        I_END_COL                     = 400
        I_END_ROW                     = 10
      TABLES
        INTERN                        = itab1
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
    It throws SY_SUBRC = 2.
    Please let me know how i can solve this issue.
    Thanks,

    Hi Ashwani,
                     I will send a sample code for ur problem.Please the check the function modules i have used and procedure i followed.My function modules can work for any no.of rows and columns ok..check it once..
        Along with my code i am sending a flat file.plz copy the code and execute it and debug it ok..i will attach flat file at the end of the program check it once ok...
    code:
    *& Report  YBDC_UPLOAD_MM01_XLS                                        *
    *&  DEVELOPER  : KIRAN KUMAR.G                                         *
    *&  PURPOSE    : MAKE CHANGES TO DOWNLOADED FILE AND UPLOAD THE FILE   *
    *&  CREATION DT: 3/12/2007                                             *
    *&  REQUEST    : ERPK900035                                            *
    REPORT  YBDC_UPLOAD_MM01_XLS.
    Tables
    TABLES : mara. "General Material Data
    Global BDCDATA Structure and MESSAGE Structure
    DATA: gt_bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE,
          gt_msgtab  LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
    Global Variables
    DATA: gv_infile  TYPE string,
          gv_msg     TYPE string,
          gv_update  VALUE 'A'.
    Internal Table
    DATA:  BEGIN OF gt_data OCCURS 0,
             matnr(20), "Material Number
             mbrsh(20), "Account Group
             mtart(20), "Material Type
             meins(20), "Base Unit Of Measure
             maktx(20), "Material Description
           END OF gt_data.
    Selection-screen
    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_file LIKE rlgrap-filename,
                p_mode.
    SELECTION-SCREEN : END OF BLOCK b1.
    Select the File
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM fetch_file.
    START-OF-SELECTION.
    Fetch Data From XLS File
      PERFORM fetch_data.
    Fetch Data From XLS File
      PERFORM delete_headerinfo.
    Fetch Data From XLS File
      PERFORM place_data.
    *&      Form  fetch_file
          text
    -->  p1        text
    <--  p2        text
    FORM fetch_file .
      CALL FUNCTION 'F4_FILENAME'
       EXPORTING
         program_name        = syst-cprog
         dynpro_number       = syst-dynnr
      FIELD_NAME          = ' '
       IMPORTING
         file_name           = p_file.
      gv_infile = p_file.
    ENDFORM.                    " fetch_file
    *&      Form  fetch_data
          text
    -->  p1        text
    <--  p2        text
    FORM fetch_data .
      refresh : gt_data. "Clear Body Of the Internal Table
      clear   : gt_data. "Clear Header Line
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                      = gv_infile
         filetype                      = 'ASC'
         has_field_separator           = 'X'
        HEADER_LENGTH                 = 0
        READ_BY_LINE                  = 'X'
        DAT_MODE                      = ' '
      IMPORTING
        FILELENGTH                    =
        HEADER                        =
        TABLES
          data_tab                      = gt_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.
    ENDFORM.                    " fetch_data
    *&      Form  place_data
          text
    -->  p1        text
    <--  p2        text
    FORM place_data .
      LOOP AT gt_data.
        PERFORM bdc_dynpro      USING 'SAPLMGMM' '0060'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RMMG1-MATNR'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=AUSW'.
        PERFORM bdc_field       USING 'RMMG1-MATNR'
                                       gt_data-matnr.
        PERFORM bdc_dynpro      USING 'SAPLMGMM' '0070'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'MSICHTAUSW-DYTXT(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=ENTR'.
        PERFORM bdc_field       USING 'MSICHTAUSW-KZSEL(01)'
                                      'X'.
        PERFORM bdc_dynpro      USING 'SAPLMGMM' '4004'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=BU'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'MAKT-MAKTX'.
        PERFORM bdc_field       USING 'MAKT-MAKTX'
                                       gt_data-maktx.
        PERFORM bdc_field       USING 'MARA-MTPOS_MARA'
                                      'NORM'.
        CALL TRANSACTION 'MM02' USING gt_bdcdata MODE p_mode
                                      UPDATE     gv_update
                                      MESSAGES   INTO gt_msgtab.
    *For Error Messages Handling.
        LOOP AT gt_msgtab.
          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       = gv_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.
          IF sy-tabix = 1.
            WRITE: / 'Process Log' COLOR 3.
          ENDIF.
          WRITE:/ gv_msg.
        ENDLOOP.
        REFRESH gt_msgtab.
        REFRESH gt_bdcdata.
      ENDLOOP.
    ENDFORM.                    " place_data
           Start new screen                                              *
    FORM bdc_dynpro USING program dynpro.
      CLEAR gt_bdcdata.
      gt_bdcdata-program  = program.
      gt_bdcdata-dynpro   = dynpro.
      gt_bdcdata-dynbegin = 'X'.
      APPEND gt_bdcdata.
    ENDFORM.                    "BDC_DYNPRO
           Insert field                                                  *
    FORM bdc_field USING fnam fval.
      CLEAR gt_bdcdata.
      gt_bdcdata-fnam = fnam.
      gt_bdcdata-fval = fval.
      APPEND gt_bdcdata.
    ENDFORM.                    "BDC_FIELD
    *&      Form  delete_headerinfo
          text
    -->  p1        text
    <--  p2        text
    FORM delete_headerinfo .
      DELETE gt_data INDEX 1.
    ENDFORM.                    " delete_headerinfo
                         FLAT FILE
    *MATERIAL NUMBER     INDUSTRY SECTOR     MATERIAL TYPE     BASE UNIT OF
    *MEASURE     MATERIAL DESCRIPTION
    *806     M     FERT     CM     IRON
    *807     M     HALB     KG     STEEL
    *808     M     HAWA     KG     IRON
    Reward points if helpful
      Kiran Kumar.G.A
          Have a nice day...

  • Help with uploading an excel file to a table using an application

    Hello,
    Can anyone please help me out with this issue. I have apex application where in the end users upload an excel file to a table. For this I have followed the solution provided in this link
    http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
    Using the above solution, I was able to upload the excel data to a table "sample_tbl1" successfully with fields Id,acct_no,owner_name,process_dt. But the thing is I want accomdate a particular condition while uploading the file data, to check see if the acct_no already exists in another table say "sample_tbl2" or not. If acct_nos already exists in sample_tbl2 then give out an error displaying the list of account numbers that already exists in the database. Below is the code which I am using to upload file data to a table.
    DECLARE
    v_blob_data       BLOB; 
    v_blob_len        NUMBER; 
    v_position        NUMBER; 
    v_raw_chunk       RAW(10000); 
    v_char            CHAR(1); 
    c_chunk_len       number       := 1; 
    v_line            VARCHAR2 (32767)        := NULL; 
    v_data_array      wwv_flow_global.vc_arr2; 
    v_rows            number; 
    v_sr_no           number         := 1; 
    l_cnt             BINARY_INTEGER := 0;
    l_stepid          NUMBER := 10;
    BEGIN
    --Read data from wwv_flow_files</span> 
    select blob_content into v_blob_data 
    from wwv_flow_files 
    where last_updated = (select max(last_updated) from wwv_flow_files where UPDATED_BY = :APP_USER) 
    and id = (select max(id) from wwv_flow_files where updated_by = :APP_USER); 
    v_blob_len := dbms_lob.getlength(v_blob_data); 
    v_position := 1; 
    /* Evaluate and skip first line of data
    WHILE (v_position <= v_blob_len ) LOOP
    v_raw_chunk := dbms_lob.substr(v_blob_data,c_chunk_len,v_position);
    v_char :=  chr(hex_to_decimal(rawtohex(v_raw_chunk)));
    v_line := v_line || v_char;
    v_position := v_position + c_chunk_len;
    -- When a whole line is retrieved
    IF v_char = CHR(10) THEN
    -- Clear out 
    v_line := NULL;
    EXIT;
    END IF;
    END LOOP;
    -- Read and convert binary to char</span> 
    WHILE ( v_position <= v_blob_len ) LOOP 
    v_raw_chunk := dbms_lob.substr(v_blob_data,c_chunk_len,v_position); 
    v_char :=  chr(hex_to_decimal(rawtohex(v_raw_chunk))); 
    v_line := v_line || v_char; 
    v_position := v_position + c_chunk_len; 
    -- When a whole line is retrieved </span> 
    IF v_char = CHR(10) THEN
    -- Convert comma to : to use wwv_flow_utilities </span> 
    v_line := REPLACE (v_line, ',', ':'); 
    -- Convert each column separated by : into array of data </span> 
    v_data_array := wwv_flow_utilities.string_to_table (v_line); 
    -- Insert data into target table
    EXECUTE IMMEDIATE 'insert into sample_tbl1(ID,ACCT_NO,OWNER_NAME,PROCESS_DT) 
    values (:1,:2,:3,:4)'
    USING 
    v_sr_no, 
    v_data_array(1), 
    v_data_array(2),
    to_date(v_data_array(3),'MM/DD/YYYY');
    -- Clear out 
    v_line := NULL; 
    v_sr_no := v_sr_no + 1; 
    l_cnt := l_cnt + SQL%ROWCOUNT;
    END IF; 
    END LOOP;
    delete from wwv_flow_files
    where last_updated = (select max(last_updated) from wwv_flow_files where UPDATED_BY = :APP_USER)
    and id = (select max(id) from wwv_flow_files where updated_by = :APP_USER);
    l_stepid  := 20;
    IF l_cnt = 0 THEN
    apex_application.g_print_success_message := apex_application.g_print_success_message || '<p><span style="font-size:14;font-weight:bold">Please select a file to upload.</span></p>' ;
    ELSE
    apex_application.g_print_success_message := apex_application.g_print_success_message || '<p><span style="font-size:14;font-weight:bold;color:green">File uploaded and processed ' || l_cnt || ' record(s) successfully.</span></p>';
    END IF;
    l_stepid  := 30;
    EXCEPTION WHEN OTHERS THEN
    ROLLBACK;
    apex_application.g_print_success_message := apex_application.g_print_success_message || '<p><span style="font-size:14;font-weight:bold;color:red">Failed to upload the file. '||REGEXP_REPLACE(SQLERRM,'[('')(<)(>)(,)(;)(:)(")('')]{1,}', '') ||'</span></p>';
    END;
    {code}
    Can anyone please help me, how do i accomdate the condition within my existing code.
    thanks,
    Orton                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Orton,
    From your code it appears that the account No comes in the second column of the file = > v_data_array(1)
    So You can put a conditional block around the execute immediate code that inserts the records
    For instance
      SELECT count(1) INTO ln_account_no_exists from <"sample_tbl2> where account_no = v_data_array(1);
      IF (  ln_account_no_exists > 0 ) THEN
         --Account No: already exists
        <Do what you want to do here >
      ELSE
        EXECUTE IMMEDIATE ...
      END IF:
    {code}
    Inorder to handle the account no records which exists you can
      <li>Raise an exception
      <li> Write record to table or insert into collection and then use a report region in the page based on this table/collection to show error records
      <li> Append errored account No:s to the Success Message Variable programmatically(this variable is used by PLSQL process success/error message )
       {code}
        IF ( record exists)
          apex_application.g_print_success_message := apex_application.g_print_success_message||','|| v_data_array(1) ; -- Comma separated list of errored account no:s
        ELSE ...
       {code}
    Hope it helps                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Upload an excel file in the server  with a background job

    I am trying to upload an excel file in the server, but i only can upload flat files, i can upload files in local with the function ALSM_EXCEL_TO_INTERNAL_TABLE, can i use this function reading an excel file in the server, or is there another possibility of uploadinging an excel file in the server  with a background job ?
    thanks in advance

    Hi
    First read the file from the server to some temporary place at presentation layer and then open it. And if required, save it to the server afterwards. To read/write files to application server you can use:
    1. Statements "OPEN DATASET/CLOSE DATASET".
    2. There are some FMs for server file operations, like "C13Z_FILE_UPLOAD_BINARY" and "C13Z_FILE_DOWNLOAD_BINARY".
    *--Serdar

  • Upload an excel file to update a table

    Hi All
    I have a requirement in which, user uploads a simple excel file with some records (columns in excel in a pre-specified format similar to a database table) and all those have to insert into a table in a database.
    I've gone thru some documentation on Oracle ADF DI, and itseems to me that a simple excel file upload feature is not part of that. ADF DI basically has support to advanced features, and includes having a plug-in for excel, configuring excel workbook, etc.
    My req is uploading a simple excel.
    One solution i found, is to use af:inputfile, and read the excel in a java file(Backing Bean/Managed Bean - I always gets confused b/w these two :-) ) using POI, and manually update it to DB using a VO.
    Is there any better solution for this.
    Thanks in advance, Regards,
    Ravi.

    Yes thats how you its done . You can follow this blog for the solution - http://technology.amis.nl/blog/8418/adf-11g-import-from-excel-into-an-adf-table
    Btw backing bean will generally have bindings to all components on a page and Managed bean has bindings to specific ones - thats a prime difference between the two .

  • Excel file with auto-filter

    I have a excel file with auto-filters (sort filters) i'm
    trying to incorporate that into my web page via dreamweaver. what
    is the best method on doing so? converting the file to any other
    format will loose the auto-filter feature i have setup on the excel
    file. any ideas would be appreciated.

    Nor do I... Now! ;-)
    BTW interesting error message. I've never seen that.
    Walt
    "Ken Binney" <[email protected]> wrote
    in message
    news:g8kig8$2tm$[email protected]..
    > Thanks for posting that Walt, but I have no problems
    reaching the site
    > from New York.
    >
    >
    >
    > "Walt F. Schaefer" <[email protected]> wrote
    in message
    > news:g8kco3$o97$[email protected]..
    >> link delivers this: This Account Has Exceeded Its
    CPU Quota
    >>
    >> Whoops!
    >>
    >> --
    >>
    >> Walt
    >>
    >>
    >> "Ken Binney"
    <[email protected]> wrote in message
    >> news:g8k8vp$j7e$[email protected]..
    >>> You might also consider converting it to a table
    and use javascript for
    >>> sorting
    >>> Here's a free script
    >>>
    >>>
    http://www.mingyi.org/other/ts_demo.html
    >>>
    >>> "bronxbabie1"
    <[email protected]> wrote in message
    >>> news:g8jsro$269$[email protected]..
    >>>>I have a excel file with auto-filters (sort
    filters) i'm trying to
    >>>>incorporate
    >>>> that into my web page via dreamweaver. what
    is the best method on doing
    >>>> so?
    >>>> converting the file to any other format will
    loose the auto-filter
    >>>> feature i
    >>>> have setup on the excel file. any ideas
    would be appreciated.
    >>>>
    >>>
    >>>
    >>
    >>
    >
    >

  • 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

  • Need help in uploading an excel file into SAP

    Hi All,
    I got a requirement to upload an excel file to SAP.
    But When i tried with the FM "ALSM_EXCEL_TO_INTERNAL_TABLE" , file  not getting uploaded to internal table.
    Getting expection 2, UPLOAD_OLE...
    I think the problem is with the file... the following the sample text of the file...
    Technical IdentNo.     Line No.     Text                                 Location
    BS-PZ-180                   1     035-05 EXZENTER-SCHNECKENPUMPE             0026
    BS-PZ-180                   2          LIEFERANT : SOCSIL-INTER SA  ECUBLENS     0026
    BS-PZ-180                   3          HERSTELLER : MONO PUMPS LIMITED  MANCH     0026
    BS-PZ-180                   4          MODELL/TYP : SH 60                             0026
    But when I tried with only one Column..its getting successfully uploaded...
    Pls suggest me how to upload the file? ( May be with sample code)
    Also pls let me know hw to handle the file..which contains 5 differnt sheets of texts.. ( May be with sample code)
    Your suggestion will be highly appreciated...
    Thanks,
    Priya

    Hi,
    Use the FM: TEXT_CONVERT_XLS_TO_SAP.  It will work perfectly.  I used this function module and uploaded data from xls to sap.  check the following code:
    TYPE-POOLS: truxs.
    PARAMETERS: p_file TYPE  rlgrap-filename.
    TYPES: BEGIN OF t_datatab,
          PROP_NAME like SDOKPROP-PROP_NAME,
          PROP_CHECK like SDOKPROP-PROP_CHECK,
          TABNAME like SDOKPROP-TABNAME,
          FIELDNAME like SDOKPROP-FIELDNAME,
          DESCRIPT(30) type c,
          END OF t_datatab.
    DATA: it_datatab type standard table of t_datatab,
          itab  TYPE STANDARD TABLE OF t_datatab,
          wa_itab TYPE t_datatab,
          wa_datatab type t_datatab.
    DATA: it_raw TYPE truxs_t_text_data.
    At selection screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          field_name = 'P_FILE'
        IMPORTING
          file_name  = p_file.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    SELECT * FROM sdokprop INTO CORRESPONDING FIELDS OF TABLE itab
    WHERE PROP_NAME LIKE 'DMS%'.
    WRITE / 'Before Modification'.
      LOOP AT itab INTO wa_itab.
        WRITE:/1 wa_itab-PROP_NAME, 27 wa_itab-PROP_CHECK, 31 wa_itab-TABNAME, 65 wa_itab-FIELDNAME, 96 wa_itab-DESCRIPT.
        CLEAR wa_itab.
      ENDLOOP.
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
        I_FIELD_SEPERATOR        =
          i_line_header            =  'X'
          i_tab_raw_data           =  it_raw       " WORK TABLE
          i_filename               =  p_file
        TABLES
          i_tab_converted_data     = it_datatab[]    "ACTUAL 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.
    END-OF-SELECTION.
    END-OF-SELECTION.
      WRITE / 'After Modification'.
    MODIFY sdokprop FROM TABLE it_datatab.
      LOOP AT it_datatab INTO wa_datatab.
        WRITE:/1 wa_datatab-PROP_NAME, 27 wa_datatab-PROP_CHECK, 31 wa_datatab-TABNAME, 65 wa_datatab-FIELDNAME, 96 wa_datatab-DESCRIPT.
        CLEAR wa_datatab.
      ENDLOOP.
      IF sy-subrc = 0.
        MESSAGE 'successfull' TYPE 'S'.
      ELSE.
        MESSAGE 'failed' TYPE 'E'.
      ENDIF.
    Regards,
    Bhaskar

  • From sap to excel file with different sheets?

    can  i upload   an internal table  from  SAP to single Excel file with different sheets for example like : sheet1, sheet2, sheet3.......sheet10. , but need to upload data from sap to excel worksheets ie. from multiple named tabs in Excel. Is this possible, and if so, please can you help and advise me how?
    thanks
    venkat.
    Edited by: Matt on Feb 16, 2009 2:15 PM  Removed excessive question marks...!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Hi venkat,
    Yes indeed it is possible to write data from internal table to different excel sheets. Check out SAP's Microsoft OLE functionality.Search on SDN for OLE . Following are some links
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/sample%252bprogram%252bto%252bopen%252bexcel%252bsheet%252busing%252bole
    You can also check out FM ALSM_EXCEL_TO_INTERNAL_TABLE to check how to read different worksheets.
    Using the above two resources you can create a program that can upload data to multiple worksheets in the same workbook.
    Also see this link
    Creating Excel with More than one page
    Edited by: aditya aghor on Feb 16, 2009 1:57 PM
    Edited by: aditya aghor on Feb 16, 2009 2:02 PM

  • Upload an excel file to table data

    Hi  ,
    I could succesfully develope an application for uploading an excel file and displaying the data in tabular format (i.e through table  display ) .  But on  Action <<Export TO Table>> it is not showing the details in tabular format . After uploadinfg file it is providing successful msg but when i m clicking on Export to table it is not displaying table data .
    Its a demo WD program in java given below
    Could anybody please guide me in this approach ?
    public void onActionUploadFileData(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        InputStream text = null;
        int temp = 0 ;
        String path ;
        try
                File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
                FileOutputStream output = new FileOutputStream(file);
                if (wdContext.currentContextElement().getResource()!= null )
                      text = wdContext.currentContextElement().getResource().read(false);
                      while ((temp=text.read())!= -1)
                            output.write(temp);
                output.flush();
                output.close();
                path = file.getAbsolutePath();
                wdComponentAPI.getMessageManager().reportSuccess(path);
        catch (Exception ex)
          ex.printStackTrace();
      public void onActionExport_To_Table(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionExport_To_Table(ServerEvent)
        try {
          Workbook workbook = Workbook.getWorkbook(new File(path));
          Sheet sheet = workbook.getSheet(0);
          int columns = sheet.getColumns();
          int rows = sheet.getRows();
          int i=0;
          int j;
          for (j=1;j<=rows;j++)
                element = wdContext.nodeTableData().createTableDataElement();
                Cell cell1 = sheet.getCell(i,j);
                element.setEmpId(cell1.getContents());
                Cell cell2 = sheet.getCell(i+1,j);
                element.setFirstname(cell2.getContents());
                      Cell cell3 = sheet.getCell(i+2,j);
                      element.setLastname(cell3.getContents());
                      wdContext.nodeTableData().addElement(element);
         catch (Exception ex)
                ex.printStackTrace();
    Edited by: Trina_Saheli on Feb 26, 2010 4:22 PM

    Hi Trina,
    Check onAction method(onActionExporttotable) of "Export to Table ". Print the c1.getContents(), c2.getContents,c3.getContents value with MessageManager while setting vaule to node attribute.
    Once the all the attribute added to node TableData, print the table attribute in onActionExporttotable method itself.
    Also check the TableData node properties which is bind to table of displaying in the screen.
    Hopt it helps
    Regards,
    Arun

  • What parameters should i pass inorder to upload an excel file in gui_upload

    what parameters should i pass inorder to upload an excel file in gui_upload
    Thanks in advance.
    Ahmed.

    check below program....
    *& Report  UPLOAD_EXCEL                                                *
    *& Upload and excel file into an internal table using the following    *
    *& function module: ALSM_EXCEL_TO_INTERNAL_TABLE                       *
    REPORT  UPLOAD_EXCEL no standard page heading.
    *Data Declaration
    data: itab like alsmex_tabline occurs 0 with header line.
    Has the following format:
                Row number   | Colum Number   |   Value
         i.e.     1                 1             Name1
                  2                 1             Joe
    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'
                i_begin_row             = '2'  "Do not require headings
                i_end_col               = '14'
                i_end_row               = '31'
           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'.                              "First name
            wa_record-name1 = itab-value.
          when '0002'.                              "Surname
            wa_record-name2 = itab-value.
          when '0003'.                              "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.

  • 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.

  • Error While uploading a EXCEL file in Web dynpro - HR_KR_XSTRING_TO_STRING

    Hi,
       I am getting an error while trying to upload a excel file.  I am using the function HR_KR_XSTRING_TO_STRING for conversion. The error message is  "Unable to interpret    as a number"

    First of all, are you sure you know what you are working with here.  If this is standard Excel file in the Microsoft binary/propriatery format there is not function module or class in ABAP that can magically just transform this to a character string.  You should search the forums as this has been discussed extensively.  On that topic, please also do not post duplicate threads.  I have already locked your other thread with the same basic question.
    Instead of the binary/propriatery format of Excel, the file should be saved on the client as a text based format - like XML or Text Tab Delimited. You can then use several different options on the server to convert the XSTRING to STRING and process the content (becuase it was text based to begin with).  You could use CL_BCS_CONVERT, the function modules in the function group SCMS_CONV, or the class CL_ABAP_CONV_IN_CE.

  • How do I merge multiple Excel files with more than one tab in each file using PowerQuery?

    Hello
    I have 12 Excel (.xlsx) files and each file has three identically named and ordered tabs in them. 
    I know how to merge multiple Excel files in a folder using M (those guides are all over the web) but how do I merge multiple Excel files with multiple (yet identically named and ordered) tabs? Surely it is possible? I just don't know how to do it in M.
    Cheers
    James

    What Laurence says is correct, and probably the best thing to do when the sheets have differing structures. Here is an alternate approach that works well when the sheets all have the same structure.
    When you first open the Excel file from Power Query, you can see its structure in the navigator at the right-hand-side of the screen. If you select the root (which is the filename itself) and click Edit, you'll see all the tabs in the sheet as a single table.
    You can now do filtering based on the Name, Item and Kind values. When you've reduced the set of things down to the sheets you want, select the Data column and say "Remove Other Columns". If the sheets don't have any header rows, you can just click the expand
    icon in the header and you'll be done.
    Otherwise, if the sheets have headers or if some other kind of sheet-level transformation is required against each sheet before doing a merge, you'll have to write some M code manually. In the following example, each sheet has a header row consisting of
    two columns: Foo and Bar. So the only step I need to perform before merging is to promote the first row into a header. This is done via the Table.TransformColumns operation.
    let
        Source = Excel.Workbook(File.Contents("C:\Users\CurtH\Desktop\Test1.xlsx")),
        RemovedOtherColumns = Table.SelectColumns(Source,{"Data"}),
        PromotedHeaders = Table.TransformColumns(RemovedOtherColumns,{{"Data", each Table.PromoteHeaders(_)}}),
        ExpandData = Table.ExpandTableColumn(PromotedHeaders, "Data", {"Foo", "Bar"}, {"Data.Foo", "Data.Bar"})
    in
        ExpandData

  • Uploading an Excel File

    I'm doing a test on uploading an Excel file using JAVA. Right now I have my code set up to upload to an Access database. Everything works great except the last record in my Excel file is not being uploaded. I can make it load the last record by adding redundant code { stSQL.executeUpdate(strSQL);  }
    outside the loop as shown below. This doesn't really make sense to me since I am printing the last SQL statement twice, once inside the loop and once outside the loop so why the SQL statement isn't executed is beyond me. Any thoughts? Thanks,
    import java.io.*;
    import java.sql.*;
    import java.util.regex.*;
    public class UploadExcel{
    public static void main(String[] args){
    Connection connection = null;
    String TableName = "GSABill";
    String strBeginSQL = "INSERT INTO " + TableName + " VALUES( ";
    try{
    int iCount = 0;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");                
    Connection con = DriverManager.getConnection( "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=c:/test3.xls;DriverID=22;READONLY=false;" );
    Connection Access = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)}; DBQ=c:/temp/test.mdb;Uid=Admin;Pwd=;");
    Statement st = con.createStatement();
    Statement stSQL = Access.createStatement();
    ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );      
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    int rows;
    String strSQL;
    strSQL = "";
    while (rs.next()) {
    strSQL = strBeginSQL;
    iCount++;
    strSQL = strBeginSQL + iCount + ", ";
         for (int i = 1; i <= numberOfColumns; i++) {                                             
              String columnValue = rs.getString(i);                          
    try{
    if (!columnValue.equals("")){
    strSQL = strSQL.substring(0, strSQL.length()-1) + "'" + columnValue + "', ";
    } else {
    strSQL = strSQL.substring(0, strSQL.length()-1) + "'', ";
    } catch(Exception e) {
    strSQL = strSQL.substring(0, strSQL.length()-1) + "'', ";
    strSQL = strSQL.substring(0, strSQL.length() - 2) + ")";
    System.out.println(strSQL);
    stSQL.executeUpdate(strSQL);
    System.out.println(strSQL);
    stSQL.executeUpdate(strSQL);
    stSQL.close();
         st.close();
         con.close();
    } catch(Exception ex) {
         System.err.print("Exception: ");
         System.err.println(ex.getMessage());

    jsp file upload code (any type of file): (fileUpload.jsp)
    <%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>
    <%@ page import="java.io.FileWriter,java.io.IOException" %>
    <%
         String savePath = "", filepath = "", filename = "";
         String contentType = "", fileData = "", strLocalFileName = "";
         int startPos = 0;
         int endPos = 0;
    %>
    <%!
         //copy specified number of bytes from main data buffer to temp data buffer
         void copyByte(byte [] fromBytes, byte [] toBytes, int start, int len)
              for(int i=start;i<(start+len);i++)
                   toBytes[i - start] = fromBytes;
    %>
    <%
         int BOF = 0, EOF = 0;
         contentType = request.getContentType();
         out.println("<br>Content type is :: " +contentType);
         if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))
              DataInputStream in = new DataInputStream(request.getInputStream());
              DataInputStream in1 = in;
              int formDataLength = request.getContentLength();
              byte dataBytes[] = new byte[formDataLength];
              int byteRead = 0;
              int totalBytesRead = 0;
              while (totalBytesRead < formDataLength)
                   byteRead = in1.read(dataBytes, totalBytesRead, formDataLength);
                   totalBytesRead += byteRead;
              out.println("<br>totalBytesRead : " + totalBytesRead + " : formDataLength = " + formDataLength);
              //String file = new String(dataBytes);
              //out.println("<br>File Contents:<br>////////////////////////////////////<br>" + file + "<br>////////////////////////////////<br>");
              byte[] line = new byte[128];
              if (totalBytesRead < 3)     
              return;     //exit if file length is not sufficiently large
              String boundary = "";
              String s = "";
              int count = 0;          
              int pos = 0;
              //loop for extracting boundry of file
              //could also be extracted from request.getContentType()
              do
                   copyByte(dataBytes, line, count ,1);     //read 1 byte at a time
                   count+=1;
                   s = new String(line, 0, 1);
                   fileData = fileData + s;
                   pos = fileData.indexOf("Content-Disposition: form-data; name=\""); //set the file name
                   if(pos != -1)
                        endPos = pos;
              }while(pos == -1);
              boundary = fileData.substring(startPos, endPos);
              //loop for extracting filename
              startPos = endPos;
              do
                   copyByte(dataBytes, line, count ,1);     //read 1 byte at a time
                   count+=1;
                   s = new String(line, 0, 1);
                   fileData = fileData + s;
                   pos = fileData.indexOf("filename=\"", startPos); //set the file name
                   if(pos != -1)
                        startPos = pos;
              }while(pos == -1);                         
              do
                   copyByte(dataBytes, line, count ,1);     //read 1 byte at a time
                   count+=1;
                   s = new String(line, 0, 1);
                   fileData = fileData + s;
                   pos = fileData.indexOf("Content-Type: ", startPos);
                   if(pos != -1)
                        endPos = pos;                              
              }while(pos == -1);
              filename = fileData.substring(startPos + 10, endPos - 3);     //to eliminate " from start & end
              strLocalFileName = filename;
              int index = filename.lastIndexOf("\\");
              if(index != -1)
                   filename = filename.substring(index + 1);
              else
                   filename = filename;
              //loop for extracting ContentType
              boolean blnNewlnFlag = false;
              startPos = endPos;     //added length of "Content-Type: "
              do
                   copyByte(dataBytes, line, count ,1);     //read 1 byte at a time
                   count+=1;
                   s = new String(line, 0, 1);
                   fileData = fileData + s;               
                   pos = fileData.indexOf("\n", startPos);
                   if(pos != -1)
                        if(blnNewlnFlag == true)
                             endPos = pos;                         
                        else
                             blnNewlnFlag = true;
                             pos = -1;
              }while(pos == -1);
              contentType = fileData.substring(startPos + 14, endPos);
              //loop for extracting actual file data (any type of file)
              startPos = count + 1;
              do
                   copyByte(dataBytes, line, count ,1);     //read 1 byte at a time
                   count+=1;
                   s = new String(line, 0, 1);
                   fileData = fileData + s;
                   pos = fileData.indexOf(boundary, startPos);     //check for end of file data i.e boundry value               
              }while(pos == -1);
              endPos = count - boundary.length();
              //file data extracted
              out.println("<br><br>0. Local File Name = " + strLocalFileName);
              out.println("<br><br>1. filename = " + filename);
              out.println("<br>2. contentType = " + contentType);
              out.println("<br>3. startPos = " + startPos);
              out.println("<br>4. endPos = " + endPos);
              out.println("<br>5. boundary = " + boundary);
              //create destination path & save file there
              String appPath = application.getRealPath("/");
              out.println("<br>appPath : " + appPath);
              String destFolder = appPath + "images/banner/";
              filename= destFolder + filename;
              FileOutputStream fileOut = new FileOutputStream(filename);
              fileOut.write(dataBytes, startPos, (endPos - startPos));
              fileOut.flush();
              fileOut.close();
              out.println("<br>File saved as >> " + filename);          
              //file saved at destination
              //out.println("<br>File data : <br><br>**************************<br>" + (new String(dataBytes,startPos, (endPos - startPos))) + "<br><br>**************************");
         else
              out.println("Error in uploading ");
    %>
    supporting html file:
    <form method="post" action="fileUpload.jsp" name="upform" enctype="multipart/form-data">
      <table width="60%" border="0" cellspacing="1" cellpadding="1" align="center" class="style1">
        <tr>
          <td align="left"><b>Select a file to upload :</b></td>
        </tr>
        <tr>
          <td align="left">
            <input type="file" name="uploadfile" size="50">
            </td>
        </tr>
        <tr>
          <td align="left">
              <input type="hidden" name="todo" value="upload">
            <input type="submit" name="Submit" value="Upload">
            <input type="reset" name="Reset" value="Cancel">
            </td>
        </tr>
      </table> 
    </form>
    </body>
    </html>

Maybe you are looking for

  • Can't connect using AEBS - driving me insane

    hi, hopefully someone out there can help!! i am trying to connect 2 computers to my AEBS. one is a mac mini and wired, the other is an ibook and wireless. both of them connect perfectly when i connect them with wires directly into the modem. however

  • When I try opening iTunes, it fails to load!

    Ok, well I click on my iTunes, from my desktop or start menu, anywhere possible. My laptop freezes over, for about five minutes, and then when it unfreezes, an error message pops up that says "iTunes failed to load because there is not enough memory

  • Oracle, Help!

    Hi, I am new member and I am new in Oracle. I have to connect to the oracle server thru VPN. I don't have problem in connecting thru VPN. My problem is in MsAccess ODBC, when i test the connection i have return error; Unable to connect SQLState-08004

  • Modbus communication with an automation direct GS2 AC Drive

    Has anyone written any VI's to communicate with an automation direct GS2-41P0 AC Drive using modbus?  I need to ask the unit a few questions while it is running and possibly start and stop it.  I have started searching around and found the NIModbus V

  • Problems on bootup

    1. I'm experiencing some errors showing up on bootup. I'm using Voodoo. My dmesg is (the errors): drivers/usb/input/hid-core.c: v2.6:USB HID core driver end_request: I/O error, dev sr0, sector 1413968 Buffer I/O error on device sr0, logical block 353