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

Similar Messages

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

  • Need help in uploading an excel file into SAP

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

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

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

  • Problems with Import a excel file?

    Folks,
    I created a form to upload a excel file, the upload works fine , but I have a problem with the first line of the excel file. I created a model with the column names, the headers. When I uploaded this excel file to a folder inside my CF server, the first line is inserted in my DB, how fix this problem?
    Tks
    Fabiano Magno Pechibella

    You've said you have a problem. You haven't said what the problem is.

  • 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

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

  • After uploading an excel file from Windows XP, impossible to read the file anymore

    Hello,
    I uploaded an excel file from my Imac to the Icloud. I could use it on my Ipad through Numbers without problem. I went on my laptop running with Windows XP, I didn't see the plugin to install, so I didn't do it. I download this excel file and worked on it. When I uploaded again this file, I could see the letter E written on the file on the Icloud, but impossible to download it and work on it anymore from any of my devices. I installed the missing plugin on the laptop but still, no improvements.
    Any suggestions ?
    Best regards.

    Hi Stephan,
    You can do this using OLE technology. Bu you will have performance issues.
    Can you check the below demo programs? It has similar functionality. I am able to create excel sheet from sap and also able to save the data in the sap.
    SAPRDEMOEXCELINTEGRATION
    SAPRDEMOEXCELINTEGRATION2
    Please also check the below rograms for more help.
    SAPRDEMOACTIVEXINTEGRATION
    SAPRDEMODOCUMENTCONTAINER
    SAPRDEMODOCUMENTCONTAINER2
    Thanks
    Ramakrishna

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

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

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

  • I would like to upload a excel file using jsp

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

    No.
    Mylenium

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

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

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

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

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

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

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

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

Maybe you are looking for

  • Ipod Classic-0 KB Free but nothing on it.

    I have a Ipod Classic.  In the setting menu it says 0KB Free but in all other parts of the menu there is no music, podcasts, movies etc.  When I try to go to itunes to reload the ipod will not come up on my itunes.  I have tried all the USBs on the c

  • Is it possible to make photos with the Ipod nano 5G?

    Is it possible to make photos with the Ipod Nano 5G?

  • Cannot download itunes.....says there is a windows inslaller problem

    ttried to update my iphone 4 to ios5.......needed to update itunes....tried came up with windows inslaller .........removed itunes, now cannot install due to same windows inslaller problem, any ideas peeps......its doin my head in!!!!!!

  • Dynamic node mapping

    Hi everyone, I have a scenario in which the source structure contains an indicator A and 1 or 2 source nodes (X & Y, both 0..unbounded). Node X will always be in there where Y will only be in there if A = true. Target node is T (0..unbounded). Now, t

  • MRP  : Planning levels , time lines , qunatities

    Hi all , can somebody answer me this What level can we plan the material using MRP ? can material planned at storage location level ? What are the time ( lines ) say Purch processing time , planned  delivery time , GR processing time are considered d