Adapter module to read excel file -java code required for PI 7.1

Hi PI experts,
I am working on PI 7.1 SP 08.
I am trying to develope an adapter module to read excel file
http://wiki.sdn.sap.com/wiki/display/ABAP/AdapterModuleToReadExcelFilewithMultipleRowsandMultiple+Columns
but here in this wiki , given java code is for pi 7.0 and it is using jar file from PI 7.0
I tried with using corresponding PI 7.1 files
com.sap.aii.af.lib.mod.jar:
sap.comtcloggingjavaimpl.jar:
com.sap.aii.af.svc_api.jar:
com.sap.aii.af.cpa.svc_api.jar:
com.sap.aii.af.ms.ifc_api.jar:
jave program is not throwing any error in NWDS but After deploying file on server.
i am getting this errot in communication channel
2009-12-15 15:47:08 Information AO: Now calling the Convert Method to convert Excel to XML.
2009-12-15 15:47:08 Error MP: exception caught with cause javax.ejb.TransactionRolledbackLocalException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file; nested exception is: javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file; nested exception is: javax.ejb.EJBTransactionRolledbackException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file; nested exception is: javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file
since i am not a JAVA expert so i am unable to resolve this error
if some one has already deployed this module for PI 7.1, then please provide me java code for PI 7.1
Thanks
sandeep sharma

hi,
please try this:
obj = inputModuleData.getPrincipalData();
msg = (Message) obj;
amk = new MessageKey(msg.getMessageId(),msg.getMessageDirection());
XMLPayload xpld = msg.getDocument();
Workbook wb = Workbook.getWorkbook((InputStream) xpld.getInputStream());
xmldata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"+ "<ns0:"msgType" ""xmlns:ns0=\""nameSpace+"\">";
Cell[] cells ;
Cell[] cellNames ;
cellNames = wb.getSheet(0).getRow(0);
for(int j=1;j<wb.getSheet(0).getRows();j++)
xmldata = xmldata+"<Record>";
cells = wb.getSheet(0).getRow(j);
for(int i=0;i<wb.getSheet(0).getColumns();i++)
xmldata = xmldata"<"cellNames<i>.getContents()">"cells<i>.getContents()"</"cellNames<i>.getContents()+">";
xmldata = xmldata+"</Record>";
xmldata = xmldata"</ns0:"msgType+">"; 
wb.close();
byte byt[] = xmldata.getBytes();
xpld.setContent(byt);
inputModuleData.setPrincipalData(msg);
Thanks,
Mayank

Similar Messages

  • Adapter Module Error-Sending excel file as an attachment of the mail

    Hi ,
    My scenario is as follows
    1)I am sending an excel file as an attachment of the mail.I need to read that excel attachment as a payload.
    So mail adapter is used in sender side.
      To configure this, have used standard PayloadSwapBean  module with proper module key.
      Next to convert excel to XML another custom adapter module is being used.
    Both this adapter module , I configured into the CC of sender mail adapter.
    The order in which adapter modules are being used in the sender CC are as follows
    1)localejbs/AF_Modules/PayloadSwapBean
    2)localejbs/MDPExcelToXMLConversion
    3)sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean
    MDPExcelToXMLConversion-Custom adapter module written to convert excel to xml.
    I am getting the following error
    exception caught during processing mail message [4899]com.sap.aii.af.lib.mp.module.ModuleException
    And also,
    no messages in coming MONI of PI.
    Pls suggest what to do.
    Thanks
    Ayan

    Shabarish,
    Will the ordering in which the adapter modules(In this case there are two-PayloadSwapBean & MDPExcelToXML) are appearing into Module tab of sender adapter matter?
    Firstly, what is happenning
    1)If I take out the custom  adapter module MDPExcelToXML and put only PayloadSwapBean  then it is successfully converting mail attachment into the main Payload i.e PayloadSwapBean   module is working.
    2)Nextly, my local code( i.e java code without including standard Module specific method like ejbActivate(),ejbPassivate(),process()  etc etc.)) for MDPExcelToXML is successfuly converting the excel file into the XML file.Then I am making the local code into adapter module specific code and deploying that.
    A few question arises here,
    Do I need to do any specific configurations here in PI for this particular things.Maybe both the adapter module is clashing with each other.
    And also using tracing and logging into my custom adapter module code.Getting the following error,
    java.io.IOException: Unable to read entire header; 116 bytes read; expected 512 bytes#
    Thanks
    Ayan

  • Jar files required to read excel file in SAP PI 7.3.1 sp09 dualstack

    Hi experts,
    I need to read excel file (.xls) using SAP PI and process it to target system. I have read blogs
    and found that there are 2 ways to read an excel file in PI using file adapter.
    1) Developing a custom adapter module
    2) Using XSLT code.
    So in order to develop a custom adapter module, i have followed the following blogs
    **************** - XI - Step-by-step guide to develop Adapter Module to read Excel file
    and
    Excel Files - How to handle them in SAP XI/PI (The Alternatives)
    and
    http://wiki.scn.sap.com/wiki/display/ABAP/Adapter+Module+To+Read+Excel+File+with+Multiple+Rows+and+Multiple+Columns
    I am unable to find the jar files in SAP PI at OS level as per the first blog(think they were obsolete).
    Please let me know
    1) What are the required jar files needed to read excel file and their location
    2) Even if i use the old jar files as mentioned in the first blog can i achieve my requirement
    3) Following this blog Convert incoming XML to Excel or Excel XML – Part 1 - XSLT Way if i apply the same logic at sender side, will it work? Because through case studies i came to know that we cannot read a .xls file using XSLT code. Correct me if i am wrong.
    Looking for your valuable suggestions.
    Regards
    Shilpa

    Hi Shilpa
    Welcome to SCN!
    The blog you refered to might be for previous versions of PI. You can refer to the following two wikis to find out what are the relevant JAR files for PI 7.3 and also how to get them.
    XI libraries for development - Process Integration - SCN Wiki
    Where to get the libraries for XI development - Process Integration - SCN Wiki
    It also looks like for newer versions, you might not need to manually get and add those JAR files into your NWDS project - please refer to the first comment on the blog below. I have not tried it personally as I'm not using the latest NWDS, but you can try that first, and if it does not work, then go get them manually.
    PI 7.4 - Adapter Module Creation using EJB 3.0
    Do note that you should be using the JAR files that is corresponding to your PI server version.
    As for your third question, that does not apply to you. XLS is the older non-XML format, and therefore cannot be read by XLST since it is in binary format.
    Rgds
    Eng Swee

  • How to read Excel file in java

    Respected sir/madam
    I want to read the values from Excel file in Java program. How can I do that. When I searched over the net I came to know that you can treat Excel file as a Database and write the code as u write for making DB connections .
    I did that but i am getting the following error ..can anybody please help..
    This is the code what i have written
    import java.io.*;
    import java.sql.*;
    public class ReadExcelFile {
    Connection c;
    Statement stmnt;
    public void checkABA_Number()
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    c = DriverManager.getConnection("jdbc:odbc:ExcelTest","",""); // ExcelTest is the DSN name
    stmnt = c.createStatement();
    ResultSet rs = stmnt.executeQuery("select * from abadata"); // abadata is my Excel file name
    while(rs.next())
    System.out.println(rs.getString(1)+" "+rs.getString(2));
    }catch(Exception e)
    System.out.println(""+e.toString());
    finally
    try
    stmnt.close();
    c.close();
    catch( Exception e )
    System.err.println( e );
    public static void main(String[] args)
    new ReadExcelFile().checkABA_Number();
    My Excel file starts from the first row and first column and also the first row contains the names of the column.
    It give me the following error..
    java.sql.SQLException: [Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'abadata'. Make sure the object exists and that you spell its name and the path name correctly.
    How can I deal with this.?I have properly selected the worksheet while giving the DSN . Is there any versionig problem with Excel or some drivers are in appropriate..and yes i chose Microsoft Excel Driver (.xsl) from ODBC .
    I created System DSN.
    Can anybody please help me with this ? I will be very gratefull for replies
    Thanks in advance

    here is the code to read excel file
    public void readexel(String filename)
    Connection c = null;
    Statement stmnt = null;
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" + filename);
    stmnt = c.createStatement();
    String query = "Select * from [Sheet1$]" ;
    ResultSet rs = stmnt.executeQuery( query );
    while( rs.next() )
    System.out.println( rs.getString(1) );
    catch( Exception e )
    System.err.println( e );
    }

  • Customised module for reading Excel files.

    Hi Gurus,
    I have to develop a customsed java module for reading Excel files from PI. I downloaded NWDS 7.31 from following location NWDS Download links - Java Development - SCN Wiki. I have installed it on my local laptop. For developing the module I need following Jar files.
    com.sap.aii.af.ms.svc_api
    com.sap.aii.proxy.svc_api.jar
    com.sap.aii.sec.svc_api.jar
    com.sap.aii.utilxi.server.jar
    com.sap.aii.utilxi.core.jar
    com.sap.xi.mapping.tool.lib_api.jar
    sap.com~tc~bl~txmanagerimpl~plb~impl.jar
    sap.com~tc~je~appcontect_api~API.jar
    com.sap.aii.af.cpa.svc.api
    com.sap.aii.af.lib.mod
    com.sap.aii.af.ms.ifc_api
    com.sap.aii.af.svc_api
    com.sap.xpi.ib.mapping.lib
    1. Where can i get these jar files. I checked these files in my downloaded NWDS 7.31  package, but cold not find them.
    Thanks in advance

    Hi.
    Check this thread.
    Where to get the libraries for XI development - Process Integration - SCN Wiki
    Regards
    Lucho

  • Java API for reading Excel Files.

    Hi,
    Can you please suggest me any api for reading excel files.
    Right now i am using jxl.jar for this purpose but i am searching for an open source java api better than this.
    Whether POI gives better than this ?
    Thanks,
    Amit Shah.

    Can you please suggest me any api for reading excel
    files.
    Right now i am using jxl.jar for this purpose
    but i am searching for an open source java api better
    than this.
    Whether POI gives better than this ?i don't know about jxl but poi has several features which an excel can contain and it has been vastly improved in the past few versions.

  • Error reading excel file using POI.

    Hi ,
    I am having some problem when reading the excel file.
    While reading excel file I am getting error-java.io.IOException: Unable to read entire block; 4 bytes read; expected 512 bytes.
    part of my code:-
    InputStream stream = objFormFile.getInputStream();
    POIFSFileSystem fs = new POIFSFileSystem(stream);//getting above error here.
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    Case 1:
    I download the file on the system ,save it ,and then directly upload it to the system ,I get the above error .
    Case 2:
    It works fine if I download the excel and manually open and save it and then upload it .
    I am using JDK1.4.1 and poi-2.5.1-final-20040804.jar.
    Can any one please help me out for the above problem?
    Edited by: hruday on Jul 31, 2008 3:20 AM

    Instead of using POIFSFileSystem, try to directly create the HSSFWorkbook
    InputStream stream = objFormFile.getInputStream();
    //POIFSFileSystem fs = new POIFSFileSystem( stream );//getting above error here.
    HSSFWorkbook wb = new HSSFWorkbook( stream );

  • Error while reading excel file from application server into internal table.

    Hi experts,
    My requirement is to read an excel file from application server into internal table.
    Hence I have created an excel file fm_test_excel.xls in desktop and uploaded to app server using CG3Z tcode (as BIN file type).
    Now in my program I have used :
    OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
    DO.
    READ DATASET v_filename INTO wa_tab.
    The statement OPEN DATASET works fine but I get a dump (conversion code page error) at READ DATASET statement.
    Error details:
    A character set conversion is not possible.
    At the conversion of a text from codepage '4110' to codepage '4103':
    - a character was found that cannot be displayed in one of the two
    codepages;
    - or it was detected that this conversion is not supported
    The running ABAP program 'Y_READ_FILE' had to be terminated as the conversion
    would have produced incorrect data.
    The number of characters that could not be displayed (and therefore not
    be converted), is 445. If this number is 0, the second error case, as
    mentioned above, has occurred.
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_CONVERSION_CODEPAGE', was not
    caught and
    therefore caused a runtime error.
    The reason for the exception is:
    Characters are always displayed in only a certain codepage. Many
    codepages only define a limited set of characters. If a text from a
    codepage should be converted into another codepage, and if this text
    contains characters that are not defined in one of the two codepages, a
    conversion error occurs.
    Moreover, a conversion error can occur if one of the needed codepages
    '4110' or '4103' is not known to the system.
    If the conversion error occurred at read or write of  screen, the file
    name was '/usr/sap/read_files/fm_test_excel.xls'. (further information about
    the file: "X 549 16896rw-rw----201105170908082011051707480320110517074803")
    Also let me know whether this is the proper way of reading excel file from app server, if not please suggest an alternative .
    Regards,
    Karthik

    Hi,
    Try to use OPEN DATASET v_filename FOR INPUT IN BINARY mode encoding default. instead of OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
    As I think you are uploading the file in BIN format to Application server and trying to open text file.
    Regards,
    Umang Mehta

  • How can we make the ms-word data as read-only using java code?

    How can we make the ms-word data as read-only using java code?

    MVSK wrote:
    By using java code i opened a file in ms-word. But the data i want to display as read-only. that means should not change it.I don't think you can do that. Display pdf documents instead.

  • Java code sample for uploading file

    Guys can some one give me a java code sample for uploading more than 1 file .
    I have a working example but that is only for one file.
    thanks
    M

    Throw it away. Go to the [http://commons.apache.org/fileupload] and carefully read both 'User Guide' and 'Frequently Asked Questions' sections.
    And please, please also carefully read this article: [http://balusc.blogspot.com/2008/06/what-is-it-with-roseindia.html].

  • Read Excel file path in WD

    Hi,
    We want to read a excel file. For that we are using file upload UI element and HSSF POI to read excel file. The code to read the excel file is working fine in standalone. In standalone we are hardcoding the file path. But in WD application, we are not hard coding it.
    We are using following code to supply the file name to HSSF code through  file upload UI:
    try
             InputStream in = new FileInputStream(wdContext.currentContextElement  
                                               ().getFileResource());
             wdComponentAPI.getMessageManager().reportSuccess("IN "+in);
             HSSFWorkbook wb  = new HSSFWorkbook(in);
    catch (Exception e)
         wdComponentAPI.getMessageManager().reportSuccess("ERROR in HSSF");
    Where FileResource is a context variable binded with property "data" of FileUpload UI element.
    Now, the problem is that the excel file is not getting read. We are getting ERROR in HSSF message.
    Please help in reading the file path.
    Regards,
    Vaibhav

    Hi,
       Try this:
    InputStream in = wdContext.currentContextElement().getFileResource().read(false);
    Regards,
    Satyajit.

  • Open data set for reading excel file on application server in back ground

    open data set for reading excel file on application server in back ground

    hi Vijay,
    I am afraid you won't be able to read from Excel file on Appl. Server.
    ec

  • Generate Excel file via code

    Hi,
    I know the user can export an Excel file once the report viewer is loaded, but I was wondering if it's possible to generate an Excel file via code (no viewer loaded)?
    thanks,
    Ron

    Yup.
    You can find export samples in our [Crystal Reports .NET SDK samples|https://www.sdn.sap.com/irj/boc/sdklibrary?rid=/library/uuid/d0bf8496-2a81-2b10-95ac-b1f48d5b63f5]
    Jason

  • How do we scan for viruses of uploaded excel file in Web Dynpro for JAVA

    Hi All,
    Please let me know "How do we scan for viruses of uploaded excel file in Web Dynpro for JAVA"
    Regards,
    Ganga.

    Hi ,
    pl go through this note "Integrating a virus scan into SAP applications 817623 "
    SAP Virus Scan Interface
    http://help.sap.com/saphelp_nw2004s/helpdata/en/30/42c13a38b44d5e8d1b140794e8e850/frameset.htm
    Sample Application
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/6e1c4221-0901-0010-63ba-b1f9459d6e74
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f2681486-0a01-0010-8497-c778eac80da5
    Regards
    Ayyappparaj

  • Uploading excel file in Web Dynpro for ABAP

    Hello Gurus,
                       I need to upload a excel file in my Web Dynpro (ABAP) program. Can anyone please tell me how do i do this. Kindly help.
    Regards,
    Aditya.

    Hi Aditya,
    Please search the forum...
    Please check this link
    Uploading Data from Excel File To Dynpro
    Excel Upload via Web dynpro ABAP
    Upload and Reading Excel File in Web Dynpro
    Best regards,
    raam

Maybe you are looking for