Non-English string access from excel sheet through JDBC

My excel sheet data is
Test ������������
I am using JDBC connectivity for accessing the Excel sheet.
Code looks like,
List Output = new List();
try
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection( "jdbc:odbc:qa-list", "", "" );
stmnt = c.createStatement();
ResultSet rs = stmnt.executeQuery("select * from [Sheet1$];");
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
for(int i=1; i <= numberOfColumns; i++){
Output.add(rsmd.getColumnLabel(i));
catch( Exception e )
System.err.println( e );
finally
try
stmnt.close();
c.close();
catch( Exception e )
System.err.println( e );
Now. I am showing those data into the table(JTable) Applet programming.
For, English string it is showing properly but, for non-English string are showing �???????????????????�
I would like to know what could be the reason.
Addional info:
ava version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
If possible please send some reference code .

I have one excel sheet which having differenct countries specific meaining of common words.
I am using JDBC connectivity for accessing that Excel sheet.
Code looks like,
List Output = new List();
try
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection( "jdbc:odbc:qa-list", "", "" );
stmnt = c.createStatement();
ResultSet rs = stmnt.executeQuery("select * from [Sheet1$];");
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
for(int i=1; i <= numberOfColumns; i++){
Output.add(rsmd.getColumnLabel(i));
catch( Exception e ){
System.err.println( e );
finally{
try{
stmnt.close();
c.close();
catch( Exception e ){
System.err.println( e );
Now. I am showing those output data into the table(JTable) in my Applet programming.
For, English string it is showing properly but, for non-English strings are showing question marks like, �?????�
I would like to know what could be the reason.
Please help me, i am stuck in my project.

Similar Messages

  • Uploading data from excel sheets through BDC's into sap system

    hi guys,
    can you please help me with this. As we use gui_upload to upload data from flat file to sap system, which function module you use to upload data from Excel sheet to sap system through bdc's

    hello pavan,
    welcome to SDN
    check the below program
    REPORT ZEXCEL_TO_INTERNAL .
    data: begin of itab occurs 0,
          name(20) type c,
          addre(20) type c,
          end of itab.
    DATA : ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    DATA : B1 TYPE I VALUE 1,
           C1 TYPE I VALUE 1,
           B2 TYPE I VALUE 100,
           C2 TYPE I VALUE 9999.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        FILENAME                   =
        'C:\Documents and Settings\administrator\Desktop\ppcon001bd_24.xls'
        I_BEGIN_COL                   = B1
        I_BEGIN_ROW                   = C1
        I_END_COL                     = B2
        I_END_ROW                     = C2
      TABLES
        INTERN                        = itab1
    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 itab1.
    write:/ itab1.
    Endlop.
    Regards,
    Naveen

  • Retrieval of Information from Excel Sheet using JDBC-ODBC

    Hello,
    Currently I am writing a program that extracts information fromexcel sheet. This excel sheet have some values in Chinese. I am able to extract English character from the different column in excel, but if some column contain chineese valur then it prints ???. After that I looked on net and found some details in to convert Big5 (Chinese) character into unicode, but this is not working and in that case nothing is displayed. I am attaching the my code. In my code the 'customer' field contain chinese character.
    import java.io.ByteArrayInputStream;
    import java.io.InputStreamReader;
    import java.io.BufferedReader;
    import java.io.Reader;
    import java.io.IOException;
    import java.sql.*;
    public class ExcelJDBC
         Connection con;
         Statement stmt;
         public ExcelJDBC(String url)
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              catch(java.lang.ClassNotFoundException e)
                   System.err.print("ClassNotFoundException: ");
                   System.err.println(e.getMessage());
              try
                   con = DriverManager.getConnection(url, "", "");
                   stmt = con.createStatement();
              catch(SQLException ex)
                   System.out.println("SQL EXCEPTION OCCURED");
                   System.err.println("SQLException: " + ex.getMessage());
                   ex.printStackTrace();
         public void sql(String sql)
              try
                   stmt.execute(sql);
              catch(SQLException ex)
                   System.out.println("SQL EXCEPTION OCCURED");
                   System.err.println("SQLException: " + ex.getMessage());
                   ex.printStackTrace();
         public void closeAll()
              try
                   stmt.close();
                   con.close();
              catch(SQLException ex)
                   System.out.println("SQL EXCEPTION OCCURED");
                   System.err.println("SQLException: " + ex.getMessage());
                   ex.printStackTrace();
         //big5 to unicode conversion
         private String b2u(String str2convert) throws IOException
              System.out.println("The input string is :" + str2convert);
              StringBuffer buffer = new StringBuffer();
              byte[] targetBytes = str2convert.getBytes();
              ByteArrayInputStream stream = new ByteArrayInputStream(targetBytes);
              InputStreamReader isr = new InputStreamReader(stream,"Big5");
              Reader in = new BufferedReader(isr);
              int chInt;
              while((chInt = in.read()) < -1)
                   buffer.append((char)chInt);
              in.close();
              System.out.println("The output string is :" + buffer.toString());
              return buffer.toString();
         public void sqlQuery(String sql)
              try
                   ResultSet rc = stmt.executeQuery(sql);
                   if(rc != null)
                        int count = 0;
                        while (rc.next())
                             String value = "";
                             value = b2u(rc.getString("workorder"));
                             System.out.println("The workorder is : "+value);
                             String customer = rc.getString("Customer");
                             value = b2u(customer);
                             System.out.println("The Customer is : "+value);
                             count++;
                        System.out.println("Entering in loop " count " time.\n");
              catch(SQLException ex)
                   System.out.println("SQL EXCEPTION OCCURED");
                   System.err.println("SQLException: " + ex.getMessage());
                   ex.printStackTrace();
              catch(IOException ex)
                   System.out.println("IO EXCEPTION OCCURED");
                   System.err.println("IOException: " + ex.getMessage());
                   ex.printStackTrace();
    public static void main(String[] args)
         String url = "jdbc:odbc:detailsdsn";     
         try
              ExcelJDBC ej = new ExcelJDBC(url);
              ej.sqlQuery("SELECT \"workorder\", \"Customer\" FROM \"Sheet1$\"");
              ej.closeAll();
         catch(Exception ex)
              System.out.println("SQL EXCEPTION OCCURED");
              System.err.println("SQLException: " + ex.getMessage());
              ex.printStackTrace();
    I will highly appriciate any answer of my problem.
    Regards,
    Ruchi

    Try to find out, what characters really are in your string customer.
    I assume you used System.out.print..(), when you got them as '?'.
    Find out which unicodes they are!
    Afterwards I see two possibilites:
    Either
    1) you see real unicodes for Chinese characters, and it was only the unability of System.out to print them others than as '?', then you can convert these characters however you want. Maybe your further processing can handle them directly as unicode.
    or
    2) you get really '?' in your string. Then Excel (or JDBC or ODBC or ???) hasn't been able to transmit these Chinese characters to your program others than converting them all into '?'. Then you are lost, because you can't know which Chinese character each '?' originally could have been.
    Hope this helps.
    Please tell us, which you experienced, 1) or 2).

  • Problem in reading data from Excel sheet to 2D string array (ActiveX & LabView).

    I am trying to read data from Excel sheet to 2D string array (ActiveX & LabView). Error -2147352571 is generated (type mismatch) if cell value is "#NULL!", "#N/A" etc. What should I do?

    Hello �
    Is the error happening when the cell value is #NULL or #NA only?
    Sometimes these errors occur because of an ActiveX object mismatch. The version of the ActiveX object might have changed or been updated since the VI was created. The VI tries to use an earlier, incompatible version of the ActiveX object.
    To solve the problem, you need to link automation refnum terminal to the correct ActiveX object. To do so, right-click an automation refnum terminal and choose Select ActiveX Class»Browse from the shortcut menu. From the Type Library pull-down menu, select the latest version of the library you want to use, such as Microsoft Excel Object Library. In the Objects list, select an ActiveX object, and click the OK button. Link ea
    ch automation refnum terminal in the VI and its subVIs until the run arrow is not broken. Also, you might have to replace some or all of the Invoke Nodes and Property Nodes for the ActiveX objects.
    Also, I came across this Knowledgebase. The error number is slightly different but it is always good to check it out and make sure it is not your case.
    Hope this helps.
    S Vences
    Applications Engineer
    National Instruments

  • Problem while executing app for retrieving data from EXCEL Sheet

    hi
    i have this exception while running my application of retrieving data from a Excel sheet through java application , i had also set theclasspath for jxl. jar file but where its going wrong i dont know heres my code
    import java.util.Date;
    import java.io.*;
    import jxl.*;
    import javax.swing.*;
    import java.awt.*;
    import jxl.read.biff.BiffException;
    public class testExcel2
    public static void main(String args[]) throws jxl.read.biff.BiffException
    try
    File f=new File("move.xls");
    jxl.Workbook workbook=null;
    jxl.Sheet sheet=null;
    workbook=jxl.Workbook.getWorkbook(f);
    sheet=workbook.getSheet(0);
    Cell a1 = sheet.getCell(0,0);
    String stringa1 = a1.getContents();
    System.out.println("stringshaddddddddjk "+stringa1);
    workbook.close();
    }catch(IOException ex){
    System.out.println("Error" + ex);
    catch (BiffException ex2){
    System.out.println("Error" + ex2);
    catch(IndexOutOfBoundsException ex1){
    System.out.println("Error" + ex1);
    compilation is sucees but while running its giving an EXCeption
    MicrosoftXP[Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    G:\mysfw\pgms>java testexcel2
    Exception in thread "main" java.lang.NoClassDefFoundError: testexcel2 (wrong nam
    e: testExcel2)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    Java is case sensitive. testexcel2 is different from testExcel2.
    G:\mysfw\pgms>java testexcel2
    Exception in thread "main" java.lang.NoClassDefFoundError: testexcel2 (wrong name: testExcel2)

  • Getting short dumps while reading bulky data from excel sheet

    Hi all,
    We have converted our non-unicode based sap system (R/3 4.7, Windows 2003,
    SQL 2000) into a unicode based system recently. We are facing two peculiar
    problems for last few days.
    *Problem 1 - *Whenever we want to upload the data from excel sheet, the
    system throws a dump after reading about 400 entries, while last week the
    same system used to read about 8000 entries in a single go.
    *Problem 2 - *Also, whenever we realease a transport requst from development
    containing a lot of changes, the request will reach the quality system but
    without the changes. but if i ll try to import the changes into quality
    system after generating more than one request containing small small
    changes, they get reflected in QAS immediately. Is there any size
    constraint in transporting a request fro DEV->QAS->PRD.
    Please suggest some ways.
    I am pasting the dump (that I am getting while data uploading from Excel).
    ~~~~~~~~~~~~~~~~~~
    Runtime errors
    MESSAGE_TYPE_X*
    Occurred on
    22.02.2008 at
    13:21:02*
    The current application triggered a termination with a short dump.
    What happened?
    The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X).
    What can you do?
    Print out the error message (using the "Print" function)
    and make a note of the actions and input that caused the
    error.
    To resolve the problem, contact your SAP system administrator.
    You can use transaction ST22 (ABAP Dump Analysis) to view and administer
    termination messages, especially those beyond their normal deletion
    date.
    Error analysis
    Short text of error message:
    Control Framework : Error processing control
    Technical information about the message:
    Diagnosis
    An error occurred when the system tried to process the commands
    from the Automation Queue on the presentation server.
    There are several possible reasons for this:
    - The installation of the SAP GUI on the presentation server is
    faulty or obsolete.
    - There is an error in the application program
    - There is an error in the SAPGUI or an integrated control
    Procedure
    1. Make sure that you have imported the appropriate Support
    Package, the current kernel, and GUI patch for the release of your
    System
    2. Check whether the error occurs locally on one or a few PCs, or
    generally on all PCs. Note whether the error only occurs for some
    users, for example because of a specific Customizing setting.
    If it only occurs locally, this suggests an installation problem
    with the PC. Check the installation; if necessary, reinstall the
    software. In the dump, search for the SY-MSGLI field, since it may
    point to the cause of the error.
    3. Activate the Automation Trace (in accordance with SAP Note
    158985).
    4.Start the transaction and continue until the screen immediately
    before the dump.
    5. From the System -> Utilities menu, choose Autom. Queue,
    Synchronous Processing.
    The status bar of the GUI displays the text:
    "Automation synchron flush mode on"
    6. If you now proceed with the application, the short dump will
    display the ABAP call that caused the error; the Automation Trace
    will contain the error on the presentation server.
    7. If necessary, load the short dump and trace files on to
    sapservX, so that SAP can analyze them.
    Message classe...... "CNDP"
    Number.............. 006
    Variable 1.......... " "
    Variable 2.......... " "
    Variable 3.......... " "
    Variable 4.......... " "
    Variable 3.......... " "
    Variable 4.......... " "
    How to correct the error
    Probably the only way to eliminate the error is to correct the program.
    You may able to find an interim solution to the problem
    in the SAP note system. If you have access to the note system yourself,
    use the following search criteria:
    "MESSAGE_TYPE_X" C
    "SAPLOLEA" or "LOLEAU02"
    "AC_SYSTEM_FLUSH"
    If you cannot solve the problem yourself, please send the
    following documents to SAP:
    1. A hard copy print describing the problem.
    To obtain this, select the "Print" function on the current screen.
    2. A suitable hardcopy prinout of the system log.
    To obtain this, call the system log with Transaction SM21
    and select the "Print" function to print out the relevant
    part.
    3. If the programs are your own programs or modified SAP programs,
    supply the source code.
    To do this, you can either use the "PRINT" command in the editor or
    print the programs using the report RSINCL00.
    4. Details regarding the conditions under which the error occurred
    or which actions and input led to the error.
    System environment
    SAP Release.............. "620"
    Application server....... "nhbho930"
    Network address.......... "192.168.0.30"
    Operating system......... "Windows NT"
    Release.................. "5.2"
    Hardware type............ "4x Intel 801586"
    Character length......... 16 Bits
    Pointer length........... 32 Bits
    Work process number...... 0
    Short dump setting....... "full"
    Database server.......... "NHBHO930"
    Database type............ "MSSQL"
    Database name............ "DEV"
    Database owner........... "dev"
    Character set............ "C"
    SAP kernel............... "640"
    Created on............... "Aug 17 2007 00:18:58"
    Created in............... "NT 5.0 2195 Service Pack 4 x86 MS VC++ 13.10"
    Database version......... "SQL_Server_8.00 "
    Patch level.............. "196"
    Patch text............... " "
    Supported environment....
    Database................. "MSSQL 7.00.699 or higher, MSSQL 8.00.194"
    SAP database version..... "640"
    Operating system......... "Windows NT 5.0, Windows NT 5.1, Windows NT 5.2,
    Windows NT 6.0"
    User, transaction...
    Client.............. 300
    User................ "NHBABAP"
    Language key........ "E"
    Transaction......... "SE38 "
    Program............. "SAPLOLEA"
    Screen.............. "SAPMSDYP 0010"
    Screen line......... 0
    Information on where terminated
    The termination occurred in the ABAP program "SAPLOLEA" in
    "AC_SYSTEM_FLUSH".
    The main program was "ZBDC_CONTRACT ".
    The termination occurred in line 29 of the source code of the (Include)
    program "LOLEAU02"
    of the source code of program "LOLEAU02" (when calling the editor 290).
    ~~~~~~~~~~~~~~~~~~~~~
    Thank you all.
    Cheers.
    Mitra __.____._

    for the 50 millionth time: Excel spreadsheets are NOT databases, you should NOT try to use them as such and NEVER access them using JDBC.
    You should also under NO condition use the JDBC-ODBC bridge driver (that was actually the 78 millionth time that was told someone).

  • Cannot retrieve the data from excel sheet

    hi all ...
    i am trying to retrieve the data from excel sheet and at the same time i am inserting the data into mysql database.
    code is as follows
    try{             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");             conn1=DriverManager.getConnection("jdbc:odbc:"+estr,"","");             Class.forName("com.mysql.jdbc.Driver");             conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/"+ t_dsn ,"root","manager");             sql="select * from student_info";             srch2 = conn.prepareStatement(sql);             rs1 = srch2.executeQuery();             String query  = "select * from ["+einput+"$]";             String query1= "select  count(*) from ["+einput+"$]";             st  = conn1.createStatement();             rs  = st.executeQuery(query);             ResultSetMetaData rsmd = rs.getMetaData();             c = rsmd.getColumnCount();//gets the column count             rs1  = st.executeQuery(query1);             while (rs1.next())  //loop to get no. of rows             {                 r = rs1.getInt(1);             }             rs = st.executeQuery(query);             for(i=1;i<=r;i++){                 rs.next();                 for(j=1;j==c;j++) {                     a = rs.getString(j);                     b= rs.getString(j);                     d = rs.getString(j);                 }                 rs1.next();                 PreparedStatement ps2 = conn.prepareStatement("insert into materials_out values(?,?,?)");                 ps2.setString(1,a);                 ps2.setString(2,b);                 ps2.setString(3,d);                 ps2.executeUpdate();             }         }catch(Exception e){             e.printStackTrace();         }
    but it is showing error as :
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name too long
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3073)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Outward_register.jButton2ActionPerformed(Outward_register.java:368)
    at Outward_register.access$400(Outward_register.java:23)
    at Outward_register$5.actionPerformed(Outward_register.java:312)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6038)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
    at java.awt.Component.processEvent(Component.java:5803)
    at java.awt.Container.processEvent(Container.java:2058)
    at java.awt.Component.dispatchEventImpl(Component.java:4410)
    at java.awt.Container.dispatchEventImpl(Container.java:2116)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
    at java.awt.Container.dispatchEventImpl(Container.java:2102)
    at java.awt.Window.dispatchEventImpl(Window.java:2429)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    please help me ...

    please help me ... The question has nothing to do with 'getting' data from excel and certainly not with putting it into MySQL.
    The stack trace specifically tells you that your connection string is wrong.
    It also tells you which connection string is wrong.
    Which you can use to determine specifically which one is wrong. And which you did not provide that info to us.

  • Read data from excel sheet and then perform the required operations.

    Hi all
    I need to write a procedure which can read data from excel sheet.I have excel sheet in which i have to options one is modification and other is addition.so if it reads modification then i need to read the concerned table name then check its availability in pl-sql datbase.If table exists then reading the realated column in that row to fire the querry. The excel sheet is saved in local disk c.
    can anybody help me with this.How i need to start specialy to read the data from excel sheet saved in local disk c.
    Edited by: user13334062 on Jun 30, 2010 3:45 AM

    Hi
    If you can convert the excel to a csv format, then it can be simply query from DB Creating Oracle External Tables. Best part is that you may still change the CSV using EXCEL.
    Following action Points can be adopt;
    *1. Convert Excel File to a csv. File Save as CSV*
    *2. Create Oracle Directory* ( This has to be the location of your excel file )
    SQL> Create directory mydir as 'C:\testdb'; --- "testdb" is the location folder in win for your excel sheet.
    *3. Create the External Table*
    SQL> create table my_ext_tab (
    Field1 Datatype,
    Field2 Datatype,
    Field3 Datatype,
    Field4 Datatype,
    Field5 Datatype
    Organization external
    (type oracle_loader default directory mydir
    access parameters (records delimited by newline fields terminated by ',')
    location ('my_ext_tab.csv'))
    reject limit 100;
    *4. Now you can query the table "my_ext_tab"*
    Select * from "my_ext_tab";
    Please avoid the reformat the data column inside the spreadsheet (CSV).

  • Creation of material from excel sheet

    Hi All,
    Can we create material by uploading from excel sheet.
    I have created all necessary product categories in system.
    I want to create 20 materials in one product category from excel sheet.
    Abdul Raheem

    Hi Abdul,
    have you tried to import the data via Import Data (System Administration --> Import and Export Tools --> Import Data).
    Also did you use the correct template; to access the correct template, please follow these steps:
    Go to Import Data
    Insert a dummy .xls file
    From the dropdown list, choose Materials
    On the next screen, download the template.csv file
    Populate the fields as required on that spreadsheet
    Repeat the import.
    Hope this helps, if it solves your question, please mark this answer as solved.
    Thanks,
    Armin

  • BAPI for automatic Pr creation witth multiple files from excel sheet

    I have written a programm  for automatic PR creation  with the help of bapi , where its picks data from excel sheet and makes PR .It is picking excel files from one folder(Files) for PR creation and moving to another folder(Files sucess).
    now the problem is if Folder (Files) contains one excel sheet ,PR is created fine , but if the Folder(Files) have multiple excel sheet ,its is creating 1st PR right, but next PR's contains all the line item of 1st PR , 2nd PR and so on .can anyone suggest me where is the problem in codes.
    types : begin of x_file ,
            key1(10),
            pur_grp(4),
            maktx(40),
            plant(4) ,
            req(10),
            s_qty(13),
            wbs(24),
            gl(10),
            trackno(10),
            supl(4),
            deladd(255).
    types : end of x_file .
      data : str5 type char10.
      data : mm type char2.
      data : yyyy type char4.
      data : dd type char2.
      data : str9 type char10.
      data : str6 type char10.
      data : month type char2.
      data : year type char4.
      year = sy-datum+0(4).
      month = sy-datum+4(2).
      dd = sy-datum+6(2).
      yyyy = sy-datum+0(4).
      mm = sy-datum+4(2).
      dd = sy-datum+6(2).
      clear str6 .
      clear str5.
      concatenate  dd'.' month '.' year into str5 .
      concatenate  yyyy mm dd into str6 .
    DATA : file type rlgrap-filename .
    data : it_file type table of x_file .
    data : wa_file type x_file .
    data : it_header type table of x_file .
    data : wa_header type x_file .
    *&  Internal Table For Define Row and Coloum Postion
    data: col_start type i value 1 ,
          row_start type i value 2,
          col_end type i value 256 ,
          row_end type i value 65000 .
    *&  Internal Table For Retrieve  Data From Excel
    *data: excel_bdcdata like kcde_cells occurs 0 with header line.
    *data: excel_bdcdata1 like kcde_cells occurs 0 with header line.
    data: excel_bdcdata like ALSMEX_TABLINE occurs 0 with header line.
    data: excel_bdcdata1 like ALSMEX_TABLINE occurs 0 with header line.
    data: it_index type i.
    DATA : IT_INDEX1 TYPE I.
    *&  Define Field Symbol
    field-symbols: <fs> .
    data :   bdcdata like bdcdata    occurs 0 with header line.
    data :   messtab like bdcmsgcoll occurs 0 with header line.
    data : req_items type table of bapiebanc .
    data : wa_req_items type bapiebanc .
    data : req_acc_asg type table of bapiebkn.
    data : wa_req_acc_asg type bapiebkn.
    DATA : RETURN LIKE BAPIRETURN OCCURS 0 WITH HEADER LINE .
    *data : return type table of     bapireturn.
    *data : wa_return type bapireturn .
    data : number type ebeln .
    *****************************MOVE FILES******************************
    data : xsource type string .
    data : xdestin type string .
    data : destin1 type string .
    data : destin2 type string .
    DATA : DEST1 TYPE STRING.
    DATA : DEST11 TYPE STRING.
    DATA : DEST2 TYPE STRING.
    DATA : DEST22 TYPE STRING.
    data : sou_dir_name like SALFILE-LONGNAME.
    data : tar_dir_name like SALFILE-LONGNAME.
    data : tar_dir_name1 like SALFILE-LONGNAME.
    data : sou_filename like EDI_PATH-PTHNAM .
    data : tar_filename like EDI_PATH-PTHNAM .
    data : filename1  type string .
    data : tar_filename1 like EDI_PATH-PTHNAM .
    data : file_itab like SALFLDIR occurs 0 with header line.
    data : wa_file_itab like SALFLDIR.
    data : file_count type i .
    data : dir_count type i.
    data : dir_table like sdokpath occurs 0 with header line.
    data : file_table like SDOKPATH occurs 0 with header line.
    data : wa_file_table like sdokpath.
    data : strr type string ,
           str1 type string ,
           str2 type string ,
           str3 type string .
    DATA : PA_VAL TYPE CHAR1.
    sou_dir_name = 'D:\barcodes\files\'.
    tar_dir_name = 'D:\barcodes\files-success\'.
        "success folder.
    CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
      EXPORTING
        DIRECTORY  = sou_dir_name
        FILTER     = '.'
      IMPORTING
        FILE_COUNT = file_count
        DIR_COUNT  = dir_count
      TABLES
        FILE_TABLE = file_table
        DIR_TABLE  = dir_table
      EXCEPTIONS
        CNTL_ERROR = 1
        OTHERS     = 2.
    IF SY-SUBRC <> 0.
    ENDIF.
    loop at file_table into wa_file_table.
    clear  :  strr , str1 , str2 , str3 .
      strr = wa_file_table-PATHNAME .
      concatenate sou_dir_name strr into str1 .
      concatenate tar_dir_name strr into str2 . " success
      concatenate tar_dir_name1 strr into str3 .         " failed
    FILE = STR1 .
    *start-of-selection.
    *&  Function For Retrieve Data From Excel
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = FILE
        i_begin_col                   = col_start
        i_begin_row                   = row_start
        i_end_col                     = col_end
        i_end_row                     = row_end
      tables
        intern                        = excel_bdcdata
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3.
      IF sy-subrc NE 0.
    WRITE : / 'File Error'.
    EXIT.
    ENDIF.
      loop at excel_bdcdata.
        translate excel_bdcdata to upper case .
        move excel_bdcdata-col to it_index.
        assign component it_index of  structure  wa_file to <fs> .
        move excel_bdcdata-value to <fs>.
        at end of row.
          append wa_file to it_file .
            clear wa_file.
        endat.
      endloop.
    sort it_file by key1. "pur_grp maktx plant  .
    it_header[] = it_file[].
    delete adjacent duplicates from it_header comparing key1 pur_grp maktx
    plant .
    data : h_item(5) type n .
    data : h_pack(10) type n .
    data : line_no(5) type n .
    data : ln_no(5) type n .
    loop at it_header into wa_header .
    ln_no = 1.
    h_item = h_item + 10.
    h_pack = h_pack + 1.
    wa_req_items-preq_item = h_item .
    wa_req_items-doc_type = 'BOM'.
    wa_req_items-pur_group = wa_header-pur_grp .
    wa_req_items-MATERIAL = wa_header-maktx .
    wa_req_items-plant = wa_header-plant .
    wa_req_items-pckg_no =  h_pack .
    wa_req_items-deliv_date = str6 .
    wa_req_items-item_cat = '0'.
    wa_req_items-acctasscat = 'P'.
    *wa_req_items-distrib = '2' .
    **wa_req_items-gr_ind = 'X'.
    wa_req_items-ir_ind = '2'.
    wa_req_items-purch_org = 'TISL' .
    wa_req_items-QUANTITY =  wa_header-s_qty.
    wa_req_items-PREQ_NAME =  wa_header-req.
    wa_req_items-SUPPL_PLNT = wa_header-supl.
    wa_req_items-trackingno = wa_header-trackno.
    append wa_req_items to req_items .
    clear wa_req_items.
    wa_req_acc_asg-preq_item = h_item .
    wa_req_acc_asg-g_l_acct = wa_file-gl .
    WA_req_acc_asg-wbs_elem  = wa_header-wbs .
    append wa_req_acc_asg to req_acc_asg .
    clear wa_req_acc_asg.
    h_pack = h_pack + 1  .
    endloop.
    clear ln_no .
    ***BREAK-POINT.
    *& BAPI FUNCTION
    call function 'BAPI_REQUISITION_CREATE'
    importing
       number                               = number
      tables
        requisition_items                   = req_items
       requisition_account_assignment       = req_acc_asg
       return                               = return .

    Can someone please give me sol........

  • Problems in uploading from excel sheet to internal table

    hi experts,
    i got one problem regarding uploading data from excel sheet to int.table. I used FM ALSM_EXCEL_TO_INTERNAL_TABLE but in that the value is char of 50. but i need a case where i have to send value more than 50 characters. please suggest me any other FM to overcome this problem.
    advanced thanks
    vijay

    Hi,
    >
    Vijay Krishna Arvapalli wrote:
    > hi tarun,
    >
    > thank you for your reply
    >
    > but when i tried to use FM TEXT_CONVERT_XLS_TO_SAP it is giving error actually that 'Error generating the test frame'.
    >
    > so can you suggest me with some other option where i can upload the field with more than 50 character length.
    >
    > thank you
    > regards
    > vijay
    Yes, when you execute the FM from SE37, then it displays a message.
    Just copy the below code and paste it in a report (SE38) and execute.
    Create a file in C:/ with name test.xls and execute it will display the records even with more than 50 characters of length.
    I have tested and its working.
    I have taken three fields in the excel file empid, name and doj.
    TYPE-POOLS : truxs.
    PARAMETERS : p_file TYPE rlgrap-filename DEFAULT 'C:\TEST.XLS'.
    DATA : BEGIN OF itab OCCURS 0,
             empid(150) TYPE c,
             name(150) TYPE c,
             doj(150) TYPE c,
           END OF itab.
    DATA: it_raw TYPE truxs_t_text_data.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM f4_file_process USING p_file.
    AT SELECTION-SCREEN.
      PERFORM validate_file_path USING p_file.
    START-OF-SELECTION.
      PERFORM upload_data.
    END-OF-SELECTION.
      PERFORM display_data.
    *&      Form  F4_FILE_PROCESS
    *       text
    *      -->P_FILE_PATH  text
    FORM f4_file_process USING p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
          field_name    = 'P_FILE'
        IMPORTING
          file_name     = p_file.
      IF sy-subrc NE 0.
        MESSAGE e000(zsd).
      ENDIF.
    ENDFORM.                    " F4_FILE_PROCESS
    *&      Form  VALIDATE_FILE_PATH
    *       text
    *      -->P_FILE  text
    FORM validate_file_path USING p_file.
      DATA : lv_dir TYPE string,
             lv_file TYPE string,
             lv_result(1) TYPE c.
      DATA : lv_filename TYPE string.
      lv_filename = p_file.
      CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
        EXPORTING
          full_name     = p_file
        IMPORTING
          stripped_name = lv_file
          file_path     = lv_dir
        EXCEPTIONS
          x_error       = 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.
      CALL METHOD cl_gui_frontend_services=>directory_exist
        EXPORTING
          directory            = lv_dir
        RECEIVING
          result               = lv_result
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          wrong_parameter      = 3
          not_supported_by_gui = 4
          OTHERS               = 5.
      IF lv_result IS INITIAL.
        MESSAGE 'Invalid Directory' TYPE 'E'.
      ENDIF.
      CLEAR lv_result.
      CALL METHOD cl_gui_frontend_services=>file_exist
        EXPORTING
          file                 = lv_filename
        RECEIVING
          result               = lv_result
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          wrong_parameter      = 3
          not_supported_by_gui = 4
          OTHERS               = 5.
      IF lv_result IS INITIAL.
        MESSAGE 'Invalid File' TYPE 'E'.
      ENDIF.
    ENDFORM.                    " VALIDATE_FILE_PATH
    *&      Form  UPLOAD_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM upload_data .
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_field_seperator    = 'X'
          i_line_header        = 'X'
          i_tab_raw_data       = it_raw
          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.
    ENDFORM.                    " UPLOAD_DATA
    *&      Form  DISPLAY_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display_data .
      LOOP AT itab.
        WRITE : / itab-empid, itab-name, itab-doj.
      ENDLOOP.
    ENDFORM.                    " DISPLAY_DATA
    Hope this helps you.
    Regards,
    Tarun

  • Non english string in URL

    Hi,
    I'm trying to send a non English string from one WD application to another.
    I managed to encode it to UTF-8 using java.net.URLEncoder in the sending application but could not decode it in the receiving application. The WD is doing some decoding to a character set I don't now.
    Any idea anyone??
    Thanks and regards,
    Nachshon

    Suggestions
    1) Try with NLS_LANG as
    SWEDISH_SWEDEN.WE8DEC
    2) Make a paramform and enter via paramform (unencoded)
    (This is just for testing purpose)
    3) Change machine locale to swedish and try
    4) Which reports version is this ?
    Please see
    BUG 2713695 - NLS CHARACTERS FOR PARAMETERS CHANGE TO QUESTION MARKS WHEN PASSED ON URL BAR
    Get in touch with Support to see if this is the issue and if "yes" get a one-off patch.
    [    All Docs for all versions    ]
    http://otn.oracle.com/documentation/reports.html
    [     Publishing reports to web  - 10G  ]
    http://download.oracle.com/docs/html/B10314_01/toc.htm (html)
    http://download.oracle.com/docs/pdf/B10314_01.pdf (pdf)
    [   Building reports  - 10G ]
    http://download.oracle.com/docs/pdf/B10602_01.pdf (pdf)
    http://download.oracle.com/docs/html/B10602_01/toc.htm (html)
    [   Forms Reports Integration whitepaper  9i ]
    http://otn.oracle.com/products/forms/pdf/frm9isrw9i.pdf
    ---------------------------------------------------------------------------------

  • Upload data in excel sheet through BDC

    Dear all,
    How do we upload data in excel sheet through BDC?
    Thanks in advance.
    Regards,
    Sandra.

    Hi,
         The sample code is as given below:
    REPORT  upload_supply_area.
    *include for dispaying icons in error log
    INCLUDE <icon>.
    *Declaration of structure.
    TYPES:BEGIN OF x_struct,
          werks TYPE v_pvbe-werks,          "Plant
          prvbe TYPE v_pvbe-prvbe,          "Supply Area
          pvbtx TYPE v_pvbe-pvbtx,          "Production supply area description
          lgort TYPE v_pvbe-lgort,          "Storage Location
          rgver TYPE v_pvbe-rgver,          "Person responsible for one or more supply areas
          END OF x_struct.
    TYPES:BEGIN OF x_messages,
           msgtyp(1) type c,
           werks TYPE v_pvbe-werks,          "Plant
           prvbe TYPE v_pvbe-prvbe,          "Supply Area
           message(120) type c,
           END OF x_messages.
    DATA: it_messages  TYPE STANDARD TABLE OF x_messages .
    DATA: wa_messages TYPE x_messages.
    DATA:it_msgtab TYPE STANDARD TABLE OF bdcmsgcoll,
         wa_msgtab TYPE bdcmsgcoll.
    *internal table for BDC
    DATA: it_bdcdata TYPE STANDARD TABLE OF bdcdata.
    DATA: wa_bdcdata TYPE bdcdata.
    DATA:it_file TYPE STANDARD TABLE OF x_struct.        "internal table which has same structure as file
    DATA:wa_file TYPE x_struct.                          "work area which has same structure as file
    DATA: it_excel TYPE STANDARD TABLE OF alsmex_tabline,
          wa_excel TYPE alsmex_tabline.
    DATA: x_ctuprms TYPE ctu_params.
    DATA:nodata TYPE c VALUE '/'.
    data:con(50) type c.
    data:con1(50) type c.
    *selection screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    *Enter file name on presentation server
    PARAMETERS:  p_file TYPE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    *Function which enables the user to browse the files on hard disk
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          program_name  = syst-repid
          static        = 'X'
        CHANGING
          file_name     = p_file
        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.
    *Subroutine to upload excel file and read it
      PERFORM upload.
    *Subroutine to upload supply area data
      PERFORM fill.
    *&      Form  bdc_dynpro
          Fill the BDC table
    FORM bdc_dynpro USING program dynpro.                       "#EC *
      CLEAR wa_bdcdata.
      wa_bdcdata-program  = program.
      wa_bdcdata-dynpro   = dynpro.
      wa_bdcdata-dynbegin = 'X'.
      APPEND wa_bdcdata TO it_bdcdata.
    ENDFORM.                    "BDC_DYNPRO
    *&      Form  bdc_field
           Fill the BDC table
    FORM bdc_field USING fnam fval.                             "#EC *
      IF fval <> nodata.
        CLEAR wa_bdcdata.
        wa_bdcdata-fnam = fnam.
        wa_bdcdata-fval = fval.
        APPEND wa_bdcdata TO it_bdcdata.                        "#EC
      ENDIF.
    ENDFORM.                    "BDC_FIELD
    *&      Form  collect_messages
          Collect the messages from transaction
    FORM collect_messages .                                     "#EC *
      DATA: w_msg(100).
      LOOP AT it_msgtab INTO wa_msgtab.
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            id        = wa_msgtab-msgid
            lang      = wa_msgtab-msgspra
            no        = wa_msgtab-msgnr
            v1        = wa_msgtab-msgv1
            v2        = wa_msgtab-msgv2
          IMPORTING
            msg       = w_msg
          EXCEPTIONS
            not_found = 1
            OTHERS    = 2.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        CONDENSE w_msg.
        CLEAR wa_messages.
        wa_messages-msgtyp = wa_msgtab-msgtyp.
        wa_messages-message = w_msg.
        wa_messages-werks = wa_file-werks.
        wa_messages-prvbe = wa_file-prvbe.
    if wa_messages-message eq 'Formatting error in the field V_PVBE-RGVER; see next message'.
    wa_messages-message = 'Invalid name of the person responsible'.
    endif.
    if wa_messages-message eq 'Formatting error in the field V_PVBE-LGORT; see next message'.
    wa_messages-message = 'Enter the storage location'.
    endif.
        APPEND wa_messages TO it_messages .
      ENDLOOP.
      REFRESH it_msgtab.
    ENDFORM.                    "collect_messages
    *&      Form  write_messages
          Display the messages
    FORM write_messages .
      DELETE ADJACENT DUPLICATES FROM it_messages COMPARING werks prvbe.
      LOOP AT it_messages INTO wa_messages .
        WRITE:/1 sy-vline.
        IF wa_messages-msgtyp = 'S'.
          WRITE: 10 icon_green_light.
        ELSEIF wa_messages-msgtyp = 'E'.
          WRITE: 10 icon_red_light.
        ELSEIF wa_messages-msgtyp = 'W'.
          WRITE: 10 icon_yellow_light.
        ENDIF.
        WRITE: 20 sy-vline.
        WRITE : 30 'Plant-', wa_messages-werks .                "#EC NOTEXT
        WRITE: 48 sy-vline.
        WRITE : 49 'Supply Area-', wa_messages-prvbe .          "#EC NOTEXT
        WRITE: 79 sy-vline.
        WRITE : 80 wa_messages-message .
        WRITE: 180 sy-vline.
        WRITE:/1 sy-vline.
        ULINE 1(180).
      ENDLOOP.
    ENDFORM.                    " write_m
    *&      Form  fill_params
          Processing mode for the transaction
    FORM fill_params .
      x_ctuprms-dismode = 'N'.
      x_ctuprms-updmode = 'A'.
      x_ctuprms-defsize = 'X'.
    ENDFORM.                    "fill_params
    *&      Form  upload
          Upload the excel file and read the data
    FORM upload .
    *Function to upload excel file
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = 1
          i_begin_row             = 2
          i_end_col               = 5
          i_end_row               = 9999
        TABLES
          intern                  = it_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.
      CLEAR wa_file.
    *Read the file row-wise
      LOOP AT it_excel INTO wa_excel.
        CASE wa_excel-col .
    *Read plant
          WHEN '1'.
            wa_file-werks = wa_excel-value.
    *Read supply area
          WHEN '2'.
            wa_file-prvbe = wa_excel-value.
    *Read decription
          WHEN '3'.
            wa_file-pvbtx = wa_excel-value.
    *Read storage location
          WHEN '4'.
            wa_file-lgort = wa_excel-value.
    *Read Person responsible
          WHEN '5'.
            IF STRLEN( wa_excel-value ) = 1.
              CONCATENATE '00' wa_excel-value INTO con.
              wa_file-rgver = con.
            ELSEIF STRLEN( wa_excel-value ) = 2.
              CONCATENATE '0' wa_excel-value INTO con1.
              wa_file-rgver = con1.
            ELSE.
              wa_file-rgver = wa_excel-value.
            ENDIF.
        ENDCASE.
        AT END OF row.
          CONDENSE:wa_file-werks,wa_file-prvbe,wa_file-pvbtx,wa_file-lgort,wa_file-rgver.
          APPEND wa_file TO it_file.
          CLEAR wa_file.
        ENDAT .
      ENDLOOP.
    ENDFORM.                    " upload
    *&      Form  fill
          Call the transaction 'PK05'
    FORM fill .
    *Upload the data through transaction 'PK05'
      PERFORM fill_params.
      LOOP AT it_file INTO wa_file.
        PERFORM bdc_dynpro      USING 'SAPLSVIX' '0100'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'D0100_FIELD_TAB-LOWER_LIMIT(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=OKAY'.
        PERFORM bdc_dynpro      USING 'SAPL0PK1' '0020'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'V_PVBE-PVBTX(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=NEWL'.
        PERFORM bdc_dynpro      USING 'SAPL0PK1' '0021'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'V_PVBE-RGVER'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'V_PVBE-WERKS'
                                      wa_file-werks.
        PERFORM bdc_field       USING 'V_PVBE-PRVBE'
                                      wa_file-prvbe.
        PERFORM bdc_field       USING 'V_PVBE-PVBTX'
                                      wa_file-pvbtx.
        PERFORM bdc_field       USING 'V_PVBE-LGORT'
                                      wa_file-lgort.
        PERFORM bdc_field       USING 'V_PVBE-RGVER'
                                      wa_file-rgver.
        PERFORM bdc_dynpro      USING 'SAPL0PK1' '0021'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'V_PVBE-WERKS'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=SAVE'.
        PERFORM bdc_field       USING 'V_PVBE-WERKS'
                                      wa_file-werks.
        PERFORM bdc_field       USING 'V_PVBE-PRVBE'
                                      wa_file-prvbe.
        PERFORM bdc_field       USING 'V_PVBE-PVBTX'
                                      wa_file-pvbtx.
        PERFORM bdc_field       USING 'V_PVBE-LGORT'
                                      wa_file-lgort.
        PERFORM bdc_field       USING 'V_PVBE-RGVER'
                                      wa_file-rgver.
        CALL TRANSACTION 'PK05'
                           USING it_bdcdata
                           OPTIONS FROM x_ctuprms
                           MESSAGES INTO it_msgtab.
        REFRESH it_bdcdata.
        PERFORM collect_messages.
        CLEAR wa_file.
      ENDLOOP.
      PERFORM write_messages.
    ENDFORM.                    " fill

  • Uploading data from excel sheet

    HI,
         Can anyone provide me the details to upload vendor data from excel sheet to database through bdc?
    Thankyou.

    upload the excel file in your internal table and then use BDC to updated the database table.
    FM's to upload Excel:
    GUI_UPLOAD
    KCD_EXCEL_OLE_TO_INT_CONVERT
    ALSM_EXCEL_TO_INTERNALTABLE
    refer to the link:
    http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table-2/
    http://www.sap-img.com/abap/learning-bdc-programming.htm
    With luck,
    Pritam.

  • How to transfer data more than 255 char from excel sheet to internal table.

    Hello Experts,
    I have a requirement where i have a text field in the excel sheet of more than 255 char and need to be updated in the text element. To do that i need to transfer the excel sheet data to an internal table where one of the field is more than 255 char.
    in the standard function module it works only upto 255 char. Can you help me if we have some other way to get more than 255 char in the internal table from excel sheet.
    Thanks in Advance.
    BR,
    RaJ.

    Using .xls, it is not possible transfer data more than 255 characters from excel sheet. However if the excel sheet is saved as Comma Delimited format or Tab Delimited format, then using GUI_DOWNLOAD function module data more than 255 characters can be transferred.
    File name should be : .csv (Comma Delimited format)  or .txt (Tab Delimited format)
    File Type would still remain 'ASC' while calling function module GUI_DOWNLOAD
    Also In the internal table declare the field type as String or LCHAR.
    Eg:
    TYPES: begin of ty_file,
            col_a TYPE string,
          end of ty_file.
    DATA: i_file type standard table
                   of ty_file
                 with header line
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      =  'C:\test.csv'
      TABLES
        DATA_TAB                      = i_file

Maybe you are looking for