web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Trial Balance Sheet in X++

(0) ShareShare
ReportReport
Posted on by

Hi Experts,

I am working on a report to calculate closing with specific main accounts and Cost Center dimensions.I have seen LedgerTrialBalanceDP class, it is calculating fiscal year and financial dimension set wise, but i want any date range with dimension parameter value like cost center 009.

public void processReport()
{
    LedgerTrialBalanceTmp cfzLedgerTrialBalanceTmp;
    LedgerTrialBalanceDP trialBalanceDP = new LedgerTrialBalanceDP();
    
    List selected = new List(Types::Enum);
    selected.addEnd(CurrentOperationsTax::Current);
    
    LedgerTrialBalanceTmp::calculateBalances(
                LedgerTrialBalanceTmp,
                "MA CC",
                mkDate(1,1,2015),
                mkDate(5,1,2015),
                false,
                false,
                false,
                selected,
                true,
                true,
                Ledger::current());

    cfzLedgerTrialBalanceTmp = trialBalanceDP.getLedgerTrialBalanceTmp();
}

written below code for testing purpose in my custom dp class, but it returns no records to table buffer at the end. Some one please guide me how to achieve this.

I have the same question (0)
  • Verified answer
    Rahul Mohta Profile Picture
    21,032 on at

    what is the requirement here?

    have you considered using financial reports when reporting out of COA, FD and dates

  • Community Member Profile Picture
    on at

    Hi Rahul,

    Below is default inquiry. Data with empty cost center also displays.

    pastedimage1589363887731v1.png     pastedimage1589364363341v7.png

    But i want report with date range out of fiscal period and selected cost center like below.

    pastedimage1589364090862v2.png

  • Verified answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hello Faran Beyg,

    Rather than trying to modify this standard form and functionality, I would recommend using a financial report for that purpose.

    In the financial report designer you can easily create a trial balance report that also includes $0 lines.

    This standard financial report functionality works out of the box and does not require a costly code modification.

    Best regards,

    Ludwig

  • Community Member Profile Picture
    on at

    Hi Ludwig,

    My functional team tried to achieve this through MR but faced filter issue. Any how i got it using default Dp class access in my custom  Dp class. I am attaching code for reference. Report is working fine now.

    [
    SRSReportParameterAttribute(classstr(CFZLandedCostSheetContract))
    ]
    class CFZLandedCostSheetDP extends SrsReportDataProviderPreProcessTempDB
    {
    
        LedgerTrialBalanceTmp trialBalanceTmp;
        CFZLandedCostTmp      cfzLandedCostTmp;
        CFZLCDimensionFilter  cfzLCDimensionFilter;
        CFZMainAccountFilter  cfzMainAccountFilter;
    
    
        CFZLandedCostSheetContract  contract;
        TransDate                   fFromdate, tTodate;
        List                        dimensionLClist,mainAccountlist;
        ListEnumerator              dimensionLCEnum,mainAccountEnum;
    
       
    
        [SRSReportDataSetAttribute(tablestr('CFZLandedCostTmp'))]
        public CFZLandedCostTmp getCFZLandedCostTmp()
        {
            //select data from table buffer
            select * from cfzLandedCostTmp;
    
            //return the buffer
            return cfzLandedCostTmp;
        }
    
        public void processReport()
        {
    
            LedgerTrialBalanceDP trialBalanceDP = new LedgerTrialBalanceDP();
            LedgerTrialBalanceContract trialBalanceContract = new LedgerTrialBalanceContract();
            contract = this.parmDataContract() as CFZLandedCostSheetContract;
            
    
            fFromdate       = contract.parmFromDate();
            tTodate         = contract.parmToDate();
            mainAccountlist = contract.parmMainAccount();
            dimensionLClist = contract.parmDimensionLC();
            
            List selected = new List(Types::Enum);
            selected.addEnd(CurrentOperationsTax::Current);
    
          
            DimensionHierarchy dimHier;
            UserConnection userConn;
            ;
          
            dimHier = DimensionHierarchy::getMainAccountFocus();
       
            userConn = new UserConnection();
            trialBalanceTmp.setConnection(userConn);
           
          
            trialBalanceContract.parmFromDate(fFromdate);
            trialBalanceContract.parmToDate(tTodate);
            trialBalanceContract.parmIncludeOpening(False);
            trialBalanceContract.parmIncludeClosing(False);
            trialBalanceContract.parmPostingLayers(selected);
            trialBalanceContract.parmPrimaryDimensionFocus("MA CC");
            trialBalanceDP.parmDataContract(trialBalanceContract);
           
            trialBalanceDP.processReport();
    
          
            trialBalanceTmp = trialBalanceDP.getLedgerTrialBalanceTmp();
    
    
    
           
            //MainAccount filter
            if (mainAccountlist && !mainAccountlist.empty())
            {
                mainAccountEnum = mainAccountlist.getEnumerator();
                while (mainAccountEnum.moveNext())
                {
                    cfzMainAccountFilter.clear();
                    cfzMainAccountFilter.MainAccountId  = mainAccountEnum.current();
                    cfzMainAccountFilter.insert();
                }
            }
    
            //Dimension filter
            if (dimensionLClist && !dimensionLClist.empty())
            {
                dimensionLCEnum = dimensionLClist.getEnumerator();
                while (dimensionLCEnum.moveNext())
                {
                    cfzLCDimensionFilter.clear();
                    cfzLCDimensionFilter.DimensionValues[2]    = dimensionLCEnum.current();
                    cfzLCDimensionFilter.insert();
                }
            }
    
         
           
    
       
            while select  trialBalanceTmp 
                join cfzLCDimensionFilter
                where trialBalanceTmp.DimensionValues[2] == cfzLCDimensionFilter.DimensionValues[2]
                join cfzMainAccountFilter
                where trialBalanceTmp.DimensionValues[1] == cfzMainAccountFilter.MainAccountId
            {
    
                cfzLandedCostTmp.DisplayValue = DimensionAttributeValueCombination::find(trialBalanceTmp.LedgerDimension).DisplayValue;
                cfzLandedCostTmp.OpeningBalance = trialBalanceTmp.OpeningBalance;
                cfzLandedCostTmp.EndingBalance = trialBalanceTmp.EndingBalance;
                cfzLandedCostTmp.PrimaryFocus = trialBalanceTmp.PrimaryFocus;
                cfzLandedCostTmp.PrimaryFocusDescription = trialBalanceTmp.PrimaryFocusDescription;
                cfzLandedCostTmp.DimensionValues[2] = trialBalanceTmp.DimensionValues[2];
                cfzLandedCostTmp.DimensionValues[1] =  trialBalanceTmp.DimensionValues[1];
                cfzLandedCostTmp.insert();
            }
    
          
           
        }
    
    }

    pastedimage1589441894096v1.png

    pastedimage1589441929623v2.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans