cancel
Showing results for 
Search instead for 
Did you mean: 

Hi a subreport problem here...Some body plz give a soln. to it

Former Member
0 Kudos

Hi All,

I want to sort the sub reports in a main report programatically from c#.net.

I mean we have say 5 sub reports and programatically i want to call the 1st subreport at 4th position, 2nd at the first etc.

Let me know if i am not clear in making you understand my problem.

Or tell me how to access the crystal report sections in the c# codebehind.

I am using vs2010 with crystal reports.

Thanks

Madhav

Edited by: madhavkulkarni on Jul 8, 2011 8:38 AM

Accepted Solutions (1)

Accepted Solutions (1)

aasavaribhave
Advisor
Advisor
0 Kudos

Can you please explain what you mean by:

"i want to call the 1st subreport at 4th position, 2nd at the first etc"

When you insert seubreports in the main report, you can place them in different sectionson report e.g. report\page header, report\page footer or details section. If the report is embedded, it will run and you will see it. If the report is on demand, you will see a hyperlink for the subreport, upon clicking the hyperlink you will see the report. Since report is rendered page by page basis, depends on where and how the subreports are placed in the main report will determine the order in which subreport data is fetched.

Former Member
0 Kudos

Hey thanks for your views, Actually i have kept each supreports in each detail sections.

Now what i need is to get the subreports or say sections based on the users input.

e.g,

Say i have sub reports A, B, C and D

if the user send a paramerter or if we can handle it in .net of sorting the sub reports or sections based on the users need.

if the user say he needs it in B,C,A and D format then i should show the report in BCAD format only.

The sorting order will dynamically come from an XML, So we can't predict the sorting order as Ascending or Descending.

One way is to keep all 4supreports in a single detail section and suppress the rest 3 supreports based on the parameters passed to the main report. But the number of subreports will be 16 instead of 4, that will lead to performance problem.

Thanks

Madhav

aasavaribhave
Advisor
Advisor
0 Kudos

This should be doable with RAS .NET SDK where you can dynamically reposition the subreport based on user's input using the RAS APIs. With 16 subreports it's going to be lots of permutation\combination you may end up writing very complex logic identifying the subreport and identifying the section it needs to be moved into.

A simple and quick solution could be to create multiple report templates (different subreport positions) and based on user's input you can choose to run a specific template. This would not even cause any performance issues which are most likely in the earlier one.

aasavaribhave
Advisor
Advisor
0 Kudos

to add: I dont think you can move sections to different positions in reports, you can only move the objects in different sections. The section position is fixed.

Former Member
0 Kudos

Hey,

Can you give me a clear picture of how to achieve by the below solution

A simple and quick solution could be to create multiple report templates (different subreport positions) and based on user's input you can choose to run a specific template. This would not even cause any performance issues which are most likely in the earlier one.

Thanks

Madhav

Former Member
0 Kudos

Hey i tried that too.

Please see the below code.

objrh.Section4.ReportObjects["Borrower.rpt"].Top = 0;

Here i tried to move the subreport to the top of main page, but ended with section4 top 0 position, Could you plz tell me how can i move a subreport that is available in Section4 to Section1

Thanks

Madhav

former_member183750
Active Contributor
0 Kudos

I wonder if a bit different approach (perhaps a bit simpler approach) will work;

Start with a main report - no subreports. What ever subreports you want to maneuver \ position \ move in the main report, should be stand-alone reports sitting in some folder.

Once you know which report will go into which section, import the subreports from the folder to that section. E.g.;

 


try 
{ 
//Get SubreportController object from ReportClientDocument object 
SubreportController subRptController = reportClientDocument. getSubreportController(); 
String name = "GlobalSales.rpt";; 
String reportURL = "C:\MyReports\GlobalSales.rpt";; 
//Get the section into which the subreport will be added 
ISection footerSection = reportClientDocument.getReportDefController() .findSectionByName 
("FooterSection"); 
//Return the imported existing report as a SubReportClientDocument object 
ISubreportClientDocument subRptClientDocument = subRptController. importSubreport(name, 
reportURL, footerSection); 
} 
catch (ReportSDKException e) 
{ 
//do something here 
} 


Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

Former Member
0 Kudos

Hi Ludek,

In order to achieve by this way i need to have RAS .NET dll right?

Do i need to purchase the RAS .NET dll or i can download it from any place.

Hope this will work.

Regards,

Madhav

former_member183750
Active Contributor
0 Kudos

No you do not. InProc RAS is included with CRVS2010.

InProc RAS examples:

https://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples

- Ludek

Former Member
0 Kudos

Hey thats great but why am i getting an error for the below mentioned things:

I tried a sample code of PDFEXPORT_CS, but was not able to debug and check how it works, I am not able to run the solution too.

For the first time when i opened the solution it gave me an error regarding ObjectFactory, saying

Error 1 Could not load file or assembly 'CrystalDecisions.ReportAppServer.ObjectFactory, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified. D:\MadhavWorkingFolder\CR.NET SDK\Report Modification\ras_samples\PDFExport\PDFExport_CS\PDFExport_CS\Web.Config 36

Later i commented the line of code regarding ObjectFactory as the version did not match and added a reference with the version 13.0.2000.0 and found the below issues:

// Log on to an Enterprise server.

SessionMgr sessionMgr = new SessionMgr();

EnterpriseSession enterpriseSession;

enterpriseSession = sessionMgr.Logon("Administrator", "password", "localhost:6400", "secEnterprise");

// Create an instance of the InfoStore Enterprise Service

EnterpriseService enterpriseService;

InfoStore infoStore;

InfoObjects infoObjects;

InfoObject infoObject;

I get an error saying:

Error 1 The type or namespace name 'SessionMgr' could not be found (are you missing a using directive or an assembly reference?) D:\MadhavWorkingFolder\CR.NET SDK\Report Modification\ras_samples\PDFExport\PDFExport_CS\PDFExport_CS\Default.aspx.cs 132 9 D:\...\PDFExport_CS\

Regarding the license part, you mean we need not to take any license to RAS .NET SDK?

Regards,

Madhav

former_member183750
Active Contributor
0 Kudos

Note the error:



Could not load file or assembly 'CrystalDecisions.ReportAppServer.ObjectFactory, Version=*12.0.1100.0*

You need to change the reference to 13.x as you are using CRVS2010.

Alos, see the article [WP inproc How to Use The RAS SDK .NET With In-Process RAS Server|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10b840c0-623f-2b10-03b5-9d1913866b32].

And re. licensing - correct.

- Ludek

Former Member
0 Kudos

Hey,

That was very helpful, i will go through the same and let you know for any issues.

Regards,

Madhav

Former Member
0 Kudos

Hi,

Now i could import the subreports dynamically using RAS.NET SDK.

Here i am assigning the datasource using Object Collection from an XML file.

Then assigning the xml data to properties and in turn to an arraylist and then to the subreport.

As below:




rd.Subreports["Residence.rpt"].SetDataSource(arrResidenceInfo);


Earlier i had a method for report document as subreports but now in RAS.NET SDK for ISCDReportClientDocument i could find the below code:




rcd.SubreportController.SetDataSource("RequestHeader", arrPreparedBy, "CRReportObjects_PreparedBy", "CRReportObjects_PreparedBy");


When i give this i am getting an error as:

The data source object is not supported.

Is there any other way i could set the datasource to the subreports dynamically or i should check on the paramerters for the above line of code(i doubt with the old and new table name, what actually i should pass there).

Thanks

Madhav

former_member183750
Active Contributor
0 Kudos

You will have to use the DataSetConverter object like this:

// pass dataset to report

m_crReportDocument.DatabaseController.SetDataSource(DataSetConverter.Convert(m_dataset), "Customer", "Customer");

See the attached app for details.

More sample apps are here:

https://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples

- Ludek

Former Member
0 Kudos

Hi Ludek,

I don't want to use the dataset i was earlier passing an arraylist to the setdatasource method of report document, don't we have the same feature in RAS.NET SDK.

As passing the datasource as Arraylist fulfills our requirement and it was working fine with:

rd.Subreports["reportname"].SetDataSource(arraylist_as_datasource);

Can i have something very similiar to this in RAS, is what i want to know.

As all rest of the things looks working to me, but now stuck to this setting of datasource to supreport.

Regards,

Madhav

Former Member
0 Kudos

Hi,

Importing of subreports is fine but getting a Logon Failed error which is not letting me move further.

What should i do if i don't have a initial catalog or connectioninfo for a datasource like created in Project Data, .Net Objects(where in we pass the Namespace.ClassName as datasource).

As i am fetching the information from an xml file and through Project Data, .NET Objects i am getting the property values in the crystal report datasource, but the report gives an error as Database Logon Failed, what is the initial catalog that i have to pass when i don't have it or what connection info should i pass.

The datasource is the namespace.classname for the crystal report and all others will be property values.

Else can you show me a demo of code where i can access the crystal report controls in .NET as we access sections or subreports.

So that i can directly assign the values to the crystal report controls from .NET only, instead of sending the datasource to the crystal report and then assigning it right.

Can you please provide a sample application with this scenario.

Let me know if i am not clear enough to explain my scenario.

Thanks,

Madhav

former_member183750
Active Contributor
0 Kudos

As you are not passing a dataset to these subreports, I think the blog [Crystal Reports and PONOs, POCOs and Classes(OH MY!)|/people/trevor.dubinsky/blog/2010/09/03/crystal-reports-and-ponos-pocos-and-classesoh-my] will be something to look at and use as a guide.

- Ludek

Former Member
0 Kudos

Ludek,

What do you think is that a good approach to go with Project Data/.NET Objects?

One more issue that i am facing is database logon failed when i assign:

ISCDReportClientDocument reportclientdocument=reportdocument.reportClientDocument;

With out using the RAS client document the project runs fine.

But when i assign the reportclientdocument with reportdocument as shown above, i get the database logon failed error.

Can you send me the sample for the connectioninfo with databasetype as .Net Objects.

I don't want CodeBuilder-RasConnectionInfo as i have already checkit it for my reports and passed the connection info and still it is giving me an error as

"Logon failed.\rError in File BoxedCreditReport {CDED2E35-F7BE-439F-A523-3C6275CFD69B}.rpt:\nUnable to connect: incorrect log on parameters."

Thanks,

Madhav

former_member183750
Active Contributor
0 Kudos

I wonder if getting the logon code written out from the report will help. See KB [1553921 - Is there a utility that would help in writing database logon code?|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333533353333333933323331%7D.do]

The above KB has a link to a utility app. All you have to do is point the utility at a report and it will write the logon code for you in VB and C#.

- Ludek

Former Member
0 Kudos

Hi,

Can we work with RAS In Proc without Business Objects OEM Partner Program.?

As everytime if we use the report client document we get some or the other errors like:

Logon Failed.

Operation not yet implemented.

Incorrect Parameters etc.

Let me know if we need to purchase the license and use it.

Thanks,

Madhav

former_member183750
Active Contributor
0 Kudos

Can we work with RAS In Proc without Business Objects OEM Partner Program.?

- Yes

I'd suggest creating a phone case here;

http://store.businessobjects.com/store/bobjamer/en_US/pd/productID.98078100?resid=S6I@hgoHAkEAAGsiyV...

- Ludek

Answers (1)

Answers (1)

0 Kudos

Hi Madhav,

Think of Crystal Reports as a book, Start with the first chapter ( Report Header ) and then move on to the Second chapter ( Page Header ) etc..... Where you place the subreports is where they get executed.

I believe what you want to do is moved the subreport at runtime, can be done but with warnings, depends on how they are linked etc. Using RAS you can clone the subreport objects and then move then to any section and set the link back up again.

It may work....

Can you explain why you want to move them, which is the same thing as running them in a different order?

I think what you need to do is go back to the Report Designer and add the subreports into each section and then set up suppression logic to suppress the one you don't want to run....

You also may want to have a look at what you are trying to accomplish, there may be easier ways to do this rather than moving subreports around.

Subreports will affect performance, if you can lay out your report, possibly using a Stored Procedure to collect/link the data that would be better than using subreports.

Good luck

Don