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 .

Similar Messages

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

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

  • 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

  • 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 the excel File to the Internal Table

    Hello Friends,
    i wrote the source code like this,
    iam getting the run time error can u tell where iam going wrong.
    data : begin of itab occurs 3,
           a type i,
           b type i,
           end of itab.
           CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
             EXPORTING
               FILENAME  = 'D:\Siemens\asd.xls'
               I_BEGIN_COL                   = 1
               I_BEGIN_ROW                   = 1
               I_END_COL                     = 2
               I_END_ROW                     = 3
             TABLES
               INTERN                        = itab
            EXCEPTIONS
              INCONSISTENT_PARAMETERS       = 1
              UPLOAD_OLE                    = 2
              OTHERS                        = 3
           IF SY-SUBRC <> 0.
    write : / 'this is not executed'.
    exit.
           ENDIF.
           loop at itab.
           write : / itab-a,itab-b.
           endloop.
    and in excel file the data is
    1     2
    3     4
    5     6

    Hi,
    Currently in ur program, FM is returning the value but on getting the value 'EXIT, command is executed. This might be the cause of the problem.
    Try like this:
    data : begin of itab occurs 3,
    a type i,
    b type i,
    end of itab.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    FILENAME = 'D:\Siemens\asd.xls'
    I_BEGIN_COL = 1
    I_BEGIN_ROW = 1
    I_END_COL = 2
    I_END_ROW = 3
    TABLES
    INTERN = itab
    EXCEPTIONS
    INCONSISTENT_PARAMETERS = 1
    UPLOAD_OLE = 2
    OTHERS = 3
    IF SY-SUBRC 0.
    If sy-subrc ne 0.
    write : / 'this is not executed'.
    else.
    loop at itab.
    write : / itab-a,itab-b.
    endloop.
    ENDIF.
    Thanks,
    Parul.

  • Upload of excel file in to purchase order

    hi guys,
                  i want to upload a excel file to the internal table and then to create the purchase order.
    i know the name of function module and bapi.
    but how to make use of them in implementation!!!
    fun module : ALSM_EXCEL_TO_INTERNAL_TABLE
    bapi :       BAPI_PO_CREATE1.
                                                                                    arun and vishnu from
                                                                    infotech solutions

    *CREATION OF A TEMPORARY STRUCTURE FOR INSERTING FIELDS OF EXCEL TO INTERNAL TABLE.
    TYPES : BEGIN OF STR_FINAL,
             COMP_CODE TYPE BAPIMEPOHEADER-COMP_CODE,    " STRUCTURE : BAPIMEPOHEADER
             ITEM_INTVL TYPE BAPIMEPOHEADER-ITEM_INTVL,
             VENDOR TYPE BAPIMEPOHEADER-VENDOR,
             PMNTTRMS TYPE BAPIMEPOHEADER-PMNTTRMS,
             PURCH_ORG TYPE BAPIMEPOHEADER-PURCH_ORG,
             PUR_GROUP  TYPE BAPIMEPOHEADER-PUR_GROUP,
             CURRENCY TYPE BAPIMEPOHEADER-CURRENCY,
             PO_ITEM  TYPE BAPIMEPOITEM-PO_ITEM,         " STRUCTURE : BAPIMEPOITEM
             MATERIAL TYPE BAPIMEPOITEM-MATERIAL,
             PLANT TYPE BAPIMEPOITEM-PLANT,
             STGE_LOC  TYPE BAPIMEPOITEM-STGE_LOC,
             QUANTITY TYPE BAPIMEPOITEM-QUANTITY,
             TAX_CODE  TYPE BAPIMEPOITEM-TAX_CODE,
             ITEM_CAT TYPE BAPIMEPOITEM-ITEM_CAT,
             ACCTASSCAT TYPE BAPIMEPOITEM-ACCTASSCAT,
             SCHED_LINE TYPE BAPIMEPOSCHEDULE-SCHED_LINE,        " STRUCTURE : BAPIMEPOSCHEDULE
             DELIVERY_DATE TYPE BAPIMEPOSCHEDULE-DELIVERY_DATE,
             SERIAL_NO TYPE BAPIMEPOACCOUNT-SERIAL_NO,           " STRUCTURE  : BAPIMEPOACCOUNT
             GL_ACCOUNT TYPE BAPIMEPOACCOUNT-GL_ACCOUNT,
             COSTCENTER TYPE BAPIMEPOACCOUNT-COSTCENTER,
             CO_AREA TYPE BAPIMEPOACCOUNT-CO_AREA,
             END OF STR_FINAL.
    DATA :   IT_FINAL TYPE TABLE OF STR_FINAL,
             WA_FINAL TYPE STR_FINAL.
    DATA: ST_BAPIMEPOHEADER TYPE BAPIMEPOHEADER,
          ST_BAPIMEPOHEADERX TYPE BAPIMEPOHEADERX.
    *it is for item data
    DATA: WA_POITEM TYPE BAPIMEPOITEM,
          IT_POITEM TYPE TABLE OF BAPIMEPOITEM,
          WA_POITEMX TYPE BAPIMEPOITEMX,
          IT_POITEMX TYPE TABLE OF BAPIMEPOITEMX,
          WA_POSCHEDULE TYPE BAPIMEPOSCHEDULE,
          IT_POSCHEDULE TYPE TABLE OF BAPIMEPOSCHEDULE,
          WA_POSCHEDULEX TYPE BAPIMEPOSCHEDULX,
          IT_POSCHEDULEX TYPE TABLE OF BAPIMEPOSCHEDULX,
          WA_POACCOUNT TYPE BAPIMEPOACCOUNT,
          IT_POACCOUNT TYPE TABLE OF BAPIMEPOACCOUNT,
          WA_POACCOUNTX TYPE BAPIMEPOACCOUNTX,
          IT_POACCOUNTX TYPE TABLE OF BAPIMEPOACCOUNTX,
          WA_RETURN TYPE BAPIRET2,
          IT_RETURN TYPE TABLE OF BAPIRET2.
    selection-screen skip 1.
    parameters: p_file type localfile default 'D:\VISHNU\DEMO.XLS'.
    *selection-screen skip 1.
    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.
    clear IT_FINAL.
    refresh IT_FINAL.
      perform upload_data.
    loop at IT_FINAL INTO WA_FINAL.
        write:/  WA_FINAL-COMP_CODE,
              /  WA_FINAL-ITEM_INTVL,
              /  WA_FINAL-VENDOR,
              /  WA_FINAL-PMNTTRMS,
              /  WA_FINAL-PURCH_ORG,
              /  WA_FINAL-PUR_GROUP,
              /  WA_FINAL-CURRENCY,
              /  WA_FINAL-PO_ITEM,
              /  WA_FINAL-MATERIAL,
              /  WA_FINAL-PLANT,
              /  WA_FINAL-STGE_LOC,
              /  WA_FINAL-QUANTITY,
              /  WA_FINAL-TAX_CODE,
              /  WA_FINAL-ITEM_CAT,
              /  WA_FINAL-ACCTASSCAT,
              /  WA_FINAL-SCHED_LINE,
              /  WA_FINAL-DELIVERY_DATE,
              /  WA_FINAL-SERIAL_NO,
              /  WA_FINAL-GL_ACCOUNT,
              /  WA_FINAL-COSTCENTER,
              /  WA_FINAL-CO_AREA.
      endloop.
    LOOP AT IT_FINAL INTO WA_FINAL.
    ST_BAPIMEPOHEADER-COMP_CODE = WA_FINAL-COMP_CODE.
    ST_BAPIMEPOHEADER-DOC_TYPE = 'NB'.
    ST_BAPIMEPOHEADER-ITEM_INTVL = WA_FINAL-ITEM_INTVL.
    ST_BAPIMEPOHEADER-VENDOR = WA_FINAL-VENDOR.
    ST_BAPIMEPOHEADER-LANGU = SY-LANGU.
    ST_BAPIMEPOHEADER-PMNTTRMS = WA_FINAL-PMNTTRMS.
    ST_BAPIMEPOHEADER-PURCH_ORG = WA_FINAL-PURCH_ORG.
    ST_BAPIMEPOHEADER-PUR_GROUP = WA_FINAL-PUR_GROUP.
    ST_BAPIMEPOHEADER-CURRENCY = WA_FINAL-CURRENCY.
    *insert ST_BAPIMEPOHEADERX values
    ST_BAPIMEPOHEADERX-COMP_CODE = 'X'.
    ST_BAPIMEPOHEADERX-DOC_TYPE = 'X'.
    ST_BAPIMEPOHEADERX-ITEM_INTVL = 'X'.
    ST_BAPIMEPOHEADERX-VENDOR = 'X'.
    ST_BAPIMEPOHEADERX-LANGU = 'X'.
    ST_BAPIMEPOHEADERX-PMNTTRMS = 'X'.
    ST_BAPIMEPOHEADERX-PURCH_ORG = 'X'.
    ST_BAPIMEPOHEADERX-PUR_GROUP = 'X'.
    ST_BAPIMEPOHEADERX-CURRENCY = 'X'.
    *insert IT_POITEM values
    WA_POITEM-PO_ITEM = WA_FINAL-PO_ITEM.
    WA_POITEM-MATERIAL = WA_FINAL-MATERIAL.
    WA_POITEM-PLANT = WA_FINAL-PLANT.
    WA_POITEM-STGE_LOC = WA_FINAL-STGE_LOC.
    WA_POITEM-QUANTITY = WA_FINAL-QUANTITY.
    WA_POITEM-TAX_CODE = WA_FINAL-TAX_CODE.
    WA_POITEM-ITEM_CAT = WA_FINAL-ITEM_CAT.
    WA_POITEM-ACCTASSCAT = WA_FINAL-ACCTASSCAT.
    APPEND WA_POITEM TO IT_POITEM.
    CLEAR WA_POITEM.
    *insert IT_POITEMX values
    WA_POITEMX-PO_ITEM = WA_FINAL-PO_ITEM.
    WA_POITEMX-PO_ITEMX = 'X'.
    WA_POITEMX-MATERIAL = 'X'.
    WA_POITEMX-PLANT = 'X'.
    WA_POITEMX-STGE_LOC = 'X'.
    WA_POITEMX-QUANTITY = 'X'.
    WA_POITEMX-TAX_CODE = 'X'.
    WA_POITEMX-ITEM_CAT = 'X'.
    WA_POITEMX-ACCTASSCAT = 'X'.
    APPEND WA_POITEMX TO IT_POITEMX.
    CLEAR WA_POITEMX.
    *insert IT_POSCHEDULE values
    WA_POSCHEDULE-PO_ITEM = WA_FINAL-PO_ITEM.
    WA_POSCHEDULE-SCHED_LINE =  WA_FINAL-SCHED_LINE.
    WA_POSCHEDULE-DELIVERY_DATE = WA_FINAL-DELIVERY_DATE .
    WA_POSCHEDULE-QUANTITY = WA_FINAL-QUANTITY.
    APPEND WA_POSCHEDULE TO IT_POSCHEDULE.
    CLEAR WA_POSCHEDULE.
    *insert IT_POSCHEDULEX values
    WA_POSCHEDULEX-PO_ITEM = WA_FINAL-PO_ITEM.
    WA_POSCHEDULEX-SCHED_LINE = WA_FINAL-SCHED_LINE.
    WA_POSCHEDULEX-PO_ITEMX = 'X' .
    WA_POSCHEDULEX-SCHED_LINEX = 'X' .
    WA_POSCHEDULEX-DELIVERY_DATE = 'X' .
    WA_POSCHEDULEX-QUANTITY = 'X' .
    WA_POSCHEDULEX-PO_ITEM = WA_FINAL-PO_ITEM .
    WA_POSCHEDULEX-SCHED_LINE = WA_FINAL-SCHED_LINE.
    WA_POSCHEDULEX-PO_ITEMX = 'X'.
    WA_POSCHEDULEX-SCHED_LINEX = 'X' .
    WA_POSCHEDULEX-DELIVERY_DATE = 'X' .
    WA_POSCHEDULEX-QUANTITY = 'X'.
    WA_POSCHEDULEX-PO_ITEM = WA_FINAL-PO_ITEM.
    WA_POSCHEDULEX-SCHED_LINE = WA_FINAL-SCHED_LINE.
    WA_POSCHEDULEX-PO_ITEMX = 'X'.
    WA_POSCHEDULEX-SCHED_LINEX = 'X'.
    WA_POSCHEDULEX-DELIVERY_DATE = 'X' .
    WA_POSCHEDULEX-QUANTITY = 'X'.
    APPEND WA_POSCHEDULEX TO IT_POSCHEDULEX.
    CLEAR WA_POSCHEDULEX.
    *insert IT_POACCOUNT values
    WA_POACCOUNT-PO_ITEM = WA_FINAL-PO_ITEM.
    WA_POACCOUNT-SERIAL_NO = WA_FINAL-SERIAL_NO.
    WA_POACCOUNT-QUANTITY = WA_FINAL-QUANTITY .
    WA_POACCOUNT-GL_ACCOUNT = WA_FINAL-GL_ACCOUNT.
    WA_POACCOUNT-COSTCENTER = WA_FINAL-COSTCENTER.
    WA_POACCOUNT-CO_AREA = WA_FINAL-CO_AREA.
    APPEND WA_POACCOUNT TO IT_POACCOUNT.
    CLEAR WA_POACCOUNT.
    *insert IT_POACCOUNTX values
    WA_POACCOUNTX-PO_ITEM = 00001.
    WA_POACCOUNTX-SERIAL_NO = 01.
    WA_POACCOUNTX-QUANTITY = 'X'.
    WA_POACCOUNTX-GL_ACCOUNT = 'X'.
    WA_POACCOUNTX-COSTCENTER = 'X' .
    WA_POACCOUNTX-CO_AREA = 'X'.
    APPEND WA_POACCOUNTX TO IT_POACCOUNTX.
    CLEAR WA_POACCOUNTX.
    ENDLOOP.
    CALL FUNCTION 'BAPI_PO_CREATE1'
      EXPORTING
        POHEADER                     = ST_BAPIMEPOHEADER
       POHEADERX                     = ST_BAPIMEPOHEADERX
      POADDRVENDOR                 =
      TESTRUN                      =
      MEMORY_UNCOMPLETE            =
      MEMORY_COMPLETE              =
      POEXPIMPHEADER               =
      POEXPIMPHEADERX              =
      VERSIONS                     =
    IMPORTING
      EXPPURCHASEORDER             =
      EXPHEADER                    =
      EXPPOEXPIMPHEADER            =
    TABLES
       RETURN                       = IT_RETURN
       POITEM                       = IT_POITEM
       POITEMX                      = IT_POITEMX
      POADDRDELIVERY               =
       POSCHEDULE                   = IT_POSCHEDULE
       POSCHEDULEX                  = IT_POSCHEDULEX
       POACCOUNT                    = IT_POACCOUNT
      POACCOUNTPROFITSEGMENT       =
       POACCOUNTX                   = IT_POACCOUNTX
      POCONDHEADER                 =
      POCONDHEADERX                =
      POCOND                       =
      POCONDX                      =
      POLIMITS                     =
      POCONTRACTLIMITS             =
      POSERVICES                   =
      POSRVACCESSVALUES            =
      POSERVICESTEXT               =
      EXTENSIONIN                  =
      EXTENSIONOUT                 =
      POEXPIMPITEM                 =
      POEXPIMPITEMX                =
      POTEXTHEADER                 =
      POTEXTITEM                   =
      ALLVERSIONS                  =
      POPARTNER                    =
    *this is for save the porder number
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    *dispaly the results
    LOOP AT IT_RETURN INTO WA_RETURN.
      WRITE:/ WA_RETURN-MESSAGE,
              ST_BAPIMEPOHEADER-PO_NUMBER.
    ENDLOOP.
    form upload_data.
      data: file type  rlgrap-filename.
      data: IT_XCEL type table of alsmex_tabline,
            WA_XCEL TYPE ALSMEX_TABLINE.
      file = p_file.
      call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           exporting
                filename                = file
                i_begin_col             = '1'
                i_begin_row             = '1'
                i_end_col               = '21'
                i_end_row               = '1'
           tables
                intern                  = IT_xcel
           exceptions
                inconsistent_parameters = 1
                upload_ole              = 2
                others                  = 3.
      loop at IT_xcel INTO WA_XCEL.
        case
            WA_XCEL-COL.
            when '0001'.
            WA_FINAL-COMP_CODE = WA_xcel-value.
            WHEN '0002'.
            WA_FINAL-ITEM_INTVL = WA_XCEL-VALUE.
            WHEN '0003'.
            WA_FINAL-VENDOR = WA_XCEL-VALUE.
            WHEN '0004'.
            WA_FINAL-PMNTTRMS = WA_XCEL-VALUE.
            WHEN '0005'.
            WA_FINAL-PURCH_ORG = WA_XCEL-VALUE.
            WHEN '0006'.
            WA_FINAL-PUR_GROUP = WA_XCEL-VALUE.
            WHEN '0007'.
            WA_FINAL-CURRENCY = WA_XCEL-VALUE.
            WHEN '0008'.
            WA_FINAL-PO_ITEM = WA_XCEL-VALUE.
            WHEN '0009'.
            WA_FINAL-MATERIAL = WA_XCEL-VALUE.
            WHEN '00010'.
            WA_FINAL-PLANT = WA_XCEL-VALUE.
            WHEN '00011'.
            WA_FINAL-STGE_LOC = WA_XCEL-VALUE.
            WHEN '00012'.
            WA_FINAL-QUANTITY = WA_XCEL-VALUE.
            WHEN '00013'.
            WA_FINAL-TAX_CODE = WA_XCEL-VALUE.
            WHEN '00014'.
            WA_FINAL-ITEM_CAT = WA_XCEL-VALUE.
            WHEN '00015'.
            WA_FINAL-ACCTASSCAT = WA_XCEL-VALUE.
            WHEN '00016'.
            WA_FINAL-SCHED_LINE = WA_XCEL-VALUE.
            WHEN '00017'.
            WA_FINAL-DELIVERY_DATE = WA_XCEL-VALUE.
            WHEN '00018'.
            WA_FINAL-SERIAL_NO = WA_XCEL-VALUE.
            WHEN '00019'.
            WA_FINAL-GL_ACCOUNT = WA_XCEL-VALUE.
            WHEN '00020'.
            WA_FINAL-COSTCENTER = WA_XCEL-VALUE.
            WHEN '00021'.
            WA_FINAL-CO_AREA = WA_XCEL-VALUE.
            ENDCASE.
            at end of row.
          append WA_FINAL TO  IT_FINAL.
         clear WA_FINAL.
        endat.
    ENDLOOP.
    ENDFORM.

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

  • Error while uploading an edited excel file into an internal table

    Hi Experts,
    I am getting error while uploading an excel file that has been edited.
    I am using GUI_UPLOAD for uploading the file into internal table.
    In my program I first have to download a file, if I use the same file without editing I am able to read the file.
    When I try to edit it and then use it to upload it fails, but this is part of the my requirement.
    PLease suggest.
    Regards
    Kishore

    TYPE-POOLS: truxs.
    parameter :    lv_full_path     TYPE rlgrap-filename,
    data : lt_conv_data   TYPE truxs_t_text_data,
              lt_roles_excel   type table of ( your structure).
    start-of-selection.
            CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
              EXPORTING
                i_line_header        = 'X'
                i_filename           = lv_full_path
              TABLES
                i_tab_sap_data       = lt_roles_excel
              CHANGING
                i_tab_converted_data = lt_conv_data
              EXCEPTIONS
                conversion_failed    = 1
                OTHERS               = 2.
    In the FM Line_header = 'X' means it will negelect the first line. So u can give the heading in the excel file.
    Hope this might help u .
    With Regards,
    Sumodh.P

  • I have problem of uploading excel file to my internal table

    Hi,
    I trying to upload data from excel file to my internal table and when i tried to debug the program and check the data in internal table and iam gettin # in all the fields and the data in not populated in internal table , as we are using 4.0b version and we are using UPLOAD FUNCTION.
            BUKRS(4) TYPE C,     
             PONO(8) TYPE C,     
             GRNNO(8) TYPE C,   
             DELNOTE(16) TYPE C,
             RECPTDT(10) TYPE C,  
             SUPPCODE(20) TYPE C, 
              RECPT(12) TYPE C,  
              GLACCT(10) TYPE C, 
             CCTR(6) TYPE C,      
      CALL FUNCTION 'UPLOAD'
        TABLES DATA_TAB = STRU.
      IF SY-SUBRC NE 0.
        WRITE: /'Data file error'.
      ENDIF.
    i am using the same sequeuence in the above structure in excel.

    Hi KODAMANCHILI,
    Refer following link :
    http://help.sap.com/saphelp_40b/helpdata/en/fc/eb3d9d358411d1829f0000e829fbfe/frameset.htm
    This will surely solve your problem.
    Regards,
    Vivek

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

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

  • 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

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

Maybe you are looking for

  • CSS link not working as it should...

    Hi i'm having problem getting my links to appear as I want them through CSS. Anythingg obvious in the code? thanks <td><p class="anchor-links"> </p>                   <p class="anchor-links"><a href="accompaniments.html">Accompaniments</a><br>       

  • Exporting using JAR tool

    Hi, I've created a Java Project in Eclipse, wich makes use of several external classes in the classpath. When viewing in the applet viewer, it works without trouble. But now I want to export it and test it from (a simple) html site. It gives a "Class

  • HTTP request isrequestsessionIdvalid()  function problem

    Hi, To check the expiration of the HTTPSession , i have used in my Controller servlet , a check as: if (!isRequestSessionIdValid()){ out.println("Session has expired!!!") however the above piece creates problem,As I type the URL and hit ENTER the con

  • Unable to set verbose stacktraces in Flex Builder 2.01

    If I set the compiler option -verbose-stacktraces=true, in the Problems listing in Flex Builder Eclipse Plugin 2.01, I get the following error message: quote: configuration variable 'compiler.verbose-stacktraces' must only be set once This suggests t

  • OWB Repository Creation with Repository Assistant

    Dear All, Im getting an error when configuring owb repository, this error raising at OWBSYS Information step. following is the error im getting OWB software with the compatible version must be installed locally on the database server machine. If it i