Netbeans - How to Upload a csv File

Hi all
A J2EE question from a java beginner:
I am using NetBeans and JBoss to develop a web application.
I need to create a JSP page for user to upload a csv file and then read from the csv file (the file is in certain fixed format).
The csv file will be read line by line to be updated into database.
In JSP Page I have this:
<td align="left" scope="col"><input type="file" name="meterList" id="meterList"></td>
<td><input type="submit" name="upload" id="upload" value="Upload File" ></td>What should I do in Servlet when I clicked on the "Upload" button?
How if I want to control the uploading size and type of the the file?
How to get the file to be processed in servlet?
Your help is much appreciated.
Thanks alot.

this question has been asked a million times
try searching next time
and uploading a csv file has nothing to do with netbeans

Similar Messages

  • How to upload a .CSV file using GUI_UPLOAD

    Hi Experts,
          In my report, I need to upload .CSV file using GUI_upload..So how to do ....Plz provide solution...

    Hi prashanthishetty,
    this is already answered many times in this forum!
    use forum search or wiki search
    [http://wiki.sdn.sap.com/wiki/display/Snippets/uploadcsvfilesintointernal+table]
    regards
    rea

  • How to upload multiple .CSV files in the same time.

    Hi Legends,
    Can anyone please help me to resolve my issue?
    This is very urgent and critical.
    Description:
    We have two users.1)edw_user_dump
    2)prd_udm.
    We need to upload the xx.csv file at the same time for these two users in oracle forms.
    we have differentiated .csv file name based on the user names.
    the main problem is in the sql loader command the xx.csv file name is created but the data is not captured in the server (kentucky) .
    Below is my code for the upload.
    -- To delete the Part_Mast.log file from the client
    DECLARE
    pid WEBUTIL_HOST.PROCESS_ID;
    v_result PLS_INTEGER;
    v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
    BEGIN
    v_result := WEBUTIL_HOST.Get_return_Code(pid ) ;
    host('cat /dev/null > /tmp/'||v_username||'_'||'EDW_CF_IO_UPLOAD.log');
    host('cat /dev/null > /tmp/'||v_username||'_'||'"CF615 IO Upload.csv"');
    END;
    DECLARE
    l_success boolean:=FALSE;
    l_bare_filename varchar2(100):=NULL;
    v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
    BEGIN
    -- Delete the content of the log and bad file
    host('cat /dev/null > /tmp/'||v_username||'_'||'EDW_CF_IO_UPLOAD.log');
    --host('cat /dev/null > /tmp/Part_Mast.bad');
    -- Upload the data file to Application Server
    l_bare_filename := v_username||'_'||substr(:FIC_SOURCE,instr(:FIC_SOURCE,'\',-1)+1);
    l_success := webutil_file_transfer.Client_To_AS_with_progress
    (clientFile => :FIC_SOURCE
    ,serverFile => '/tmp/'||l_bare_filename
    ,progressTitle => 'Upload to Application Server in progress'
    ,progressSubTitle => 'Please wait'
    ,asynchronous => false
    ,callbackTrigger => null
    IF l_success THEN
    NULL;
    ELSE
    null;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE Form_Trigger_Failure;
    END;
    DECLARE
    v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
    begin
    host('cat /dev/null > /tmp/'||v_username||'_'||'EDW_CF_IO_UPLOAD.log');
    host('cat /dev/null > /tmp/EDW_CF_IO_UPLOAD.bad');
    end;
    BEGIN
    DECLARE
    v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
    v_password varchar2(30) := GET_APPLICATION_PROPERTY(PASSWORD);
    v_connect_string varchar2(30) := GET_APPLICATION_PROPERTY(CONNECT_STRING);
    a_host varchar2(500);
    BEGIN
    a_host :='/tmp/'||v_username||'_'||'"CF615 IO Upload.csv"';
    host('sqlldr '||v_username||'/'||v_password||'@'||v_connect_string||' '|| 'control=/home/edw_bis/ctl/GLB_CF_IO_UPLOAD.CTL'||' '|| 'DATA=a_host'||' '|| 'LOG=/tmp/'||v_username||'_'||'EDW_CF_IO_UPLOAD.log SKIP=1 errors=200000 DIRECT=FALSE');
    dbms_output.put_line(a_host);
    END;
    DECLARE
    v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
    begin
    host('cat /dev/null > /tmp/'||v_username||'_'||'"CF615 IO Upload.csv"');
    EXCEPTION
    WHEN OTHERS THEN
    RAISE Form_Trigger_Failure;
    END;
    end;
    DECLARE
    al_id3 ALERT;
    al_button Number;
    BEGIN
    edw_user_dump.SANM_PRC_MERGE_CF_IO_UPLOAD(:global.v_plsql_res,:global.v_ins_rec,:global.v_upd_rec);
    IF NVL(:global.v_plsql_res,0) = 0 and (:global.v_ins_rec !=0 OR :global.v_upd_rec != 0 ) then
    al_id3 :=FIND_ALERT('ROWINS');
    SET_ALERT_PROPERTY(al_id3,alert_message_text,' Process Completed Successfully!'||CHR(10)||' Rows Inserted : '||:global.v_ins_rec ||CHR(10)||' Rows Updated : '||:global.v_upd_rec);
    al_button := SHOW_ALERT( al_id3 );
    ELSIF (:global.v_plsql_res IN(-1,0) or :global.v_plsql_res > 0) and (:global.v_ins_rec =0 and :global.v_upd_rec = 0 and :global.v_del_rec =0 ) then
    al_id3 :=FIND_ALERT('ROWINS');
    SET_ALERT_PROPERTY(al_id3,alert_message_text,' Process Failed. Please Download the Log File '||CHR(10)||' Rows Failed : '||:global.v_plsql_res||CHR(10)||' Rows Inserted : '||:global.v_ins_rec ||CHR(10)||' Rows Updated : '||:global.v_upd_rec);
    al_button := SHOW_ALERT( al_id3 );
    ELSE
    al_id3 :=FIND_ALERT('ROWINS');
    SET_ALERT_PROPERTY(al_id3,alert_message_text,'Please Download the Log File '||CHR(10)||' Rows Failed : '||:global.v_plsql_res||CHR(10)||' Rows Inserted : '||:global.v_ins_rec ||CHR(10)||' Rows Updated : '||:global.v_upd_rec );
    al_button := SHOW_ALERT( al_id3 );
    END IF;
    EXCEPTION WHEN OTHERS THEN
    RAISE Form_Trigger_Failure;
    END;
    DECLARE
    v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
    begin
    host('cat /dev/null > /tmp/'||v_username||'_'||'"CF615 IO Upload.csv"');
    host('rm -rf /tmp/'||v_username||'_'||'"CF615 IO Upload.csv"');
    end;
    Thanks in advance!
    Thanks,
    Madhusudhanan

    Madhusudhanan,
    A couple of observations. First; always list your exact Forms version (eg; 10.1.2.0.2 not 10g R2). In most cases, the solution is different depending on the Forms version. Second; why must you use Forms to kick off a SQL Loader process? This is a server-side process and should be initiated by a server side process. If you absolutely must use Forms to kick off the process, again we need your Forms version in order to offer any solutions. Based on your code sample, I can asusme you are at least using Forms 9i becuase you are using WebUtil.
    Is your Database and Application Server the same physical computer? If they are not, this would explain why your HOST command isn't working because HOST runs against the Application Server not the Database server.
    Third; have you considered using and External Table (if your RDBMS version supports them) for each of the files you are attempting to upload? In this instance, it would be helpful to know your RDBMS version as well. External Tables can be a little frustrating to set up the first time, but as with any new construct you use - it gets easier the more you use it.
    Fourth; are you getting any errors in your log file(s)? If so, what are the errors? Please list the full error message if you have one.
    Finally, with respects to your statement:
    Posted: Mar 18, 2011 2:30 PM - Madhu This is very urgent and critical.>
    You have to understand that forum contributers are all volunteers - this is not our full-time job. If your issue is truely urgent I suggest you open a Service Request (SR) with Oracle Support! ;-)
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • How to use GUI_upload for Uploading a CSV file in Microsoft Excel.

    Hi Guys,
                  can anybody tell me how to Upload the CSV format file in Microsoft excel sheet?
    Thanks,
    Gopi.

    Hi Gopi,
    u can use GUI_UPLOAD, TEXT_CONVERT_XLS_TO_SAP.
    Please check these codes.
    Uploading data from CSV file format into internal table using GUI_UPLOAD
    REPORT zupload MESSAGE-ID bd.
    DATA: w_tab TYPE ZTEST.
    DATA: i_tab TYPE STANDARD TABLE OF ZTEST.
    DATA: v_subrc(2),
    v_recswritten(6).
    PARAMETERS: p_file(80)
    DEFAULT 'C:\Temp\ZTEST.TXT'.
    DATA: filename TYPE string,
    w_ans(1) TYPE c.
    filename = p_file.
    CALL FUNCTION 'POPUP_TO_CONFIRM'
    EXPORTING
    titlebar = 'Upload Confirmation'
    * DIAGNOSE_OBJECT = ' '
    text_question = p_file
    text_button_1 = 'Yes'(001)
    * ICON_BUTTON_1 = ' '
    text_button_2 = 'No'(002)
    * ICON_BUTTON_2 = ' '
    default_button = '2'
    * DISPLAY_CANCEL_BUTTON = 'X'
    * USERDEFINED_F1_HELP = ' '
    * START_COLUMN = 25
    * START_ROW = 6
    * POPUP_TYPE =
    * IV_QUICKINFO_BUTTON_1 = ' '
    * IV_QUICKINFO_BUTTON_2 = ' '
    IMPORTING
    answer = w_ans
    * TABLES
    * PARAMETER =
    * EXCEPTIONS
    * TEXT_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.
    CHECK w_ans = 1.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = filename
    * FILETYPE = 'ASC
    has_field_separator = 'X'
    * HEADER_LENGTH = 0
    * READ_BY_LINE = 'X'
    * IMPORTING
    * FILELENGTH =
    * HEADER =
    TABLES
    data_tab = i_tab
    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.
    * SYST FIELDS ARE NOT SET BY THIS FUNCTION SO DISPLAY THE ERROR CODE *
    IF sy-subrc <> 0.
    v_subrc = sy-subrc.
    MESSAGE e899 WITH 'File Open Error' v_subrc.
    ENDIF.
    INSERT ZTEST FROM TABLE i_tab.
    COMMIT WORK AND WAIT.
    MESSAGE i899 WITH sy-dbcnt 'Records Written to ZTEST'.
    Uploading data from Excel file format into internal table using TEXT_CONVERT_XLS_TO_SAP
    REPORT  zupload_excel_to_itab.
    TYPE-POOLS: truxs.
    PARAMETERS: p_file TYPE  rlgrap-filename.
    TYPES: BEGIN OF t_datatab,
          col1(30)    TYPE c,
          col2(30)    TYPE c,
          col3(30)    TYPE c,
          END OF t_datatab.
    DATA: it_datatab type standard table of 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.
      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.
      LOOP AT it_datatab INTO wa_datatab.
        WRITE:/ wa_datatab-col1,
                wa_datatab-col2,
                wa_datatab-col3.
      ENDLOOP.
    reward if helpful
    raam

  • How to align the CSV file on upload?

    Hi All,
    I have to upload a CSV file as an attachment in a mail and the data's in the internal table which has to be uploaded in the CSV file are seperated using commas which on uploading appear in the CSV file in the same column but i need the data's to be seperated in different columns and different lines...
    Pls help it is very urgent..
    Thanks in Advance...

    Hi
    For my understanding you are talking about download.
    For that you have to concatenate each fields of final internal table (gt_itab for example) using comma as below.
    TYPES: BEGIN OF ty_lines,
             line(1023) TYPE c,
           END OF ty_lines.
    DATA: l_filename TYPE string VALUE 'C:\temp\abcd.csv',
          gt_lines  TYPE TABLE OF ty_lines,
          gw_lines  TYPE ty_lines.
      LOOP AT gt_itab INTO gw_itab.
        CONCATENATE gw_itab-f1
                    gw_itab-f2 .....
               INTO gw_lines-line
               SEPARATED BY ','.
         APPEND gw_lines TO gt_lines.
      ENDLOOP.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = l_filename
          filetype                = 'ASC'
          confirm_overwrite       = 'X'
          no_auth_check           = 'X'
        TABLES
          data_tab                = gt_lines.

  • Uploading a CSV file

    When I try to upload a CSV file in my program it gives me an error message - Do not have an E-mail address column even though I do have an E-mail column and a list of E-mail addresses. How can I resolve this problem?

    What email program are you using? I sent a .csv file via Mail, it worked perfectly.

  • How to save a .csv file to database server

    Hi every body,
    I need to upload a .csv file from the client machine and save it to a directory in a database sever.
    I could do the uploading part. Can anyone tell me how to save the file?
    Another option is save the file as a CLOB in a database column. But I'm not aware of doing that too.
    Please guide me.
    Thanks in advance.
    Surangi.

    See Steve Muench's Not Yet Documented Example #85 at http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html#85. While this is for 10.1.3, this is still relevant for 11g. Steve's example is for uploading to a BLOB - same thing for a CLOB. Once your data is in the database, you can use the DBMS_LOB package to write the file to a directory on the database server, if you like.
    Also the Developers Guide is your friend - Chapter 9.9 in the Fusion Web User Interface Developers Guide for Oracle ADF 11g, or 19.6 in the ADF Developers Guide for Forms/4GL Developers for JDeveloper 10.1.3.

  • Flat File Upload as CSV File in BPS.

    Hi Friends,
    We have to upload CSV file to BPS and as of now we are able to upload tab spaced file as per the How to Document.
    Kindly can some body post the COMPLETE CODE changes for Uploading the CSV File in both LOAD and WEB Function Modules.
    For complete code points are guaranteed.

    Hi BI,
    please check the following thread.
    Load flat file to BPS - GUI issue
    I've implemented the file upload for CSV file. please note the changes i've made -
    Code for INIT function module :-
    FUNCTION Z_BPS_FILE_UPLOAD_INIT_CSV.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(I_AREA) TYPE  UPC_Y_AREA
    *"     VALUE(I_PLEVEL) TYPE  UPC_Y_PLEVEL OPTIONAL
    *"     VALUE(I_PACKAGE) TYPE  UPC_Y_PACKAGE OPTIONAL
    *"     VALUE(I_METHOD) TYPE  UPC_Y_METHOD OPTIONAL
    *"     VALUE(I_PARAM) TYPE  UPC_Y_PARAM OPTIONAL
    *"     REFERENCE(IT_EXITP) TYPE  UPF_YT_EXITP OPTIONAL
    *"     REFERENCE(ITO_CHASEL) TYPE  UPC_YTO_CHASEL OPTIONAL
    *"     REFERENCE(ITO_CHA) TYPE  UPC_YTO_CHA OPTIONAL
    *"     REFERENCE(ITO_KYF) TYPE  UPC_YTO_KYF OPTIONAL
    *"  EXPORTING
    *"     REFERENCE(ETO_CHAS) TYPE  ANY TABLE
    *"     REFERENCE(ET_MESG) TYPE  UPC_YT_MESG
      DATA: lto_chas TYPE yto_chas,
      ls_chas     TYPE ys_chas,
      ls_exitp    TYPE upf_ys_exitp,
      ls_mesg     TYPE upc_ys_mesg,
      ls_chasel   TYPE upc_ys_chasel, "<<<INSERT
      ls_charng   TYPE upc_ys_charng. "<<<INSERT
      DATA: lt_filetab TYPE filetable,
      ls_filetab   TYPE file_table,
      l_file       TYPE string,
      l_separator  TYPE char01,
      l_action     TYPE i,
      l_count      TYPE i.
      FIELD-SYMBOLS: <f> TYPE ANY. "<<<INSERT
    Try to get file name from parameter
      READ TABLE it_exitp INTO ls_exitp WITH KEY parnm = 'FILENAME'.
      IF sy-subrc = 0.
        l_file = ls_exitp-chavl.
      ENDIF.
    If no file name is given, prompt user for it
      IF l_file IS INITIAL.
        CALL METHOD cl_gui_frontend_services=>file_open_dialog
          EXPORTING
            window_title            = 'Select Upload File'
            default_extension       = 'csv'
            file_filter             = 'Text Files (*.csv)'
          CHANGING
            file_table              = lt_filetab
            rc                      = l_count
            user_action             = l_action
          EXCEPTIONS
            file_open_dialog_failed = 1
            cntl_error              = 2
            OTHERS                  = 3.                        "#EC NOTEXT
        IF sy-subrc <> 0.
          CLEAR ls_mesg.
          MOVE-CORRESPONDING syst TO ls_mesg.
          APPEND ls_mesg TO et_mesg.
          EXIT.
        ENDIF.
        CALL METHOD cl_gui_cfw=>flush.
        LOOP AT lt_filetab INTO ls_filetab.
          l_file = ls_filetab.
        ENDLOOP.
        CHECK l_action = 0.
      ENDIF.
      l_separator = 'X'.
    Upload file from front-end (PC)
    File format is tab-delimited ASCII
    l_separator = ';' .
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = l_file
         filetype                = 'DAT'
         has_field_separator     = l_separator
        TABLES
          data_tab                = gt_file_csv
        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.
        CLEAR ls_mesg.
        MOVE-CORRESPONDING syst TO ls_mesg.
        APPEND ls_mesg TO et_mesg.
        EXIT.
      ENDIF.
    Create one dummy combination
    If we don't do this, the upload won't work since the second function
    will not be executed at all in case no transaction data exists so far.
    The combination must be a subset of the planning level!
      " >>> BEGIN INSERT
      CLEAR ls_chas.
      LOOP AT ito_chasel INTO ls_chasel.
        READ TABLE ls_chasel-t_charng INTO ls_charng INDEX 1.
        IF sy-subrc = 0.
          ASSIGN COMPONENT ls_chasel-chanm OF STRUCTURE ls_chas TO <f>.
          IF sy-subrc = 0.
            <f> = ls_charng-low.
          ENDIF.
        ENDIF.
      ENDLOOP.
      " <<< END INSERT
      COLLECT ls_chas INTO lto_chas.
      eto_chas = lto_chas.
    ENDFUNCTION.
    Include should contains following declarations-
    TYPES:      begin of itab_CSV,
                           text(255) type c,
                     end of itab_CSV.
    Global table to temporarily store loaded data.
    DATA: gt_file_CSV TYPE STANDARD TABLE OF itab_csv WITH DEFAULT
    KEY.
    Hope it will help you.
    Regards
    Tarun

  • How to import an .csv file into the database?

    and can we code the program in JSP to import the.csv file into the database.

    It is better to use Java class to read the CSV file and store the contents in the database.
    You can use JSP to upload the CSV file to the server if you want, but don't use it to perform database operations.
    JSPs are good for displaying information on the front-end, and for displaying HTML forms, there are other technologies more suitable for the middle layer, back end and the database layer.
    So break you application into
    1) Front end - JSPs to display input html forms and to display data retrieved from the database.
    2) Middle layer - Servlets and JavaBeans to interact with JSPs. The code that reads the CSV file to parse it's contents should be a Java Class in the middle layer. It makes use of Java File I/O
    3) Database layer - Connects to the database using JDBC (Java Database Connectivity), and then writes to the database with SQL insert statements.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Keeping the above concepts in mind, first build a simple JSP and get it to work,
    then research on Google , for Java File I/O , discover how to read a file,
    Then search on how to readh a CSV file using Java.
    After researching you should be able to read the CSV file line by line and store each line inside a Collection.
    Then research on Google, on how to write to the database using JDBC
    Write a simple program that inserts something to a dummy table in the database.
    Then, read the data stored in the Collection, and write insert statements for each records in the collection.

  • VISA: How to get the CSV file through C/C++ code?

    How to get the CSV file through C/C++ code?
    I'm communicating with a USB oscilloscope using VISA.

    Thank you for your reply.
    I am using Apache Commons File Upload. Here is the code where I got the "fi".
         DiskFileUpload fu = new DiskFileUpload();
              fu.setSizeMax(1000000000);
              List fileItems = fu.parseRequest(request);
             Iterator itr = fileItems.iterator();
              FileItem fi = (FileItem)itr.next();
              if(!fi.isFormField())
                File tempFileRef  = new File(fi.getName());
         System.out.println("Field = "+tempFileRef.getAbsolutePath());
         }

  • Upload a csv file in application server with the specified codepage(Poland

    Hi,
    i want to upload a csv file in application server with the specified codepage ( for poland ) , please let me know how to use open dataset for that.?
    Anurag

    I would upload the file with transaction CG3Z in binary mode and do the code page translation with a report: read from server an save with different name.

  • How to upload a text file from a shared folder and provide an o/p

    how to upload a text file from a shared folder and provide an o/p  containing the details in each order in the text file

    Hi,
    Use <b>GUI_UPLOAD</b> to upload a text file from a shared folder.
    Use <b>GUI_DOWNLOAD</b> to download data in a file on the presentation server or use <b>OPEN DATASET, TRANSFER</b> and <b>CLOSE DATASET</b> statements to download data to the application server.
    Now, I hope the code for data fetching, if required, is already present in the report.
    Reward points if the answer is helpful.
    Regards,
    Mukul

  • How to create a CSV file in java

    how to create a CSV file in java

    this is the code that I have used in a hp project:
    private static final String DELIMIT = ",";
    StringBuffer buf = new StringBuffer();
    public void addString(String str){
    buf.append(toEscapedStringLiteral(str.replaceAll(" ","").trim())).append(DELIMIT);
    public void sendFile( String strData ,
                                String strTitle,
                                String strContType,
                                HttpServletResponse res ) throws IOException {
              byte[] _filedata=strData.getBytes();
              res.setContentType( strContType );
              res.setHeader( "Content-Disposition", "attachment;filename="+ strTitle );     
                     DataOutputStream out = new DataOutputStream( res.getOutputStream() );
              out.write( _filedata, 0, _filedata.length );
              out.close();
    public void addStringWhithReturn(String str){
              buf.append(toEscapedStringLiteral(str.replaceAll(" ","").trim()));
              buf.append( "\n" );
    private String toEscapedStringLiteral( String charSeq ) {
              if ( null == charSeq ) {
                   charSeq = "";
              return "\"" + charSeq + "\"";
    ....hope its help
    kou

  • How to upload an excel file using ABAP.

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

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

  • Uploading a CSV file and getting Error ORA-01403: no data found in V4.1.1.

    I have an issue where myself and another user are unable to upload a csv file to my application using the "File Browse" page item in V4.1.1. I get the following error, "Error ORA-01403: no data found".
    This function was working perfectly last week prior to the upgrade of our APEX to V4.1.1 from V3. Other users are still able to upload the csv file, so the PL/SQL behind it must be ok.
    So here is where I am up to with testing.
    Tested the upload using my login on my PC – Fail
    Tested the upload using my login on another PC – Fail
    Tested the upload using other user’s login on my PC – Success
    Tested the upload using other user’s login on another PC - Success
    Any help would be greatly appreciated.
    Cheers,
    Greg

    The offending piece of code was in a block of script that I used from an online sample when I was first setting up this upload script. A colleague had the same issue in another application and rewrote the script to resolve the issue, see below.
    I'm still perplexed as to why the majority of users could run it ok, and there were only 2 of us that it errored on. But now it's working for all, and I can go back to building some cool stuff in V4.1.1.00.23.
    -- Read data from wwv_flow_files
    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_USERID)
    and id = (select max(id) from wwv_flow_files where updated_by = :APP_USERID);
    -- Rewritten to the following, which works.
    select blob_content into v_blob_data
    from wwv_flow_files
    where id = (select ID from wwv_flow_files
    where UPDATED_BY = :APP_USERID
    and LAST_UPDATED = (select max(LAST_UPDATED) from wwv_flow_files where UPDATED_BY = :APP_USERID));

Maybe you are looking for