cancel
Showing results for 
Search instead for 
Did you mean: 

BeforeFormatPage Event Not Firing

ido_millet
Active Contributor
0 Kudos

Environment: vb.net 2010, CR 2011, winforms

Other than declaring the report document object as WithEvents, is there any other step that's needed for the BeforeFormatPage even to fire?

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Add this code:

   


EventEnabledArgs enableArgs = new EventEnabledArgs();
                enableArgs.FieldMappingEnabled = true;
                enableArgs.FormattingEnabled = true;
                report.EnableEvent(enableArgs);


We found that even though Section event was added to CRVS2010, it is quite weak and needs a lot more work.

Couple of issue we are tracking;

1) The report crDoc.ReportDefinition.Sections[]object takes an array value of 0 to x where x is the total number of sections or it takes the section name. Unfortunately the section name it takes is completely different from anything we can index, there is a big problem with how our .NET SDK names the sections; the same name can be used for different sections in different reports.

2) Field mapping only works on reports created off of command objects and not on reports using database tables.

I suspect as we go through this in more detail we'll find more "issues" and perhaps that is why "they" left it undocumented in the Developer Help files for now...'

- Ludek

ido_millet
Active Contributor
0 Kudos

Thanks!

ido_millet
Active Contributor
0 Kudos

Hi Ludek,

Just to confirm that the extra code indeed enables the formatting events.

Also, the section codes are indeed strange (1000, 2000, 3000, 4000, ...).

Thanks, again for the fast response!

- Ido

former_member183750
Active Contributor
0 Kudos

Yeah like I said. The "thing" needs way more work. I'll keep this thread handy and try to update it as these formatting events evolve. Oh, and credit due to Trevor D. who has done 99% of the work on this.

- Ludek

former_member200290
Contributor
0 Kudos

Hi Ido,

The section codes being returned are not really useful to you the way they are. The come from the base reporting engine itself and is what it uses to index the sections. I have attached a C# class file that can take the numeric sections 1000, 2000 etc and turn them into something readable and understandable such as RH, DA, DB, GH2C.

Unfortunately to work with sections you have to use the .NET section naming convention, GroupoHeaderSection1, GroupHeaderSection2. For some basic sections we can match them up, but for others like GroupHeaders and GroupFooters there is no reliable way, you cannot tell if GroupHeaderSection2 is GH1b or GH2a.

This has been identified as an issue with the section format event and is being tracked, we need to be patient in the mean time.

Kind Regards,

Trevor.

File reattached this should work now.

Edited by: Trevor Dubinsky on Jul 5, 2011 2:02 PM

ido_millet
Active Contributor
0 Kudos

Hi Trevor,

The clarification is much appreciated.

I plan to wait for the fix. I had asked Blair for this functionality several years ago; I can wait a few more months... :monkey_face:

ido_millet
Active Contributor
0 Kudos

Trevor, the download link doesn't seem to work.

former_member200290
Contributor
0 Kudos

Fixed and tested the file from another machine.

Hope this helps.

- Trevor

ido_millet
Active Contributor
0 Kudos

Link to the file still fails.

The webpage at http://forums.sdn.sap.com/servlet/JiveServlet/download/313-1987710-10417682-1915/clsEventUtils.cs might be temporarily down or it may have moved permanently to a new web address.

Error 100 (net::ERR_CONNECTION_CLOSED): The server unexpectedly closed the connection.

former_member200290
Contributor
0 Kudos

Hello Ido,

So I am not sure what I can say, I have tested this from both an internal SAP computer and an external computer and had a friend try at his office too.

I will try to paste a code snippet here to see if it works, but it may not be pretty:


class clsEventUtils
    {
	// Report Document Event Utility Class
	// Written June 20, 2011 by Trevor Dubinsky
	// Call the function SectionCodeToStr function to change
	// The numeric section code to a human readable string.
	// Translated from funtion in the Delphi VCL written by Frank Zimmerman
        public int PE_GROUP_N(int sectioncode)
        {
            return sectioncode % 25;
        }

        public int PE_SECTION_N(int sectioncode)
        {
            return (sectioncode / 25) % 40;
        }

        public string SectionCodeToStr(int Value)
        {
            string[] SubArray = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai", "aj", "ak", "al", "am", "an" };
            int nType,
                nGroup = 0,
                nSection = 0;
            string sTmp,
                   res;

            sTmp = "";
            
            //{Get Area}
            if (Value < 2000)
            {
                sTmp = "RH"; //{RH}
            }
            else if (Value >= 2000 && Value < 3000)
            {
                sTmp = "PH"; //{PH}
            }
            else if (Value >= 3000 && Value < 4000)
            {
                nGroup = PE_GROUP_N(Value);
                sTmp = "GH"; //{PH}
                sTmp += ++nGroup;
            }
            else if (Value >= 4000 && Value < 5000)
            {
                sTmp = "D"; //{PH}
            }
            else if (Value >= 5000 && Value < 7000)
            {
                nGroup = PE_GROUP_N(Value);
                sTmp = "GF"; //{PH}
                sTmp += ++nGroup;
            }
            else if (Value >= 7000 && Value < 8000)
            {
                sTmp = "PF"; //{PH}
            }
            else if (Value > 8000)
            {
                sTmp = "RF"; //{PH}
            };

            nSection = PE_SECTION_N(Value);
            if ((sTmp == "") || (nSection > 39) || (nSection < 0))
            {
                res = "";
            }
            else
            {
                res = sTmp + SubArray[nSection];
            }
            return res;
        }
    }

Trevor

ido_millet
Active Contributor
0 Kudos

Thanks!

former_member200290
Contributor
0 Kudos

Your welcome I hope it helps Ido!

Answers (0)