My 2p about ERP Solutions, Information Worker Solutions and other software products (mainly Microsoft Dynamics AX and Microsoft SharePoint).

04 May 2010

Turning DataField Property off in a Section Group on a Report

by Patrik Luca 0 comments

Tag



Business Requirement

With the DataField Property of a section group control on a report, you can create sections using the same table. In this post I explain how you can turn this off if the DataField Property has a value in your Report Design.

This post uses an existing Report as example: Report CustGrossMarginByAccount. It can be found in Accounts Receivable > Reports > Statistics > Customer > Gross Margin by Customer.

Solution

Step 1 Add new global variables in the ClassDeclaration

Add new global variables dialogShowSubTotals and showSubTotals in the ClassDeclaration of Report CustGrossMarginByAccount: a new checkbox should become available on the startup dialog of the Report in which the end user can choose to print subtotals or not.

public class ReportRun extends ObjectRun

{

    Amount custGross;

    Amount custMargin;

    Amount custCost;

    Amount totGross;

    Amount totMargin;


    ReportSectionGroup      rsSG;

    ReportSection           rsBody;

    ReportSection           rsDetailHeader;

    ReportSection           rsSummaryHeader;

    CustName custName;


    DialogField         dialogSummary;

    NoYes               summary;

    DialogField         dialogShowSubTotals;

    NoYes               showSubTotals;


    #define.CurrentVersion(2)

    #localmacro.CurrentList

        summary,

        showSubTotals

    #endmacro

}



Step 2 Add a field to the dialog to have the option to print subtotals



Add a field to the dialog by modifying the dialog method: the user will be able to choose here if subtotals should be printed or not.



public Object dialog(Object _dialog)

{

    DialogRunbase dialog = super(_dialog);

    ;


    dialog.addGroup("@SYS7764");    // Parameters


    dialogSummary = dialog.addFieldValue(typeid(NoYes),
summary,
"@SYS62602",
"@SYS99221");


 

dialogShowSubTotals = dialog.addFieldValue(typeid(NoYes),
showSubTotals,
"@SYS26674");


    return dialog;
}




Step 3 Store the value by modifying the getFromDialog method



Modify the getFromDialog method to store the value of the chosen print option.



public NoYes getFromDialog()

{

    ;

    summary = dialogSummary.value();
    showSubTotals = dialogShowSubTotals.value();

    return true;

}



Step 4 Modify the fetch method to turn subtotals on or off



Modify the fetch method to switch the subtotals on or off.



public boolean fetch()

{
Queryrun qr;

    ReportSectionGroup  reportSectionGroup;

    ;

    if (!showSubTotals)

    {

        reportSectionGroup = element.design().sectionGroup( tableNum(CustInvoiceJour)

            ,fieldName2Id(tableNum(CustInvoiceJour)

            ,"OrderAccount"));

        reportSectionGroup.dataField(0);

    } …..

}


Result



Upon starting the Report CustGrossMarginByAccount the end user has the option to print the subtotals per Order Account or not.





Leaving the option unchecked, results in a report without subtotals per Order Account:





Checking the subtotals option results in a report with the subtotals:




Comments 0 comments

Patrik Luca, Ieper, BELGIUM
Feel free to use or spread all of the content on my blog. In return, linking back to my blog would be greatly appreciated. All my posts and articles are provided "AS IS" with no warranties.

Subscribe feeds via e-mail
Subscribe in your preferred RSS reader

Subscribe feeds rss Most Read Entries

Subscribe feeds rss Recent Entries

Categories

Recommended Books


Subscribe feeds rss Recent Comments

This Blog is part of the U Comment I Follow movement in blogosphere. Means the comment field of this blog is made DOFOLLOW. Spam wont be tolerated.

Blog Archive

My Blog List

Followers

Links