How to Create Temp Form Report in Dynamics 365

Dynamics 365'te Geçici Form Raporları Nasıl Oluşturulur?

Dynamics 365 Finance and Operations'da SSRS raporlarına alternatif olarak geçici form raporları oluşturmak mümkündür. Bu yöntem, belirli iş ihtiyaçlarına göre daha hızlı ve esnek raporlar hazırlamanıza olanak tanır.

1. Geçici Tablo (Temp Table) Oluşturma

İlk adım olarak, TempDB özelliği etkinleştirilmiş geçici bir tablo oluşturun. Bu tablo, rapor verilerinizi geçici olarak depolayacaktır. Tabloya gerekli alanları ekleyin ve veri türlerini iş gereksinimlerinize göre belirleyin.

2. Veri İşleme Sınıfı (Data Provider Class) Oluşturma

Veri işleme sınıfı, geçici tabloya veri doldurmak için kullanılır. Bu sınıfı oluşturarak, iş mantığınızı burada tanımlayın. Bu sayede, gerekli hesaplamaları yaparak verileri geçici tabloya ekleyebilirsiniz.

class ETGProdCostTrialBalanceControlDP
{
    public ETGProdCostTrialBalanceControlTmp tmp;
    public TransDate transDate;

    public void run()
    {
        Ledger ledger;
        MainAccount mainAccount;
        GeneralJournalEntry generalJournalEntry, generalJournalEntryPrev;
        GeneralJournalAccountEntry generalJournalAccountEntry, generalJournalAccountEntryPrev;
        DataAreaId company = curExt();

        FromDate fromDate = mkDate(1, mthOfYr(transDate), year(transDate));
        ToDate toDate = endMth(fromDate);

        FromDate prevFromDate = prevMth(fromDate);
        ToDate prevToDate = endMth(prevFromDate);

        if(this.validate())
        {

            while select mainAccount
             where mainAccount.Type == DimensionLedgerAccountType::ProfitAndLoss
                && mainAccount.MainAccountId like "720*"
                || mainAccount.MainAccountId like "730*"
             exists join ledger
             where ledger.ChartOfAccounts == mainAccount.LedgerChartOfAccounts
                && ledger.Name == company
            {

                select sum(AccountingCurrencyAmount), sum(ReportingCurrencyAmount) from generalJournalAccountEntry
                 where generalJournalAccountEntry.MainAccount == mainAccount.RecId
                exists join generalJournalEntry
                 where generalJournalEntry.RecId == generalJournalAccountEntry.GeneralJournalEntry
                    && generalJournalEntry.AccountingDate >= fromDate
                    && generalJournalEntry.AccountingDate <= toDate
                    && generalJournalEntry.PostingLayer == CurrentOperationsTax::Current
                    && generalJournalEntry.SubledgerVoucherDataAreaId == company;


                select sum(AccountingCurrencyAmount), sum(ReportingCurrencyAmount) from generalJournalAccountEntryPrev
                 where generalJournalAccountEntryPrev.MainAccount == mainAccount.RecId
                exists join generalJournalEntryPrev
                 where generalJournalEntryPrev.RecId == generalJournalAccountEntryPrev.GeneralJournalEntry
                    && generalJournalEntryPrev.AccountingDate >= prevFromDate
                    && generalJournalEntryPrev.AccountingDate <= prevToDate
                    && generalJournalEntryPrev.PostingLayer == CurrentOperationsTax::Current
                    && generalJournalEntryPrev.SubledgerVoucherDataAreaId == company;

                tmp.clear();
                tmp.MainAccountId = mainAccount.MainAccountId;
                tmp.Name = mainAccount.Name;
                tmp.Department = "";
                tmp.BalanceMST = generalJournalAccountEntry.AccountingCurrencyAmount;
                tmp.BalanceSecCur = generalJournalAccountEntry.ReportingCurrencyAmount;
                tmp.PrevBalanceMST = generalJournalAccountEntryPrev.AccountingCurrencyAmount;
                tmp.BalanceSecCur = generalJournalAccountEntryPrev.ReportingCurrencyAmount;
                tmp.insert();

            }
        }
    }

    private boolean validate()
    {
        boolean ret = true;

        if(ret && transDate == dateNull())
        {
            ret = checkFailed("Tarih seçiniz.");
        }

        return ret;
    }

}

3. Form Oluşturma

Yeni bir form oluşturun ve form tasarımında aşağıdaki adımları izleyin:

  • Veri Kaynağı (Data Source) Ekleme: Oluşturduğunuz geçici tabloyu formun veri kaynağı olarak ekleyin.

  • Tasarım Deseni (Design Pattern) Uygulama: Formun tasarımında "Simple List" desenini kullanın. Bu, formun standartlara uygun ve kullanıcı dostu olmasını sağlar.

  • Grid Kontrolü Ekleme: Form tasarımına bir grid kontrolü ekleyerek, geçici tablodaki verilerin listelenmesini sağlayın.

  • Form Design Properties

    Form Design Properties

  • Form DataSource Properties

    Form DataSource Properties

4. Kod Yazma

Formun init() ve run() metotlarında, veri işleme sınıfını çağırarak geçici tabloyu doldurun ve formu güncelleyin. Bu sayede, form açıldığında veriler otomatik olarak yüklenecektir. Forma yazılması gereken kodları aşağıda paylaşıyorum.

[Form]
public class ETGProdCostTrialBalanceControl extends FormRun
{
    ETGProdCostTrialBalanceControlTmp tmp;

    [DataSource]
    class ETGProdCostTrialBalanceControlTmp
    {
        /// <summary>
        ///
        /// </summary>
        public void init()
        {
            super();

            ETGProdCostTrialBalanceControlTmp.linkPhysicalTableInstance(tmp);
        }

    }

    [Control("Button")]
    class btnRun
    {
        /// <summary>
        ///
        /// </summary>
        public void clicked()
        {
            super();

            ETGProdCostTrialBalanceControlDP controlDP = new ETGProdCostTrialBalanceControlDP();
            controlDP.transDate = TransDate.dateValue();
            controlDP.run();

            tmp = controlDP.tmp;
            ETGProdCostTrialBalanceControlTmp.linkPhysicalTableInstance(tmp);
            ETGProdCostTrialBalanceControlTmp_ds.executeQuery();
        }

    }

}

Sonuç

Bu adımları izleyerek, Dynamics 365 Finance and Operations'da geçici form raporları oluşturabilirsiniz. Bu yöntem, SSRS raporlarına alternatif olarak kullanılabilir ve belirli senaryolarda daha hızlı sonuçlar elde etmenize yardımcı olabilir.