cancel
Showing results for 
Search instead for 
Did you mean: 

Determining if a field/formula will participate in an export

ido_millet
Active Contributor
0 Kudos

VS 2010, CR 2011, winform application.

After previewing a report in a viewer application, is there a way to use code to determine which main report fields/formulas would participate in an export?

Or is there a way to identify which main report fields/formulas are currently visible on the main report layout, or currently hidden but may become visible through drill-down?

Thanks,

- Ido

Accepted Solutions (1)

Accepted Solutions (1)

saurabh_pathak
Active Contributor
0 Kudos

Hi Ido,

With the following code you should be able to find all the fields on the main reports

private void FindReportObects(ReportDocument reportDocument)
    {
        if (reportDocument.ReportDefinition.ReportObjects.Count > 0)
        {

            Response.Write("<table border=1 cellspacing=2>");
            Response.Write("<tr>");
            Response.Write("<td><b>Report Object Name</b></td>");
            Response.Write("<td><b>Report Kind</b></td>");
            Response.Write("<td><b>Report Object Format</b></td>");
            Response.Write("</tr>");

            foreach (ReportObject reportObject in reportDocument.ReportDefinition.ReportObjects)
            {
                Response.Write("<tr>");
                Response.Write("<td>" + reportObject.Name + " </td>");
                Response.Write("<td>" + reportObject.Kind.ToString() + " </td>");
                Response.Write("<td>" + reportObject.ObjectFormat.ToString() + " </td>");
                Response.Write("</tr>");
            }

            Response.Write("</table>");
        }

    }

With drilldown you should be able to find the GroupName, ObjectName, GroupPath, and DataContext.

You can use DrillDownEventArgs class for above.

For more you can use [Crystal Reports .NET SDK API Reference|http://help.sap.com/businessobject/product_guides/boexir31/en/crsdk_net_apiRef_12_en.chm]

Hope that helps

Thanks,

Saurabh

ido_millet
Active Contributor
0 Kudos

Thanks for the reply, but it doesn't address the question. I am not looking for a way to detect ALL fields.

I am looking for a way to identify ONLY those fields that are visible or that can become visible. Or alternatively, only those fields that participate in an export. For example, a field/formula placed in a suppressed detail section does not participate in an export and can't become visible during a Preview session. I want to separate potentially visible fields from all others.

saurabh_pathak
Active Contributor
0 Kudos

Following will separate potentially visible fields from all others.

private void FindReportObects(ReportDocument reportDocument)
    {
        ReportDefinition reportDefinition = reportDocument.ReportDefinition;
        Areas areas = reportDefinition.Areas;
        foreach (Area area in areas)
        {
           
               Sections sections = area.Sections;
               for (int i = 0; i < sections.Count; i++)
               {

                   Section section = sections<i>;
                   if (!section.SectionFormat.EnableSuppress)
                   {
                       ReportObjects rptObjects = section.ReportObjects;

                       if (rptObjects.Count > 0)
                       {
                           Response.Write("</br>");
                           Response.Write("<table border=1 cellspacing=2>");
                           Response.Write("<tr>");
                           Response.Write("<td><b>Report Object Name</b></td>");
                           Response.Write("<td><b>Report Kind</b></td>");
                           Response.Write("<td><b>Section Name</b></td>");
                           Response.Write("</tr>");

                           foreach (ReportObject reportObject in rptObjects)
                           {
                               Response.Write("<tr>");
                               Response.Write("<td>" + reportObject.Name + " </td>");
                               Response.Write("<td>" + reportObject.Kind.ToString() + " </td>");
                               Response.Write("<td>" + section.Name + " </td>");
                               Response.Write("</tr>");
                           }

                           Response.Write("</table>");

                       }
                   }

               }
           
       }

Hope it helps this time

- Saurabh

ido_millet
Active Contributor
0 Kudos

Hi Saurabh,

Thanks for the detailed code example. However, it would list all field objects regardless of their individual suppress status.

Your approach may be viable if code could be added to test each field for its own suppress condition.

I'm hoping there is a more direct approach. After all, Crystal needs to establish field "visibility" each time it exports a report.

Cheers,

- Ido

saurabh_pathak
Active Contributor
0 Kudos

Most of the code will remain same, but following condition will yield the output you are looking forward to.. i.e. field with individual suppress will not be available to you as an output. You can test this code, if you find any direct approach please update the thread with it.

foreach (ReportObject reportObject in rptObjects)
                           {
                               if (!reportObject.ObjectFormat.EnableSuppress)
                               {
                                   Response.Write("<tr>");
                                   Response.Write("<td>" + reportObject.Name + " </td>");
                                   Response.Write("<td>" + reportObject.Kind.ToString() + " </td>");
                                   Response.Write("<td>" + reportObject.ObjectFormat.ToString() + " </td>");
                                   Response.Write("<td>" + area.Name + " </td>");
                                   Response.Write("<td>" + area.Kind.ToString() + " </td>");
                                   Response.Write("<td>" + section.Name + " </td>");
                                   Response.Write("</tr>");
                               }
                           }

Thanks

Saurabh

ido_millet
Active Contributor
0 Kudos

Hi Saurabh,

Again, thanks for the time and energy you have invested in providing detailed code solutions. The visibility of a field/formula depends not only on it's own suppress property, but also on the suppress property of its section. Furthermore, each of these two properties could be controlled by a dynamic expression (rather than by a static design-time choice).

Hence, I keep going back to a request, perhaps aimed mainly at the SAP hosts of this forum, to see if anyone is aware of a more direct way to establish object visibility or "exportability."

I suspect Don or Ludek already saw the question so, evidently, they are not aware of a direct method.

Hence, I'll award you the points and close this thread... 🐵

Thanks,

- Ido

saurabh_pathak
Active Contributor
0 Kudos

Hi Ido,

My code checks both the conditions if you notice it.

for section I have

Section section = sections<i>;
if (!section.SectionFormat.EnableSuppress)
                   {
--------
-----             }

and for field/formula present in it I have updated the code.

foreach (ReportObject reportObject in rptObjects)
                           {
                               if (!reportObject.ObjectFormat.EnableSuppress)
                               {
-----
----
      }
}

I will check if I can find any direct approach, but I could think of this only.

Thanks

Saurabh

Answers (0)