SAP Knowledge Base Article - Public

1208044 - How to prevent orphaned group headers from appearing on a report in Crystal Reports?

Symptom

  • Headers prints on one page, and the details on the next page.
  • When printing or previewing a report in Crystal Reports, some Group Header displays at the bottom of the page and the group's records are displayed on the following page instead of on the same page as the Group Header. How to avoid this situation?
  • How do you prevent an orphaned Group Header in Crystal Reports?

Environment

  • SAP Crystal Reports 2008
  • SAP Crystal Reports 2011
  • SAP Crystal Reports 2013
  • SAP Crystal Reports 2016

Reproducing the Issue

  1. In Crystal Reports, create a report off any data source.
  2. Add at least one field in the Details section of the report.
  3. Insert a group.
  4. Add in the Group Header section heading information.
  5. When viewing the report, it sometimes prints the header alone on one page, and displays it's details on the next page.

Resolution

  • There are two ways to prevent an orphaned group header in Crystal Reports:
    • Check the group option: "Keep Group Together"; or
    • Add the header in the details section, and only print it the first time the group prints.
          
        
  • Check the group option: "Keep Group Together" 
     
    When the option "Keep Group Together" is uncheck for a group, it prints each sections as space allowed on a page, and there is always the potential the Header prints on one page, and the related information starts printing on the next page.     
         
    When checking the options "Keep Group Together", it will keep the whole group together, therefore if there is not enough room on the page to print the group, it will start printing it on the next page, but note that there is always the potential to leave some white gap on the page, which is normal.
        
    1. Open the report in Crystal Reports designer

    2. Under the menu "Report", select "Group Expert..."

    3. In the "Group Expert" window, select the "Group", and click the button "Options..."

    4. In the "Change Group Options" window, under the tab "Options", uncheck the option "Keep Group Together"

    5. Click "OK"

    6. Perform the same steps if you have more than one group, then click "OK" to accept the change.

  • Add the header in the details section, and only print it the first time the group prints.
      
    The second suggestion is to combine the Group Header, with the Details section together, and only print what was in the Group Header the first time it prints group. In this way, the header will always print at the same time as the first details.
        
    1. Suppress the Group Header, where the header are currently inserted.

    2. Insert a new section in the Details section.
      2.1 Under the menu "Report", select "Section Expert".
      2.2 In the "Section Expert" window, select the "Details" section and click "Add"
        
            It will create a "Details a" and "Details b" section.

    3. Set the new section to be be the first subsection of the Details.

    4. Insert the Group Header information in the Details - a section

    5. Create a formula that will use a variable to indicate when a new group starts printing, like:
           
           WhilePrintingRecords;
           BooleanVar PrintGroup := True

    6. Insert the formula in the suppressed Group Header section.

    7. Create a conditional suppression on the Details a section, to only print it once per group. The formula will be like:
        
          WhilePrintingRecords;
          BooleanVar PrintGroup;

          If PrintGroup = True Then
          (
            PrintGroup := False;  
            False
           )
           Else
             True

    8. Finally, in the "Section Expert", select the Details section, and ensure the following option is checked. "Keep Together"
      ( Do not select the Details - a, but select the root level, which is called: Details )
           
      Now, the header for the group will print at the same time as the first details, since they are part of the same section.

Keywords

CR, GROUP KEEP TOGETHER, WIDOW, ORPHAN Group , KBA , BI-RA-CR , Crystal Reports designer or BusinessViews Manager , How To

Product

Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports 2013 ; SAP Crystal Reports 2016