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

Similar Messages

  • Upload multiple excel files into tables using APEX

    Hi folks,
    I'm wondering if anyone has ever uploaded multiple .csv files simultaniously and store the data into the database using APEX XE before.
    I can browse for a single file, and execute that okay and a good example of doing that can be found at http://advait.wordpress.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
    This works fine when the user browses to a specific file on their network and then uploads the data from that one file.
    However I need the ability to 'grab' every file in a specific directory one after the other to process rather than having to specify which one to load everytime, and wondered if anyone has come across this before.
    Many thanks
    Graham.

    Just for completeness ...
    Got this to work, but it's a pl/sql issue as opposed to an APEX issue.
    Anyway, if anyone needs to have the ability to read multiple files then a quick easy way to do it (as lomg as they know the file names that will be read), is to create a directory on the database which points to the actual harddrive on your PC, then create a table (called an external table) and read from that external table as if it was an actual database table ...
    1 - Log on as sys and grant CREATE ANY DIRECTORY to whatever user you are logging in as (assuming you are not using sys to create apps)
    2 - Create a directory e.g....CREATE OR REPLACE DIRECTORY GB_TEST AS 'c:\gbtest';
    3 - Create an external table as ...
    CREATE TABLE gb_test
    (file_name varchar2(10),
    rec_date date
    rec_name VARCHAR2(20),
    rec_age number,
    ORGANIZATION EXTERNAL
    TYPE ORACLE_LOADER
    DEFAULT DIRECTORY GB_TEST
    ACCESS PARAMETERS
    RECORDS DELIMITED BY NEWLINE
    FIELDS TERMINATED BY ','
    LOCATION ('data1.csv','data2.csv','data3.csv','data4.csv')
    PARALLEL 5
    REJECT LIMIT 20000;
    That's it then ...
    select * from gb_test
    where file_name = 'xxx'
    will return all the data where the file_name = 'xxx'
    very easy to use.

  • How  to load the data from excel  file  into table in oracle using UTL_FI

    How to load the data from excel file into table in oracle
    and from table to excel file
    using UTL_FILE package
    Please give me some example

    This is something i tried in oracle apex
    http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
    Regards,
    CKLP

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Urgent : Uploading an excel file to an internal table

    Hi All
    M problem is simple ..i have to upload an excel file from my PC which is containing 2 cols to an internal table which is having two fields .. I am using GUI_UPLOAD function module for this and using FILELD_SEPARATOR as 'X" .. But i am not able to upload anything .it gives some junk content to my internal tble .
    please help me out
    Regards
    rohan

    Hi Rohan,
    Use the following code.
    DATA: IT_MAIN LIKE STANDARD TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = 'c:\test.xls'
        i_begin_col                   = 1
        i_begin_row                   = 1
        i_end_col                     = 4
        i_end_row                     = 4
      tables
        intern                        = IT_MAIN
    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 IT_MAIN.
      WRITE:/ IT_MAIN-ROW, '   ',
              IT_MAIN-COL, '   ',
              IT_MAIN-VALUE, '   '.
    ENDLOOP.
    The field VALUE of internal table IT_MAIN will contain the data. The first row will contain data from the first column, second for the second column and so on... In your case, the third row will contain 2nd row data from the first column of your excel sheet and so on.
    Hopw this helps,
    Cheers,
    Madhur

  • FM to upload the Excel file to internal table

    Hi
    Is any FM available to upload the Excel file to internal table.
    Thanks
    Anbu

    Hi
    se this code
    EXCEL to INTERNAL TABLE and then to APPLICATION SERVER
    *& Report  ZSD_EXCEL_INT_APP
    REPORT  ZSD_EXCEL_INT_APP.
    parameter: file_nm type localfile.
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    at selection-screen on value-request for file_nm.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      PROGRAM_NAME        = SYST-REPID
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
       STATIC              = 'X'
      MASK                = ' '
      CHANGING
       file_name           = file_nm
    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.
    refresh it_tab2[].clear wa_tab2.
    file = file_nm.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
    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 it_tab.
      case it_tab-col.
       when '002'.
        wa_tab2-f1 = it_tab-value.
       when '004'.
        wa_tab2-f2 = it_tab-value.
      when '008'.
        wa_tab2-f3 = it_tab-value.
    endcase.
    at end of row.
      append wa_tab2 to it_tab2.
    clear wa_tab2.
      endat.
    endloop.
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    loop at it_tab2 into wa_tab2.
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    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

  • Upload an Excel file into an Internal Table

    Hi,
    I want to upload an Excel file into an internal table but it doesn't work. I'd appreciate if someone could tell me what is wrong.
    My excel file has the following format:
          Col1  Col2
    Row1    1    2
    Row2    2    3
    Row3    3    4
    And the report code is the following one:
    REPORT ZFI_PROKON_PROCESOS.
    DATA: BEGIN OF itab OCCURS 0,
            num1(1),
            num2(1).
    DATA: END OF itab.
    PARAMETERS: p_file LIKE rlgrap-filename obligatory.
    AT SELECTION-SCREEN.
    AT SELECTION-SCREEN on value-request for p_file.
      call function 'KD_GET_FILENAME_ON_F4'
           EXPORTING
                static    = 'X'
           CHANGING
                file_name = p_file.
    START-OF-SELECTION.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
         EXPORTING
              FILENAME                = p_file
              I_BEGIN_COL             = 1
              I_BEGIN_ROW             = 1
              I_END_COL               = 2
              I_END_ROW               = 5
         TABLES
              INTERN                  = itab
        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 itab.
      WRITE: / itab-num1, 10 itab-num2.
    ENDLOOP.
    Thanks in advance,
    Gerard

    Try function module
    ALSM_EXCEL_TO_INTERNAL_TABLE
      call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           exporting
                filename                = p_path
                i_begin_col             = 1
                i_begin_row             = 2
                i_end_col               = 70
                i_end_row               = 10000
           tables
                intern                  = i_excel
           exceptions
                inconsistent_parameters = 1
                upload_ole              = 2
                others                  = 3.
    P_PATH is file name with path.
    I_EXCEL is internal table to store data.
    declaration is "i_excel like structure alsmex_tabline"
    then loop at i_Excel and populate your table
    for eg
      loop at i_excel.
        case  i_excel-col.
          when '0001'.
            i_data-compcode              = i_excel-value.
          when '0002'.
            i_data-rcpttyp               = i_excel-value.
          when '0003'.
            i_data-pocimpro              = i_excel-value.
          when '0004'.
            i_data-tranno                = i_excel-value.
          when '0005'.
            i_data-msrpo                 = i_excel-value.
          when '0006'.
            i_data-mporel                = i_excel-value.
        endcase.
        at end of row.
          append i_data.
          clear  i_data.
        endat.
      endloop.

  • Upload an excel file into a table

    Good Morning:
    I have to upload the contents of an excel file into a table. Someone knows how to do it?
    Thanks a lot.

    Hi,
    See this sample code.
    At selection-screen on value-request for p_file.
      call function 'F4_FILENAME'
           exporting
                field_name = 'p_file'
           importing
                file_name  = p_file.
      clear itab.
      call function 'WS_UPLOAD'
           exporting
                codepage                = ' '
                filename                = p_file
                filetype                = 'DAT'
           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
                others                  = 10.
    Here you need to save your Excel file as a 'DAT' file.
    I hope this will help you.
    CHEERS
    Message was edited by: Deepak333 k

  • Create BDC group per uploading excel file to fill data in Tcode FB01l

    hi experts,
    i'm using BDC to run T-code FB01L . for this i'm uploading excel file for input data. my requiremenr=t is as follows : "
    only one BDC group should be created per uploading file."  But  At this moment BDC group is created per document. For user it is not possible to handle, say 1000 BDC groups.
    please suggest.
    Thanks
    Deepika

    The answer is simple and you should be able to work it out yourself but I am feeling generous today.
    I am assuming that each line in your excel spreadsheet is a document. The easiest way to do this is simply build up youd BDC table first then create the group.
        <- build your bdc table before opening the group ->
        call function 'BDC_OPEN_GROUP'
          exporting
            group = p_group
            keep  = p_keep
            user  = p_uname.
        call function 'BDC_INSERT'
          exporting
            tcode            = 'FB01'
          tables
            dynprotab        = gt_bdcdata
          exceptions
            internal_error   = 1
            not_open         = 2
            queue_error      = 3
            tcode_invalid    = 4
            printing_invalid = 5
            posting_invalid  = 6
            others           = 7.
    call function 'BDC_CLOSE_GROUP'
    In the future please do a search on SDN. I have also moved this thread to the ABAP General forum as this is not related to ABAP OO.

  • Uploading Excel File and Reading Data from that File

    <b>Hi
    Can anyone Please tell me how to upload an Excel File in to the Web Dynpro Application and After that i want to read the data from that uploaded excel file in the Web Dynpro Application to the Web Dynpro table.
    Plz help me to solve this.......
    Regards
    Chandran</b>

    Hi,
    Upload Excel file using File Upload UI
    1)Add jxl jar folder in the lib folder of ur project.
    2)Go to properties of ur project and add jar to ur project.
    3)Using the File upload ui ,browse and upload the file.
    4)Write the read file in to ur server location using fileoutput stream.
    5)then using code u can read the excelfile from the server location itself.
    Here is the code:
         IWDAttributeInfo attInfo =wdContext.getNodeInfo().getAttribute("upload");
    /** get the name of excel file and storing it in the server with the same name and extention****/
    binaryType=IWDModifiableBinaryTypeattInfo.getModifiableSimpleType();
    fileuploaded = binaryType.getFileName();
    byte b[] = wdContext.currentContextElement().getUpload();
    File filename =new File("
    <Server name>
    <folde name>
    " + fileuploaded);
    try {
    FileOutputStream out = new FileOutputStream(filename);
    out.write(b);
    out.close();
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    /**Readind from the server**/
    int iRows = 0;
    try {     Workbook wb = null;
         Sheet sheet = null;
         wb = Workbook.getWorkbook(filename);
         sheet = wb.getSheet(0);
         int iColumns = sheet.getColumns();
          iRows = sheet.getRows();
         int i = 0;
        //get Cell contents by (COLUMN, ROW);
        for (int r = 0; r < iRows; r++) {
       for (int c = 0; c < iColumns; c++) {
         Cell cell = sheet.getCell(c, r);
         characterarray<i> = cell.getContents();
    //wdComponentAPI.getMessageManager().reportSuccess("Row"r characterarray<i>);
    i++;
    wb.close();
    Declare Globally
    //@@begin others
    String fileuploaded;
    IWDModifiableBinaryType binaryType;
    String characterarray[] = new String[1000];
    //@@end
    Also look at this blog too  /people/perumal.kanthan/blog/2005/03/21/reading-excel-data-from-java-using-hssf-api
    Thanks and Regards,
    Arun

  • Uploading an excel file in an internal table.

    hi experts,
    I m trying to upload a excel file comprising of 16,000 records using the function module 'ALSM_EXCEL_TO_INTERNAL_TABLE' as follws
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                filename                = p_input
                i_begin_col             = 1
                i_begin_row             = 1
                i_end_col               = 30
                i_end_row               = 65000
           TABLES
                intern                  = g_t_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.
    My problem is I am unable to upload  record number 10001 else all the records are uploaded successfully
    can anyone help me in solving this problem

    FORM upload_itab .
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
      CODEPAGE                      = ' '
       FILENAME                      = p_file
       FILETYPE                      = 'ASC'
      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.

  • To upload a excel file to dB table through webdynpro ABAP

    HI,
        I am unable to upload a excel file directly by using  func module   "HR_KR_XSTRING_TO_STRING".
        If file is in tab delimited then only, I am able to upload.
        Suggest me if there are any other options to upload a excel file.

    Hi,
    The below link gives you an explanation of how you can upload an excel file to web dynpro.
    http://www.****************/Tutorials/WebDynproABAP/Upload/Page1.htm
    Kindly read go through the below link, as this issue have been brought up before
    http://forums.sdn.sap.com/thread.jspa?threadID=1831838
    Thanks and regards.
    Edited by: Suraj Ravindran Nair on Feb 24, 2012 6:24 AM

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

  • Problem in uploading an excel file in wd abap

    I am trying to upload an excel file in wd abap but on uploading it shows me the data in the form of some codes but when i try to do the same thing using text file it works well.Plese refer the code .
    METHOD onactionon_upload .
      TYPES : BEGIN OF itab_str1,
       name(10) TYPE c,
       age(10) TYPE c,
       END OF itab_str1.
      DATA : t_table1 TYPE STANDARD TABLE OF itab_str1,
            i_data TYPE STANDARD TABLE OF string,
            lo_nd_sflight TYPE REF TO if_wd_context_node,
            lo_el_sflight TYPE REF TO if_wd_context_element,
            l_string TYPE string,
            fs_table TYPE itab_str1,
            l_xstring TYPE xstring,
            fields TYPE string_table,
            lv_field TYPE string.
      DATA : t_table TYPE if_main=>elements_data_tab,
            data_table TYPE if_main=>elements_data_tab.
      wd_context->get_attribute(
      EXPORTING
        name = 'DATASOURCE'
        IMPORTING
          value = l_xstring
    CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
      EXPORTING
        in_xstring          = l_xstring
    IMPORTING
       out_string          = l_string.
    SPLIT l_string AT cl_abap_char_utilities=>newline  INTO TABLE i_data.
    LOOP AT i_data INTO l_string.
    SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.
    READ TABLE fields INTO lv_field index 1.
    fs_table-name = lv_field.
    READ TABLE fields INTO lv_field index 2.
    fs_table-age = lv_field.
    APPEND fs_table TO t_table1.
    ENDLOOP.
    lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB').
    lo_nd_sflight->bind_table( t_table1 ).
    ENDMETHOD.

    Problem is not with the file format  nor Upload element.
    problem is with conversion function module, still now for conversion of xcel data to string format we dont have perfect function module.
    CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
    EXPORTING
    in_xstring = l_xstring
    IMPORTING
    out_string = l_string.
    That's a bug with xcel conversion  As of now I dont find any fm which converts  xcel data to string without any problem.
    Regards
    Srinvivas
    Edited by: sanasrinivas on Dec 23, 2011 7:02 AM

Maybe you are looking for

  • XI Installation requires ABAP Engine???

    Hi, We have a big landscape in our organisation.We are planning to install XI (NW 2004s SR2) machine also. Our long term purpose with this installation is to replace the middlewares like Business connector,MQ etc. I want to know that at present,wheth

  • Is it possible to transfer songs from a separate iTunes account into a new one?

    I have a lot of songs saved on my Dad's mac under his apple ID.  I'd like to transfer the songs I've purchased/imported on his computer onto mine.  Is this possible through possibly the iCloud?  I'd like to avoid having to burn them all to a disc or

  • Wireless Outdoor Bridge Distance

    I have a customer that wants to use a 1532I bridge to connect two buildings.  The buildings are about 700 feet apart with a clear LoS between the two points.  Would the 1532I reach this distance?

  • Possible to read/ write word files using Java?

    I'm planning to write a Java application that can read an MS word document, extract something (including mathematics equations created with the equation editor) from the document and write it to another word document. Is it possible to do this? Can a

  • Problem in connecting to local db in procedure builder

    I install oracle 8i for window 2000 personal edition in my local computer and also forms & reports 6i. I create a db during installing of oracle 8i. By using the sql worksheet I build up several tables. But when I try to use procedure builder in form