Creating a report from scratch in java and getting invalidfield error

hello
I am trying to generate a report java.
I am getting invalidfieldobject - the field was not found
I checked the resultset and it does contain the column called trn
package com.surecomp;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import com.crystaldecisions.sdk.occa.report.application.ReportClientDocument;
import com.crystaldecisions.sdk.occa.report.data.DBField;
import com.crystaldecisions.sdk.occa.report.data.FieldValueType;
import com.crystaldecisions.sdk.occa.report.definition.FieldObject;
import com.crystaldecisions.sdk.occa.report.definition.ISection;
import com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat;
import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
public class reporting  {
     public static void main(String[] args) {
          reporting x = new reporting();
          x.run();
     public void run() {
          try {
               java.sql.ResultSet javaResultSet = null;
               Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
               java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:sqlserver://ssi-allmatch:1433;databaseName=mrmdus33xxx;","sa", "sa12");
               java.sql.Statement statement = connection.createStatement();
               javaResultSet = statement.executeQuery("select * from trades");               
               ReportClientDocument boReportClientDocument = new ReportClientDocument();
               boReportClientDocument.newDocument();
               boReportClientDocument.getDatabaseController().addDataSource(javaResultSet);
               ISection boSectionToAddTo = boReportClientDocument.getReportDefController().getReportDefinition().getDetailArea().getSections().getSection(0);
               // Create a new Database Field Object
               DBField boDBField = new DBField();
               boDBField.setName("trades.trn");
               boDBField.setHeadingText("trn");
               boDBField.setType(FieldValueType.stringField);
               FieldObject boFieldObject = new FieldObject();
               boFieldObject.setDataSourceName(boDBField.getFormulaForm());
               boFieldObject.setFieldValueType(boDBField.getType());
               boFieldObject.setLeft(9000);
               boFieldObject.setTop(1);
               boFieldObject.setWidth(1911);
               boFieldObject.setHeight(226);
               boReportClientDocument.getReportDefController().getReportObjectController().add(boFieldObject, boSectionToAddTo, -1);
               ByteArrayInputStream byteArrayInputStream = null;
               byteArrayInputStream = (ByteArrayInputStream) boReportClientDocument.getPrintOutputController().export(ReportExportFormat.PDF);
               writeFileFromInputStream("c:/bob.pdf",byteArrayInputStream);
          catch(ReportSDKException ex) {     
               System.out.println(ex);
          catch(Exception ex) {
               System.out.println(ex);               
    private void writeFileFromInputStream(String sfile, ByteArrayInputStream inputStream)  {
         try {
              File file = new File(sfile);
              OutputStream outputStream = new FileOutputStream(file);  
              int bytesRead = 0;  
              byte [] buffer = new byte[32768];  
              while ((bytesRead = inputStream.read(buffer, 0, 32768)) != -1) {  
                        outputStream.write(buffer, 0, bytesRead);  
              outputStream.close();    
              inputStream.close();     
         } catch (Throwable th) {

Hi,
I have the same problem, did you get this resolved? I am new to the Crystal Report Java SDK and want to create reports from scratch but I can't find any good resources on the internet or the website.

Similar Messages

  • Create a report from scratch, add Table and Datasource Problem

    Hi,
    I'm using the latest Crystal Reports Runtime supplied for eclipse.
    I want to create a report from scratch, add a Table and then add a ArrayList of Pojos as the Datasource.
    But unfortunately depending on the ConnectionInfo I supply to the Table I get different errors.
    I looked through the samples and see that I have to supply properties
    like
      "Database DLL", "crdb_javabeans.dll" and ConnectionInfo.setUserName("");
         ConnectionInfo.setPassword(null)
    I looked through the forums and find different set of properties.
    Actually because I am just working with Pojos I would have thougth that something like the following
    would be sufficient:
    ReportClientDocument  doc = new ReportClientDocument();
                doc.setReportAppServer(ReportClientDocument.inprocConnectionString);
                doc.newDocument();
    Table table = new Table();
    table.setAlias("reportTable");
    table.setName("reportTable");
    doc.getDatabaseController().addTable(oTable, null);
    doc.getDatabaseController().setDataSource(myCoolection, myClass, "reportTable", "reportTable");
    So could someone tell me the right/minimum Set of  Properties to make a Table get connected to Pojos?
    Edited by: jack mann on Aug 31, 2010 3:25 PM

    With XI Release 2, you can come quite close to creating from scratch:
    http://technicalsupport.businessobjects.com/KanisaSupportSite
    /search.do?cmd=displayKC&docType=kc&externalId=5074668
    You need Service Pack 2:
    http://support.businessobjects.com/downloads
    /service_packs/crystal_reports_en.asp
    Sincerely,
    Ted Ueda

  • Creating a new connection when creating a report from scratch

    I've searched all around but I haven't managed to find any samples or forum posts that show how to create a connection when creating a report from scratch via RCAPI.  All of the code that I've found has been aimed at replacing the ConnectionInfo for an existing connection.  I figured that it would work something like this:
    m_crystalReport.setReportAppServer(ReportClientDocument.inprocConnectionString);
    m_crystalReport.newDocument();
    IConnectionInfo ci = new ConnectionInfo();
    PropertyBag propertyBag = new PropertyBag();
    propertyBag.put("Use JDBC", true);
    propertyBag.put("Connection URL", "jdbc:jtds:sqlserver://localhost:1433;databaseName=" + DB_NAME);
    propertyBag.put("Database Class Name", "net.sourceforge.jtds.jdbc.Driver");
    propertyBag.put("Database DLL", "crdb_jdbc.dll");
    ci.setAttributes(propertyBag);
    m_connection = new Connection();
    m_connection.setConnectionInfo(ci);
    m_connection.open();
    but this produces a NullPointerException within Connection.open().  If I leave the connection closed but add it to the report via DatabaseController.addConnection() then I just get the exception later on when I try to add tables using the connection.
    Can anyone give me any pointers please?
    Thanks,
    Rich.

    Just in case anyone else runs into this, I managed to fix it by leaving the connection closed and then using the connection info instead of the connection when creating tables, eg:
         ITable t = new Table();
         t.setAlias(v.getAlias());
         t.setName(v.getView().getName());
         t.setConnectionInfo(m_connectionInfo);
         getDatabaseController().addTable(t, null);

  • Want to create a Report from scratch!!!

    Hi,
    I tried to create a report using the document provided by oracle but in vain. Could anyone give a guideline on how to carry on with this task. Or a link to where I can find an interesting user guide.
    Thanks in Advance.

    There is also a doc on our pages to get you started building templates ... very simple to get started:
    http://www.oracle.com/technology/products/xml-publisher/xmlpclient.html
    Look for the XML Publisher Templates by Example
    then once you have had some practice ... take it to Apps
    http://www.oracle.com/technology/products/xml-publisher/xmlpapps.html
    regards
    Tim

  • I'm trying to re-install mountain lion 19.8.2 from a recovery disk and get an error when it's trying to verify my computer with Apple, any idea what's wrong?

    I'm trying to reinstall mountain lion 10.8.2 from a recovery disk and I get the following error when I goes to verify my computer with apple,
    An error occurred while preparing the installation. Try running this application again. Can anyone help?

    Well, I'm trying to figure out how you're doing this from a recovery disk. The only way to reinstall Mountain Lion is through the Recovery HD in the computer. Hold Cmd/R as you are starting up the computer and keep holding it. Eventually you'll get a screen asking you to select the language. Hit continue to select english and you'll get a Mac OS X Utilities Menu with the second option down being reinstall OS X.

  • I am unable to connect to the icloud from my windows laptop and get an error message: "Connection error: icloud encountered an error while trying to connect to the server"

    I am unable to connect to icloud from my windows-based laptop and get the following error message: "icloud encountered an error while trying to connect to the server."

    I would remove the email account from mail and then set it up again.
    If your are able to long I via owa though without the auto fill, then we already know the user name and password are correct.
    Let me know if that works.

  • I'm trying to purchase an app from the app store and getting an error message that says unable to verify my computer or device.  Anyone have any suggestions?

    I'm trying to purchase an app from the App Store but continually getting an error message that reads  -"Unable to verify your device or computer".  I can purchase apps from iTues with no issues at all, but not from the App Store.  Any suggestions?

    Read the article you linked

  • Creating a Report from Excel

    I'm trying to create a report from an Excel spreadsheet and am having some issues with how Crystal is reading in the data.  I have 7 fields that are all the same, I want them to be Numeric fields.  However, when I import the Excel sheet as the data source, 4/7 of the fields import as string fields into Crystal.  At first I didn't think this would be an issue, but some of the fields, and it doesn't seem to be consistently the "string" only or the "numeric" only fields, do not seem to be printing to the report at all - the space where they should be ends up blank.  I have gone back to the Excel sheet several times to change the cell format to Numeric, but that has not helped.  I also tried changing the format in Crystal, using ToNumeric(fieldname) or ToText(fieldname), and neither of those functions seem to work either.
    Has anyone had this issue before or know how to fix it?

    Hi Jeremy,
    Which Crystal Report version are you using?
    Have you applied any service pack for Crystal Reports?
    Which Operating system are you using?
    Is the issue is with all the report or single report?
    For testing purpose:
    -Create new excell sheet with two columns one is numeric and other one string.
    -Create report using thie excell sheet.
    -Preview report and export.
    -Now print report
    Are you getting same results?
    Have you tried to print other document through that printer is it working properly.
    Regards,
    Shweta

  • Hi, I would like to create a database from my numbers spreadsheet and create reports (like SQL). Is there a way?

    Hi, I would like to create a database from my numbers spreadsheet and create reports (like SQL). Is there a way?

    Numbers is a lightweight spreadsheet.  If you know sql you will know that it can handle many queries and is a real databases that can handle many thousands of records.  Number is not the correct tool.  You can make something that does something like a query but it is not truly a query.
    Can you share anything about the specific application and how much information there is in each record?  How many records (rows)?

  • How can I create a Report from a SWT-Application?

    Post Author: mkoch
    CA Forum: JAVA
    I'm a Developer and new to Crystal Reports and I have the job to create a Report from a SWT-Application.The report-files ( *.rpt) were created with Crystal Reports 10 or 11.> I'm not sure but I have access to a machine where Crystal Reports 10 Developer an Crystal Reports 11 Runtime are installed.Can anybody describe in detail how I can start the creation of a report from my Java-Application?> What libraries are needed, where can I get them and so on.I saw in the CR10-Setup that there is a Java-feature - but unfortunately this is not installed on my test-machine.--> Is it necessary to install this feature or can I get this files on businessobjects.com?Is it possible to start the report-creation from command-line?I saw a Java-example on the internet which uses Report.exe - but I haven't found this on my machine.I hope, that somebody can help me.GreetingsMarkus

    Inv. #
    Item
    Sale Price
    Lisa
    Oct Sold 12
    Oct Sold 12-2
    Oct Sold 12-3
    149
    Vase Lidded
    25
    201
    Bird
    7
    7
    202
    Bird
    7
    203
    Bird
    7
    204
    Bird
    7
    7
    205
    Bird
    7
    7
    206
    Bird
    7
    7
    207
    Bird
    7
    207
    Bird
    7
    7
    208
    Bird
    7
    7
    209
    Bird
    7
    7
    This is my very simple inventory.  On previous program I could sort by those items that did not have any figure in the row across.  Then I could print a report of open inventory.  Such as 149 Lidded Vase has not sales amount in the four colums across, thus it is open inventory.  How can I capture all those items in one report?

  • Creating sales report from AR Data

    Hello,
    I'm Willie Owens. The company that I work for is currently in the process of implementing Oracle 11i applications. However, I have recently learned that when we first go-live with our system, we won't have the business intelligence system up. Therefore, I am going to have to create most of the views used for our sales reports from "scratch". Has anyone every used the RA_Customer_TRX_All and RA_Customer_TRX_Lines_All tables under the AR schema to accurately reflect sales information? If so, I could appreciate any input or suggestions that are offered.
    Thanks,
    Willie

    Hello Mark,
    Perhaps I should begin by describing some of the reports. One of the reports shows the sales by salesrep. These are the fields that are going to be used:sales amount, percent of sales, cost of sales, profit, percent of profit, and margin percent.
    I have some ideas but I'm just not certain. For the For example, to compute the sales amount would I use the UNIT_SELLING_PRICE * QUANTITY_INVOICED or UNIT_SELLING_PRICE * QUANTITY_ORDERED?
    Also, to calculate the cost of sales, do I use the UNIT_STANDARD_PRICE * QUANTITY_INVOICED(or QUANTITY_ORDERED)?
    I understand that my profit would be the difference between these two previously calculated amounts. I also need the user to be able to enter a period ending date value. The Discoverer report should then capture all of the sales up to this entered date.
    Then to further complicate things, I have to be able to calculate all of these values for the Period To Date(which means that it will capture all of the sales info from the 1ST day of the current month up until the Period Ending Date);a Year To Date Line will also show these values from January 1st of the current year up until the Period Ending Date.

  • How to create a report in Form line Style and can display Image field?

    Hi,
    In Report builder 10g, I would like to create a Report with Form Line Style and this report included a Image field.
    I can choose this Style only when Select Report type is Paper Layout. Because, If I choose Create both Web & Paper Layout or Create Web Layout only then in the next Style tab 03 option Form, Form letter and Mailing Label be Disabled.
    But in Paper Layout, my report can not display Image field.
    I tried with Web layout and all the other Styles (Except 03 mentioned be Disabled) then all Styles are displayed Imager field OK.
    How to create a report in Form line Style and can display Image field?
    I was change File Format property of my Image field from text to Image already in Property Inspector. But report only showed MM for my Image field.
    Thanks & regards,
    BACH
    Message was edited by:
    bachnp

    Here you go..Just follow these steps blindly and you are done.
    1) Create a year prompt with presentation variable as pv_year
    2) Create a report say Mid report with year column selected 3 times
    - Put a filter of pv_year presentation variable on first year column with a default value say @{pv_year}{2008}
    - Rename the second time column say YEAR+1 and change the fx to CAST(TIME_DIM."YEAR" AS INT)+1
    - Rename the second time column say YEAR-1 and change the fx to CAST(TIME_DIM."YEAR" AS INT)-1
    Now when you will run Mid Report, this will give you a records with value as 2008 2009 2007
    3) Create your main report with criteria as Year and Measure col
    - Change the fx for year column as CAST(TIME_DIM."YEAR" AS INT)
    - Now put a filter on year column with Filter based on results of another request and select these:
    Relationship = greater than or equal to any
    Saved Request = Browse Mid Report
    Use values in Column = YEAR-1
    - Again,put a filter on year column with Filter based on results of another request and select these:
    Relationship = less than or equal to any
    Saved Request = Browse Mid Report (incase it doesn't allow you to select then select any other request first and then select Mid Report)
    Use values in Column = YEAR+1
    This will select Year > = 2007 AND Year < = 2009. Hence the results will be for year 2007,2008,2009
    This will 100% work...
    http://i56.tinypic.com/wqosgw.jpg
    Cheers

  • How to create a Report from WebDympro

    Hi All,
    I just want to know how I can create a report from WebDynpro? I need to pull data from R/3 using a RFC function module, but I don't know if it exists a software to create reports.
    Thanks in advance
    Alexis Ramirez

    Hi Rich,
    Even i had a similar kind of problem. I wanted to fetch data from BI through the XMLA Connector which are created in Query Designer and then i wanted to fetch these fields and rearrange them and put it in a report format by colouring certain fields. Can the same can be done in WebDynpro.

  • Create a Form from Scratch: Possible or Not

    So, I have Acrobat X.
    I want to create a form from scratch. I have Word doc, but it wasn't created to look like a form, and I didn't like the way it imported.
    So, can I create a form from scratch. Or Not?
    If you try to start from scratch, it suggests a template on formscentral - and after signing up for free and spending an hour making the form, I find that I can not save or save as PDF the form that I created without forking over my credit card information - for a free trial that bills in a few weeks. (As much as I like the form data collection tools available, I cannot have my data collected by Adobe.)
    I can open an empty MS Word doc to start from - as my import choice - but can you make it any harder to mave the text around or enter new text? I never did figure out how to edit text. Is the answer going to be to edit my text in Word or in the plain PDF tool?
    I just found the form creation to be completely counter intuitive.

    Acrobat is not a Word processor, really. "Adding a carriage return" makes sense in a word processor, where the layout is still fluid. In a PDF the layout is finished, everything is a graphic. So, absolutely, it's designed to work with pre-made forms. To me, that's a strenghth - you can use the tools you already know to make the form background, then you add the fields in Acrobat. With work, you can preserve the fields over remaking the PDF, then just adjust the field positions.

  • Created a pdf from a word-file and inserted formfields. The fields works in other pdf-readers(nitro,reader etc), but not in adobe reader and acrobat. Please help.

    Hi,
    I have created a pdf from a word-file and inserted formfields for a work related file. I've used nitro pro to create the formfield. They works in nitro, reader, foxit etc. but not adobe reader. From page 3 and out, the font wont show when writing in a formfield. Some formfield doesnt even show.
    Please help me fix this (hopefully before the presentation at work friday) :-)
    File in question: Dropbox - Byggeplassperm_bico_prosjektledelse_2.pdf
    Kind regards
    Tobias

    Agreed. Adobe makes no claims that their Reader will work properly with forms made from third party software.

Maybe you are looking for

  • Apache and mod_proxy

    Hi all, Im trying to set up Apache (2.2) standalone using the mod_proxy module to act as a proxy in accessing the oracle http server which is hosted on its own server. I have successfully done this (to some degree) with the following entry in my http

  • Link a text with another sheet

    Hello!!  Is there a opportunity in Diadem to make a link in one Report sheet on a textbox? The link should go to another sheet and show me the content of it.  Best regards,  Mosquito

  • Problem in at new field.

    hi experts,               i have an itab which has materialno and qty. i need the highest qty in each material .so what shall i do now. ragrds mani

  • Spry.Widget.ValidationTextfield is not a constructor

    I have worked through the text field validation documentation, but get "Spry.Widget.ValidationTextfield is not a constructor" when I try to run. I have been trying to debug this for a while. Pretty sure I have referenced the js and css correctly. Sur

  • Animation Preset Problem

    When I add an animation preset to my text layer, it works, but it also adds the words Adobe After Effects below the first layer of text slightly overlapping the text.  Does anyone know why that is happening?  It never did that before and I did purcha