Creating a sample report using JAVA SDK

Hi,
I am trying to create a sample report using JAVA SDK.
I slelect 4 "free cells" and pass 4 different strings to it.
I even slelect the font colour and size. When i run the class and try to view the report in Infoview, I only seeblank blocks without any data. Now if I edit the report from infoview, and save the changes, I am able to see the data.
My issue is, Why am I not able to see the data when I run the java code.
Please find teh code below.
package com;
import java.awt.Color;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.businessobjects.rebean.wi.BinaryView;
import com.businessobjects.rebean.wi.DataProvider;
import com.businessobjects.rebean.wi.DataProviders;
import com.businessobjects.rebean.wi.DataSource;
import com.businessobjects.rebean.wi.DataSourceObject;
import com.businessobjects.rebean.wi.DocumentInstance;
import com.businessobjects.rebean.wi.DocumentLocaleType;
import com.businessobjects.rebean.wi.FontImpl;
import com.businessobjects.rebean.wi.FreeCell;
import com.businessobjects.rebean.wi.HTMLView;
import com.businessobjects.rebean.wi.OutputFormatType;
import com.businessobjects.rebean.wi.PageHeaderFooter;
import com.businessobjects.rebean.wi.Query;
import com.businessobjects.rebean.wi.Recordset;
import com.businessobjects.rebean.wi.Report;
import com.businessobjects.rebean.wi.ReportBody;
import com.businessobjects.rebean.wi.ReportCell;
import com.businessobjects.rebean.wi.ReportContainer;
import com.businessobjects.rebean.wi.ReportElement;
import com.businessobjects.rebean.wi.ReportEngine;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.framework.ISessionMgr;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.plugin.CeKind;
public class Aug7th {
      * @param args
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          String CMS = "pundl8136:6400";
          String userID = "srivas";
          String password = "morcom123";
          String auth = "secEnterprise";
          List<String> entire =new ArrayList<String>();
          List<String> country =new ArrayList<String>();
          List<String> resort =new ArrayList<String>();
          IEnterpriseSession enterpriseSession;
          try
               ISessionMgr mySessionMgr = CrystalEnterprise.getSessionMgr();
               enterpriseSession = mySessionMgr.logon(userID, password, CMS,auth);
               if (enterpriseSession != null)
               {//Create and store useful objects for the session.
                    IInfoStore iStore = (IInfoStore)enterpriseSession.getService("InfoStore");
                    ReportEngine reportEngine = (ReportEngine)enterpriseSession.getService("WebiReportEngine");
                    IInfoObject infoView = null;
                    String str = "SELECT SI_ID, SI_NAME, SI_PARENTID FROM CI_INFOOBJECTS WHERE (SI_KIND = '"+CeKind.WEBI+"' OR SI_KIND='FullClient') " +
                    "AND SI_INSTANCE = 'false' AND SI_NAME='Structure Test_001_Java' ORDER BY SI_NAME ASC ";
                    //String str = "SELECT SI_ID, SI_NAME, SI_PARENTID FROM CI_INFOOBJECTS ORDER BY SI_NAME ASC ";
                    IInfoObjects objInfoObjectsWIDs = (IInfoObjects) iStore.query(str);
                    System.out.println(objInfoObjectsWIDs.size());
                    IInfoObject objInfoObjectWID = (IInfoObject) objInfoObjectsWIDs.get(0);
                    DocumentInstance doc = reportEngine.openDocument(objInfoObjectWID.getID());
                    DataProviders dps = doc.getDataProviders();
//                     Retrieve the 1st data provider
                    DataProvider dp = dps.getItem(0);
//                     Retrieve the universe objects
                    DataSource ds = dp.getDataSource ();
                    Query q = dp.getQuery();
                    Recordset rs = dp.getResult(0);
//                     0: assume query has one flow
                    rs.first();
//                     Print the column types. They can be Integer, String,
//                     or Date.
                    for (int i = 0; i < rs.getColumnCount(); i++) {
                    Class c = rs.getColumnType(i);
                    StringBuffer sbt = new StringBuffer();
                    if ( c.equals(Integer.class) )
                    sbt.append("Integer");
                    if ( c.equals(String.class) )
                    sbt.append("String");
                    if ( c.equals(Date.class) )
                    sbt.append("Date");
                    sbt.append(";");
                    System.out.println(sbt.toString());
                    System.out.println(rs.getColumnCount());
                    while (!rs.isLast()) {
//                          column names
                         StringBuffer sbn = new StringBuffer();
                         StringBuffer sbd = new StringBuffer();
                         for (int j = 0; j < rs.getColumnCount(); j++) {
                         sbn.append( rs.getColumnName(j).toString() );
                         sbn.append(";");
                         System.out.println("sbn "+sbn.toString());
//                          data
                         for (int k= 0; k< rs.getColumnCount(); k++) {
                         sbd.append( rs.getCellObject(k).toString() );
                         sbd.append(";");
                         entire.add(rs.getCellObject(k).toString());
                         System.out.println("sbd "+sbd.toString());
                         rs.next();
                    System.out.println(entire.size());
                    for(int i=0;i<entire.size();i++){
                         country.add(entire.get(i));
                         i++;
                         System.out.println("entireList "+entire.get(i));
                         resort.add(entire.get(i));
                    DataSourceObject city = ds.getClasses().getChildByName("Country");
                    DataSourceObject resorts = ds.getClasses().getChildAt(1);
                    dp.runQuery();
                    ReportContainer report = doc.createReport("Resort");
                    PageHeaderFooter header = report.getPageHeader();
                    FreeCell headerCell = header.createFreeCell("Resort Report");
                    PageHeaderFooter footer = report.getPageFooter();
                    FreeCell footerCell = footer.createFreeCell("Report Ends");
                    ReportBody body =  report.createReportBody();
                    for(int k=0;k<resort.size();k++){
                    FreeCell res=body.createFreeCell(resort.get(k));
                    res.getAttachTo();
                    res.setHeight(15d);
                    res.setWidth(30d);
                    Color c = new Color(255,255,255);
                    Color c1 = new Color(255,0,0);
                    FontImpl fnt = (FontImpl)res.getFont();
                    fnt.getDecoration().setTextColor(c1);
                    res.setFont(fnt);
                    //res.deleteAttachment();
                    //res.setAttachTo(body,VAnchorType.BOTTOM,HAnchorType.NONE);
                    doc.applyFormat();
                    doc.refresh();
                    final String l_docToken = doc.getStorageToken();
                    final DocumentInstance l_docToSave = reportEngine.getDocumentFromStorageToken(l_docToken);
                    doc.saveAs("mor31",835,null,null);
                    doc.closeDocument();
                    str = "SELECT SI_ID, SI_NAME, SI_PARENTID FROM CI_INFOOBJECTS WHERE (SI_KIND = '"+CeKind.WEBI+"' OR SI_KIND='FullClient') " +
                    "AND SI_INSTANCE = 'false' AND SI_NAME='mor31' ORDER BY SI_NAME ASC ";
                    //String str = "SELECT SI_ID, SI_NAME, SI_PARENTID FROM CI_INFOOBJECTS ORDER BY SI_NAME ASC ";
                    objInfoObjectsWIDs = (IInfoObjects) iStore.query(str);
                    System.out.println(objInfoObjectsWIDs.size());
                    objInfoObjectWID = (IInfoObject) objInfoObjectsWIDs.get(0);
                    DocumentInstance doc1 = reportEngine.openDocument(objInfoObjectWID.getID());
                    String token = doc1.getStorageToken();
                    DocumentInstance doc2 = reportEngine.getDocumentFromStorageToken(token);
                    doc2.saveAs("123123", 835, null, null);
               //     doc.refresh();
                    //doc.save();
               enterpriseSession.logoff();
          catch(Exception e)
               e.printStackTrace();

duplicate post:
Sample report using JAVA SDK

Similar Messages

  • SAP BO Report Scheduling and Save as report using Java SDK

    Hi All,
    We have a java product which is integrated with SAP BO using Java SDK and we have certain java screen through which we select report prompt values and webi report gets run.
    Now we want to give a functionality to save report to BO repository.
    When user select certain check box from java screen a separate copy of the webi report should get saved under default folder on BO repository.
    Also, we want user to choose the scheduling option from java screen only (and not the one which we use from BI Launchpad) due to certain access restriction. User does not have access to BI Launchpad. Only he can run report by selecting values through Java screen.
    If i need to create a separate screen for scheduling as well as saving webi report then also i am ok with it.
    P.S. i guess we need to work on Java SDK level. But could somebody please help me with the right direction?
    Let me know in case requirement is not clear.

    Hi Ketan,
    As you are on version BI 4.0 SP5 and would be migrating to BI 4.1, the best SDKs to use would be the Restful Webservices SDKs.
    You have the options to schedule a webi report with prompts as well as the save feature which you require.
    Please refer to the webi restful guides avialble at
    For BI 4.0 SP5
    http://help.sap.com/businessobject/product_guides/boexir4/en/xi4sp5_webi_restful_ws_en.pdf
    For BI 4.1 SP4
    http://help.sap.com/saphelpiis_sbo41sp4wi-sdk/frameset.htm
    Refer to the below blog to understand the Restfull Webservices SDKs.
    http://scn.sap.com/community/restful-sdk/blog/2013/09/07/scripting-web-intelligence-the-restful-raylight-web-services--learing-it
    More blogs on Rest are available at
    http://scn.sap.com/community/restful-sdk/content#filterID=contentstatus%5Bpublished%5D~objecttype~objecttype%5Bblogpost%5D
    You can find the samples from the below link
    http://scn.sap.com/community/restful-sdk/content#filterID=contentstatus%5Bpublished%5D~objecttype~objecttype%5Bdocument%5D
    You would need to refer to the community below in case you have concerns about Rest SDKs.
    http://scn.sap.com/community/restful-sdk
    Thanks,
    Prithvi

  • How to create cross tab reports using RAS SDK api with Crystal Reports XI

    Hi Everybody,
    Iam generating reports in a web-based application with Crystal Reports XI using Report Application Server(RAS) SDK API. The columns in my report exceed that of an A4 sized page. So, when I export that report to pdf, only those columns that fit to a page are showing up. To solve, this problem, I thought of using cross tab. But, I donot know how to generate cross tab report using RAS SDK API. I have tried to get some code from the internet. But, I did not find any java code for that.Can some one give me some sample code.It is very urgent.
    Thanks in advance.

    Hi,
    The easiest way I use is to create the worksheet as regular table and then when i verify the data I get (non aggregate) I duplicate it as a cross tab.
    In the duplication wizard I just need to define the axis (using drag and drop).
    if you want to create a cross tab from the beginning you need to define that in the new workbook wizard (check the "cross tab" rather then "table"), chose your fields and define the place you want them.
    The data point (the center of the cross tab) is aggregated as to your machine definition and will happen automatically.
    for example: to find the amount of receipt by months:
    On the left put the "Buyer Name", on top put the "Months" and in the data point put the amount.
    What you'll get is something like:
    months: jan feb mar apr ......
    buyer_name
    jhon_smith 100 50 30 250 ......
    jhon_doe 80 45 90 453 ........
    and so on.....

  • Error while trying to save a report using Java SDK for CR server 2011

    I use the java sdk to update the report database jndi alias and then save the report. While saving the report, the utility throws the following exception. It only happens to 3 reports out of more than 70 reports. What could be the problem with report that is causing this problem ?
    Thanks.
    com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: Failed to read data from report file C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\Data\CrystalRep
    ortsRasServer\temp\{56586260-E771-4C63-BF8B-F3CF14BB508A}.rpt. Reason: Repository object could not be found.---- Error code:-2147467259 [CRSDK00000000] Error code name:failed
            at com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException.throwReportSDKServerException(ReportSDKServerException.java:109)
            at com.crystaldecisions.proxy.remoteagent.ExceptionHelper.throwResultInfoException(ExceptionHelper.java:192)
            at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.sendSyncRequest(ReportClientDocument.java:803)
            at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.doSave(ReportClientDocument.java:820)
            at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.save(ReportClientDocument.java:2245)

    The error points to the report using a repository object that it cannot be found.  What happens if you try and update the reports using the Crystal Report Designer instead of the SDK?

  • Create a Crystal Report using Java

    Hi
    Im Using Java 6 to connect to a Crystal Reports server. Im trying to create a common API that we can use throughout our office for integration with Crystal Reports.
    But Im having troubles with my method to upload/create a report. If I create a new Report Object via the Business Objects Central Management Console then everything is fine, but I get some funnies when I do it via Java.
    My upload code is like this :
    IInfoObjects newObjs = infoStore.newInfoObjectCollection();
    IPluginInfo pluginInfo = infoStore.getPluginMgr().getPluginInfo(CeProgID.REPORT);
    IInfoObject newObj = newObjs.add(pluginInfo);
    IReport myReport = (IReport)newObj;
    myReport.setTitle("title");
    myReport.setParentID(parentId);
    IFiles files = myReport.getFiles();
    files.addFile(file);
    infoStore.commit(newObjs);
    Now that all works fine and I get no errors. When I look at the Central Management Console I can see the newly created Report, but when I click on it I dont get any of the standard tabs. i.e. 'Properties', 'History' etc, but I do get an error message on the screen that simply says "An internal error has occurred"
    I cant find anything in the logs to tell me what this error is, and my steps to create/upload the report seem to match every example I have found.
    Can anyone help with this problem?
    Thanks for your time

    cwhiteside, please don't post in threads that are long dead. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.
    I'm locking this thread now.
    db

  • My first program to create a crystal report from java... Help needed...

    Hi... I am writing a java program that fetches a table from database and creates a Crystal Report from that table(ResultSet object)... Optionally exporting the report as a pdf also...  This will be a console application since it is my first program using crystal reports.... Any one can help me with this...?

    Hi Karthik,
    you could have a look over these developer guides below for understanding of Java sdk :-
    [http://www.sdn.sap.com/irj/boc/sdklibrary|http://www.sdn.sap.com/irj/boc/sdklibrary]
    you could also find  below sample codes for creating reports using Java sdk (RAS sdk) :-
    [http://www.sdn.sap.com/irj/boc/samples|http://www.sdn.sap.com/irj/boc/samples]
    let me know if you need any help,
    Regards,
    Rameez.

  • How to create a report with data using the Crystal Reports for Java SDK

    Hi,
    How do I create a report with data that can be displayed via the Crystal Report for Java SDK and the Viewers API?
    I am writing my own report designer, and would like to use the Crystal Runtime Engine to display my report in DHTML, PDF, and Excel formats.  I can create my own report through the following code snippet:
    ReportClientDocument boReportClientDocument = new ReportClientDocument();
    boReportClientDocument.newDocument();
    However, I cannot find a way to add data elements to the report without specifying an RPT file.  Is this possible?  I seems like it is since the Eclipse Plug In allows you to specify your database parameters when creating an RPT file.
    is there a way to do this through these packages?
    com.crystaldecisions.sdk.occa.report.data
    com.crystaldecisions.sdk.occa.report.definition
    Am I forced to create a RPT file for the different table and column structures I have? 
    Thank you in advance for any insights.
    Ted Jenney

    Hi Rameez,
    After working through the example code some more, and doing some more research, I remain unable to populate a report with my own data and view the report in a browser.  I realize this is a long post, but there are multiple errors I am receiving, and these are the seemingly essential ones that I am hitting.
    Modeling the Sample code from Create_Report_From_Scratch.zip to add a database table, using the following code:
    <%@ page import="com.crystaldecisions.sdk.occa.report.application.*"%>
    <%@ page import="com.crystaldecisions.sdk.occa.report.data.*"%>
    <%@ page import="com.crystaldecisions.sdk.occa.report.document.*"%>
    <%@ page import="com.crystaldecisions.sdk.occa.report.definition.*"%>
    <%@ page import="com.crystaldecisions.sdk.occa.report.lib.*" %>
    <%@ page import = "com.crystaldecisions.report.web.viewer.*"%>
    <%
    try { 
                ReportClientDocument rcd = new ReportClientDocument();
                rcd.newDocument();
    // Setup the DB connection
                String database_dll = "Sqlsrv32.dll";
                String db = "qa_start_2012";
                String dsn = "SQL Server";
                String userName = "sa";
                String pwd = "sa";
                // Create the DB connection
                ConnectionInfo oConnectionInfo = new ConnectionInfo();
                PropertyBag oPropertyBag1 = oConnectionInfo.getAttributes();
                // Set new table logon properties
                PropertyBag oPropertyBag2 = new PropertyBag();
                oPropertyBag2.put("DSN", dsn);
                oPropertyBag2.put("Data Source", db);
                // Set the connection info objects members
                // 1. Pass the Logon Properties to the main PropertyBag
                // 2. Set the Server Description to the new **System DSN**
                oPropertyBag1.put(PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES, oPropertyBag2);
                oPropertyBag1.put(PropertyBagHelper.CONNINFO_CRQE_SERVERDESCRIPTION, dsn);
                oPropertyBag1.put("Database DLL", database_dll);
                oConnectionInfo.setAttributes(oPropertyBag1);
                oConnectionInfo.setUserName(userName);
                oConnectionInfo.setPassword(pwd);
                // The Kind of connectionInfos is CRQE (Crystal Reports Query Engine).
                oConnectionInfo.setKind(ConnectionInfoKind.CRQE);
    // Add a Database table
              String tableName = "Building";
                Table oTable = new Table();
                oTable.setName(tableName);
                oTable.setConnectionInfo(oConnectionInfo);
                rcd.getDatabaseController().addTable(oTable, null);
        catch(ReportSDKException RsdkEx) {
                out.println(RsdkEx);  
        catch (Exception ex) {
              out.println(ex);  
    %>
    Throws the exception
    com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: java.lang.NullPointerException---- Error code:-2147467259 Error code name:failed
    There was other sample code on SDN which suggested the following - adding the table after calling table.setDataFields() as in:
              String tableName = "Building";
                String fieldname = "Building_Name";
                Table oTable = new Table();
                oTable.setName(tableName);
                oTable.setAlias(tableName);
                oTable.setQualifiedName(tableName);
                oTable.setDescription(tableName) ;
                Fields fields = new Fields();
                DBField field = new DBField();
                field.setDescription(fieldname);
                field.setHeadingText(fieldname);
                field.setName(fieldname);
                field.setType(FieldValueType.stringField);
                field.setLength(40);
                fields.add(field);
                oTable.setDataFields(fields);
                oTable.setConnectionInfo(oConnectionInfo);
                rcd.getDatabaseController().addTable(oTable, null);
    This code succeeds, but it is not clear how to add that database field to a section.  If I attempt to call the following:
    FieldObject oFieldObject = new FieldObject();
                oFieldObject.setDataSourceName(field.getFormulaForm());
                oFieldObject.setFieldValueType(field.getType());
                // Now add it to the section
                oFieldObject.setLeft(3120);
                oFieldObject.setTop(120);
                oFieldObject.setWidth(1911);
                oFieldObject.setHeight(226);
                rcd.getReportDefController().getReportObjectController().add(oFieldObject, rcd.getReportDefController().getReportDefinition().getDetailArea().getSections().getSection(0), -1);
    Then I get an error (which is not unexpected)
    com.crystaldecisions.sdk.occa.report.lib.ReportDefControllerException: The field was not found.---- Error code:-2147213283 Error code name:invalidFieldObject
    How do I add one of the table.SetDataFields()  to my report to be displayed?
    Are there any other pointers or suggestions you may have?
    Thank you

  • How to get the filters of Webi document/Report using Java code in XI SDK.

    Hi All,
       I have a requirement where i have to extrcat filters from the Webi Document.using java SDK.
    I am trying to find the class called "filterable"but not able to use in my java code and will get always
    "java.lang.ClassCastException  com.businessobjects.wp.om.OMDocument cannot be cast to com.businessobjects.rebean.wi.Filterable"
    I am using the below java code like
    ReportElement re=document.getStructure()
    FilterContainer flt=((Filterable) re).getFilter()
    I am stuck and need this in uregent.
    Please help.

    Hi Rajeev,
    To retrieve a FilterContainer you will need to traverse the report structure:
    ReportStructure boReportStructure = boDocumentInstance.getStructure();
    ReportContainer boReportContainer = (ReportContainer) boReportStructure.getReportElement(0);
    FilterContainer boFilterContainer = null;
    if (boReportContainer.hasFilter()) {
         boFilterContainer = boReportContainer.getFilter();
    } else {
         boFilterContainer = boReportContainer.createFilter(LogicalOperator.AND);
    Calling boDocumentInstance.getStructure() will retrieve the entire structure for the document.
    Calling boReportStructure.getReportElement(0) will retrieve the structure for the first report of the document.
    Hope this helps.
    Regards,
    Dan

  • How to set DbConnections when scheduling a crystal report using Crystal Reports Server Java SDK?

    Post Author: Manjula
    CA Forum: JAVA
    Hi,
    Trying to schedule a report using Crystal Reports Server Java SDK. Want to pass DBConnections from API, though passing DBConnections, the report is not being scheduled and says "Failed to retrieve data from the database.Details:&#91;Database Vendor Code:6550&#93;.
    Would be thankful if someone could answer my point as applicable.
    Here is the code attached.
    ISDKList dbLogons = oReport.getReportLogons();int dbLogonSize = dbLogons.size();
    for(int i=0; i<dbLogonSize; ++i) {
    IReportLogon dbLogon = (IReportLogon)dbLogons.get(i);
    dbLogon.setDatabaseName("DBname");
    dbLogon.setUserName("usrname");
    dbLogon.setPassword("pwd");
    Thanks in advance.

    Post Author: Manjula
    CA Forum: JAVA
    Ted,
    Thank you for your valuable information.
    First, tried scheduling on Central Management Console and then with the java code.It worked fine, but here is another question for you.
    On the Console, a report exists with ServerName and UserName harcoded and when trying to set ServerName and UserName from the java code, its throwing exception. Where as Password is not set on Console, am able to set password from java.
    And DatabaseName is not set on Console (non editable), unable to set the same from java too. Why is it so?
    So, my question is - though ServerName,DatabaseName,UserName,Password exists on the Console report, can't I override those parameters from java?
    Would be greatful if you answer my question and provide me some guidance.
    Thanks in advance.

  • Update database logon in reports using java

    Please review the code below and let me know where did I go wrong! I am able to login to CMS and able to retrieve the list of reports. Now, I am trying to update the database credentials for a single report using java (My requirement is to update all 200 reports though!).
    This is the 100th time I go this error message: Failed to open the connection.report.lib.ReportSDKServerException: Failed to open the connection.
    I also wrote a sample java program which tries to connect to the sql server database with same login credentials - this works perfectly fine. But, if I use the same connection url, driver name and login credentials, this report fails to update for whatever reason. Please help me ASAP..Thanks!
    import com.crystaldecisions.sdk.exception.*;
    import com.crystaldecisions.sdk.framework.*;
    import com.crystaldecisions.sdk.occa.infostore.*;
    import com.crystaldecisions.sdk.occa.managedreports.*;
    import com.crystaldecisions.sdk.occa.report.application.*;
    import com.crystaldecisions.sdk.occa.report.data.*;
    import com.crystaldecisions.sdk.occa.report.lib.*;
    import java.util.Iterator;
    class ChangeDataSource {
        public static void main(String args[]){
             String cms = "134.X.X.X:6400";
             String username = "Administrator";
             String password = "";
             String auth = "secEnterprise";
             IEnterpriseSession enterpriseSession = null;
             ISessionMgr sessionMgr = null;//CrystalEnterprise.getSessionMgr();   
             Exception failure = null;
             boolean loggedIn = true;
             ReportClientDocument clientDoc = null;
             if (enterpriseSession == null)
              try
                  sessionMgr = CrystalEnterprise.getSessionMgr();
                  enterpriseSession = sessionMgr.logon(username, password, cms, auth);
                  System.out.println("\nLOGIN SUCCESSFUL\n");
              catch (Exception error)
                  loggedIn = false;
                  failure = error;
              if (!loggedIn)
                   System.out.println("\nLOGIN FAILED\n");
              else
                  // Query for the sample report from the Enterprise CMS.
                  try {
                        IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore");
                        IInfoObjects infoObjects = iStore.query("Select SI_ID From CI_INFOOBJECTS Where SI_INSTANCE=0 AND SI_PARENT_FOLDER=771");
                        System.out.println("\ninfoObjects size = "+infoObjects.getResultSize());
                        IReportAppFactory reportAppFactory = (IReportAppFactory)enterpriseSession.getService("RASReportFactory");
                        IInfoObject infoObject = (IInfoObject)infoObjects.get(0);      
                        clientDoc = new ReportClientDocument();
                        clientDoc = reportAppFactory.openDocument(infoObject,0, java.util.Locale.US);
                        System.out.println("Report "+ infoObject.getTitle() +" Opened");     
                        switch_tables(clientDoc.getDatabaseController());
                   }catch(ReportSDKException re){                    
                        re.printStackTrace();
                   }catch(SDKException re){
                        re.printStackTrace();
         private static void switch_tables(DatabaseController databaseController) throws ReportSDKException {
              //Declare the new connection properties that report's datasource will be switched to.
              //NOTE: These are specific to using JDBC against a particular MS SQL Server database.  Be sure to use the
              //DisplayConnectionInfo sample to determine what your own connection properties need to be set to.
              final String TABLE_NAME_QUALIFIER = "dbname.dbo.";
              final String DATABASE_NAME = "dbname";
              final String DBUSERNAME = "userid";
              final String DBPASSWORD = "pword";
              final String SERVERNAME = "134.X.X.X";
              final String CONNECTION_URL = "jdbc:sqlserver://134.X.X.X:1433;DatabaseName=dbname";
              final String DATABASE_CLASS_NAME = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
              final String DATABASE_DLL = "crdb_jdbc.dll";
              //Obtain collection of tables from this database controller.
              Tables tables = databaseController.getDatabase().getTables();
              System.out.println("\nTables size = "+tables.size());
              //Set the datasource for all main report tables.
              for (int i = 0; i < tables.size(); i++) {
                   //ITable currTable = tables.getTable(i);     
                   ITable table = tables.getTable(i);
                   //Keep existing name and alias.
                   table.setName(table.getName());
                   table.setAlias(table.getAlias());
                   //System.out.println("Table Name = "+table.getName()+" Alias "+table.getAlias());
                   //Change properties that are different from the original datasource.
                   table.setQualifiedName(TABLE_NAME_QUALIFIER + table.getName());
                   System.out.println(table.getQualifiedName());
                   //Change connection information properties.
                   IConnectionInfo connectionInfo = null;
                   try{
                        connectionInfo = table.getConnectionInfo();
                        //System.out.println("conn info: "+connectionInfo);
                   }catch(Exception re) {
                        re.printStackTrace();
                   //Set new table connection property attributes.
                   PropertyBag propertyBag = new PropertyBag();
                   //Overwrite any existing properties with updated values.
                   propertyBag.put("Trusted_Connection", "false");
                   propertyBag.put("Connection URL", CONNECTION_URL);
                   propertyBag.put("Database Class Name", DATABASE_CLASS_NAME);
                   propertyBag.put("Server", SERVERNAME);
                   //propertyBag.put("Database Name", DATABASE_NAME);
                   propertyBag.put("Server Type", "JDBC (JNDI)");
                   //propertyBag.put("URI", null);
                   propertyBag.put("Use JDBC", "true");
                   propertyBag.put("Database DLL", DATABASE_DLL);
                   connectionInfo.setAttributes(propertyBag);
                   System.out.println("\n Properties SET\n");
                   //Set database username and password.
                   //NOTE: Even if these the username and password properties don't change when switching databases, the
                   //database password is *not* saved in the report and must be set at runtime if the database is secured. 
                   connectionInfo.setUserName(DBUSERNAME);
                   connectionInfo.setPassword(DBPASSWORD);
                   connectionInfo.setKind(ConnectionInfoKind.SQL);
                   table.setConnectionInfo(connectionInfo);
                   //Update old table in the report with the new table.
                   try {
                        databaseController.setTableLocation(table, tables.getTable(i));               
                        }catch(ReportSDKException re) {
                        re.printStackTrace();
                   System.out.println("\n All tables updated\n");

    I have exactly same error. I can confirm that CRJavaHelper.changeDataSourceReportClientDocument clientDoc,
                    String reportName, String tableName,
                    String username, String password, String connectionURL,
                    String driverName,String jndiName)
    has very slow performance.
    Obviously the line:
                        clientDoc.getDatabaseController().setTableLocation(origTable, newTable);
    works very slow. I also have JDBC defined in report and also stored procedure, that returns recordset (cursor) in 0.48 sec.
    I am using CR Reports Server XI R2 and custom JAVA client program that renders report to pdf.
    Lines from java program:
    rpt = new ReportClientDocument();
    String report = "C:
    temp
    CrystalReport1.rpt";
    rpt.open(report, com.crystaldecisions.sdk.occa.report.application.OpenReportOptions._openAsReadOnly);
    CRJavaHelper.changeDataSource(rpt, "The specified item was not found.", "", "jdbc:oracle:thin:@oratest:1521:oratest","oracle.jdbc.driver.OracleDriver", "");
    CRJavaHelper.addDiscreteParameterValue(rpt, "", "P_INET_ID", id);
    rpt.refreshReportDocument();
    PDFExportFormatOptions pdfOptions = new PDFExportFormatOptions();
    ExportOptions exportOptions = new ExportOptions();
    exportOptions.setExportFormatType(ReportExportFormat.PDF);
    exportOptions.setFormatOptions(pdfOptions);
    InputStream is = rpt.getPrintOutputController().export(exportOptions);

  • Call Unix Command From Reports Using Java

    Hi,
    Could somebody please show me a sample coding to call Unix command from 10g report using java?
    In metalink doc id 361857.1 does not show much.
    Thanks,
    neemin

    Hi,
    I have a problem with synchronization of the java commands.
    In the Before Parammeter Form trigger, I have:
    function BeforePForm return boolean is
    rt ORA_JAVA.JOBJECT;
    proc ORA_JAVA.JOBJECT;
    v_txt varchar2(32000);
    i integer := 0;
    v_cd_modulo int;
    v_arqlog text_io.file_type;
    cursor c_evento is
    select codigo,
    nome
    from
    (select e.cd_evento || e.cd_edicao codigo
    ,nm_evento nome
    from grh_ev_evento e
    where e.CD_GRUPO in (select cd_grupo
    from grh_ev_adm
    where cd_usuario = (select cd_usuario
    from usuario
    where login_usuario = :AUTHID)))
    order by substr(nome, 11);
    begin
    -- Create the context for logged user
    if instr(upper(nvl(:AUTHID,'RWCLIENT')),'RWCLIENT') > 0 then
    :AUTHID := :SSO_USUARIO;
    end if ;
    TCEENV.SET_TCEENV(:AUTHID);
    if PK_SCA.SCA_GET_USER_RIGHTS(:sca_module_name, :AUTHID) IS NULL then
    srw.message(100, 'Access denided!');
    return (FALSE);
    end if;
    -- Create file in Report Server (UNIX)
    v_txt := '<BR>' || htf.formSelectOpen('P_EV_EDICAO', 'Evento: ');
    :p_file := '/u03/SCAWEB/repout/' || :sca_module_name || '_' ||
    pk_sca.sca_encrypt(:AUTHID || to_char(systimestamp, 'ss.ff'));
    v_arqlog := text_io.fopen (:p_file, 'A');
    text_io.put_line (v_arqlog, v_txt);
    for reg in c_evento loop
    i := i + 1;
    if i = 1 then
    v_txt := '<OPTION SELECTED VALUE="' || reg.codigo || '">' || reg.nome;
    else
    v_txt := '<OPTION VALUE="' || reg.codigo || '">' || reg.nome;
    end if;
    text_io.put_line (v_arqlog, v_txt);
    end loop;
    v_txt := '</SELECT></CENTER></form></BODY> </HTML>';
    text_io.put_line (v_arqlog, v_txt);
    text_io.fclose (v_arqlog);
    SRW.SET_AFTER_FORM_HTML(SRW.FILE_ESCAPE, :p_file);
    rt := RUNTIME.GetRuntime();
    proc := RUNTIME.exec(rt,'rm ' || :p_file);
    return (TRUE);
    end;
    The problem is that there isn't a "synchronize" command, and the
    RUNTIME.exec(rt,'rm ' || :p_file) don't works (it does nothing) because
    the SRW.SET_AFTER_FORM_HTML has a large delay and the following
    command is ignored.
    How can I solve it?
    thanks,
    lmprestes

  • Having trouble with creation of a cloud service with multiple virtual machines using java sdk.

    I am creating a cloud service on azure with 2 virtual machines using java sdk API. Service created successfully.
    My input endpoint details are as follows.
    INPUT ENDPOINTS
    Head : 191.238.144.47:2400
    Head : 191.238.144.47:22
    Node0 : 191.238.144.47:43211
    For Head instance port 2400 is for HTTPS and port 22 is for SSH and for Node0 instance port 43211 is for SSH.
    But I am having problem with doing a ssh on Head instance. Sometimes it works sometimes doesn't. Same problem with HTTPS also.
    I have some application running over there but when i try to access it thru browser sometimes it works but most of the time doesn't. When I restart the instances from azure portal, its works after
    that(not always but most of the time). 
    Now I am confused what is going on there. I am creating cloud service and virtual machines using java sdk and setting input endpoints also. After creation of all instances i restart every instance programmatically .
    I am not sure whether restart is required or not. It must be something to do with input endpoints only but not able to get the right thing i guess. When i do the same thing thru azure portal(creation of cloud service with virtual machines and setting up input
    end points) everything works fine but not achieving the result when implementing it by java sdk API. Please help me.

    HI Nithin,
    Thanks for your reply. I am setting the endpoints after creating my instances using update call. Here's the code snippet.
    AzureService aServ = new AzureService(session);
     if(aServ.checkNameAvailability(clusterName)) {
               aServ.createHostedService(clusterName, "dbX cluster");         
             // Creating head instance
             aServ.createHead(clusterName, imgName, headType, userName, pswd);  
            // Setting end points for head node
             String name = "ssh";
             int port = 22;
             aServ.updateVMInputEndpoint(clusterName, "Head", name, port);
             // Restarting head instance
             aServ.restartVM(clusterName, "Head");
           String roleName = "Node";
           String tmpRoleName = "";
           for(int i=0; i<noi; i++) {
                      port = 43210+(i+1);
                      tmpRoleName = roleName + i;
                   // Creating node instance
                    aServ.createVM(clusterName, tmpRoleName, imgName, nodeType, userName, pswd);
                  // Setting end points for node instance
                   aServ.updateVMInputEndpoint(clusterName, tmpRoleName, name, port);
                  // Restarting node instance
                 aServ.restartVM(clusterName, tmpRoleName);
          // Method to update the input endpoint details 
          public void updateVMInputEndpoint(String clusterName, String vmName, String name, int port)
            throws Exception {
                    VirtualMachineGetResponse resp = computeManagementClient.getVirtualMachinesOperations().
                                                            get(clusterName, clusterName, vmName);
                    VirtualMachineUpdateParameters updateParameters = new VirtualMachineUpdateParameters();
                    //get the configuration list
                    ArrayList<ConfigurationSet> configlist = resp.getConfigurationSets();
                    //get inputendpoint list and update it
                    ArrayList<InputEndpoint> endpointlist = configlist.get(0).getInputEndpoints();
                    InputEndpoint inputEndpoint = new InputEndpoint();
                    inputEndpoint.setEnableDirectServerReturn(false);
                    inputEndpoint.setPort(port);
                    inputEndpoint.setLocalPort(port);
                    inputEndpoint.setName(name);
                    inputEndpoint.setProtocol(InputEndpointTransportProtocol.TCP);
                    endpointlist.add(inputEndpoint);
                    // Open port for https on head node
                    if(vmName.equals("Head")) {
                            inputEndpoint = new InputEndpoint();
                            inputEndpoint.setEnableDirectServerReturn(false);
                            inputEndpoint.setPort(2400);
                            inputEndpoint.setLocalPort(2400);
                            inputEndpoint.setName("https");
                            inputEndpoint.setProtocol(InputEndpointTransportProtocol.TCP);
                            endpointlist.add(inputEndpoint);
                    updateParameters.setConfigurationSets(configlist);
                    //required for update
                    OSVirtualHardDisk osVirtualHardDisk = resp.getOSVirtualHardDisk();
                    updateParameters.setOSVirtualHardDisk(osVirtualHardDisk);
                    updateParameters.setRoleName(resp.getRoleName());
                    OperationResponse updtResp = computeManagementClient.getVirtualMachinesOperations().update(clusterName, clusterName, resp.getRoleName(), updateParameters);
    And every time i am creating a new cloud service along with head and node instances. Region is "South Central US".
    I am setting ProvisionGuestAgent field to true at instance creation time. Thank you.

  • How do we create self-signed certificate using java packages

    Hi All,
    I require some information on creating self-signed certificate using java packages.
    The java.security.cert.* package allows you to read Certificates from an existing store or a file etc. but there is no way to generate one afresh. See CertificateFactory and Certificate classes. Even after loading a certificate you cannot regenerate some of its fields to embed the new public key &#8211; and hence regenerate the fingerprints etc. &#8211; and mention a new DN. Essentially, I see no way from java to self-sign a certificate that embeds a public key that I have already generated.
    I want to do the equivalent of &#8216;keytool &#8211;selfcert&#8217; from java code. Please note that I am not trying to do this by using the keytool command line option &#8211; it is always a bad choice to execute external process from the java code &#8211; but if no other ways are found then I have to fall back on it.
    Regards,
    Chandra

    I require some information on creating self-signed certificate using java packages. Its not possible because JCE/JCA doesn't have implementation of X509Certificate. For that you have to use any other JCE Provider e.g. BouncyCastle, IAIK, Assembla and etc.
    I'm giving you sample code for producing self-signed certificate using IAIK JCE. Note that IAIK JCE is not free. But you can use BouncyCastle its open source and free.
    **Generating and Initialising the Public and Private Keys*/
      public KeyPair generateKeys() throws Exception
          //1 - Key Pair Generated [Public and Private Key]
          m_objkeypairgen = KeyPairGenerator.getInstance("RSA");
          m_objkeypair = m_objkeypairgen.generateKeyPair();
          System.out.println("Key Pair Generated....");
          //Returns Both Keys [Public and Private]*/
          return m_objkeypair;
    /**Generating and Initialising the Self Signed Certificate*/
      public X509Certificate generateSSCert() throws Exception
        //Creates Instance of X509 Certificate
        m_objX509 = new X509Certificate();
        //Creatting Calender Instance
        GregorianCalendar obj_date = new GregorianCalendar();
        Name obj_issuer = new Name();
        obj_issuer.addRDN(ObjectID.country, "CountryName");
        obj_issuer.addRDN(ObjectID.organization ,"CompanyName");
        obj_issuer.addRDN(ObjectID.organizationalUnit ,"Deptt");
        obj_issuer.addRDN(ObjectID.commonName ,"Valid CA Name");
        //Self Signed Certificate
        m_objX509.setIssuerDN(obj_issuer); // Sets Issuer Info:
        m_objX509.setSubjectDN(obj_issuer); // Sets Subjects Info:
        m_objX509.setSerialNumber(BigInteger.valueOf(0x1234L));
        m_objX509.setPublicKey(m_objkeypair.getPublic());// Sets Public Key
        m_objX509.setValidNotBefore(obj_date.getTime()); //Sets Starting Date
        obj_date.add(Calendar.MONTH, 6); //Extending the Date [Cert Validation Period (6-Months)]
        m_objX509.setValidNotAfter(obj_date.getTime()); //Sets Ending Date [Expiration Date]
        //Signing Certificate With SHA-1 and RSA
        m_objX509.sign(AlgorithmID.sha1WithRSAEncryption, m_objkeypair.getPrivate()); // JCE doesn't have that specific implementation so that why we need any //other provider e.g. BouncyCastle, IAIK and etc.
        System.out.println("Start Certificate....................................");
        System.out.println(m_objX509.toString());
        System.out.println("End Certificate......................................");
        //Returns Self Signed Certificate.
        return m_objX509;
      //****************************************************************

  • Creating a service report using SQVI

    Hi experts
    I am creating a service report using SQVI
    The report should have the following fiels
    SrvPO No | SrvPO Data | vendor | Stata  | City | Type of Srv (Ad\banner|maintnc.)  | Amount | Status(open or closed)
    I am using the following tables using table join fnc
    1. EKKO
      EBELN-PO No
    AEDAT - PO Data
    LIFNR - Vendor
    PROCSTAT - Status of PO doc
    2.LIFNR
    REGIO - State
    ORTO1 - City
    3. ESSR
    TXZ01 - Type of Service (Short text)
    4.EKPO
    NETWE - Net amount of PO
    All the tables are legally join but after executing I am not able to fetch any data or hardly one service PO.
    And the selection field will be only From Date and To date.or the Service PO No.
    Immediate response is urgent
    Regards
    Partha

    Moderator message: you said your  issue is solved but did not mark your discussion as such, please see
    How to close a discussion and why

  • Need help in creating a sample application using Oracle I\PM 10gR3.

    I am a new to Oracle I\PM 10gR3 and I need a guide to create a sample
    application using Filer and a sample Process.
    I have searched the net and was unable to find any documents. If any body has
    any kind of guide to create an application please let me know.
    Waiting for a response.

    Please see Kenichi Unnai in his blog "How to use UWL API for NetWeaver BPM Tasks"
    How to use UWL API for NetWeaver BPM Tasks
    The .sca-file can be found on the sap service marketplace, afterwards you need to import the .sca-file, add the SC to your "MyComponents" and then you can select your necessary DC's.

Maybe you are looking for