Thursday, June 14, 2018

SSRS Reports using DP, Contract, UI Builder

Contract Class :

/// <summary>
/// Data Contract class for CustomerTransactions SSRS report
/// </summary>
/// <remarks>
/// This is the Data Contract class for the CustomerTransactions SSRS Report.
/// </remarks>
[
    DataContractAttribute,
    SysOperationContractProcessingAttribute(classStr(DIPL_CustTransUIBuilder))
]

public class DIPL_CustTransContract implements SysOperationValidatable
{
    TransDate   fromDate;
    TransDate   toDate;
    List        custAccount;
}

--------------------------------------------------------------------------------------------------------------------

/// <summary>
/// Gets or sets the value of the datacontract parameter CustAccount.
/// </summary>
/// <param name="_custAccount">
/// The new value of the datacontract parameter CustAccount.
/// </param>
/// <returns>
///  The current value of datacontract parameter CustAccount
/// </returns>
[
    DataMemberAttribute('CustAccount'),
    AifCollectionTypeAttribute('CustAccount', Types::String),
    SysOperationLabelAttribute(literalStr("CustAccount")),
    SysOperationDisplayOrderAttribute('3')
]
public List parmCustAccount(List _custAccount = custAccount)
{
    custAccount = _custAccount;

    return custAccount;
}

--------------------------------------------------------------------------------------------------------------------------

/// <summary>
/// Gets or sets the value of the datacontract parameter FromDate.
/// </summary>
/// <param name="_fromDate">
/// The new value of the datacontract parameter FromDate; optional.
/// </param>
/// <returns>
///  The current value of datacontract parameter FromDate
/// </returns>
[
    DataMemberAttribute('FromDate'),
    SysOperationLabelAttribute(literalstr("@SYS4083")),
    SysOperationHelpTextAttribute(literalstr("FromDate")),
    SysOperationGroupMemberAttribute('Date'),
    SysOperationDisplayOrderAttribute('1')
]
public TransDate parmFromDate(TransDate _fromDate = fromDate)
{
    fromDate = _fromDate;

    return fromDate;
}

------------------------------------------------------------------------------------------------------------------------

/// <summary>
/// Gets or sets the value of the datacontract parameter ToDate.
/// </summary>
/// <param name="_toDate">
/// The new value of the datacontract parameter ToDate; optional.
/// </param>
/// <returns>
///  The current value of datacontract parameter ToDate
/// </returns>
[
    DataMemberAttribute('ToDate'),
    SysOperationLabelAttribute(literalstr("@SYS8828")),
    SysOperationHelpTextAttribute(literalstr("ToDate")),
    SysOperationGroupMemberAttribute('Date'),
    SysOperationDisplayOrderAttribute('2')
]
public TransDate parmToDate(TransDate _toDate = toDate)
{
    toDate = _toDate;

    return toDate;
}

-------------------------------------------------------------------------------------------------------------------------

/// <summary>
///    Validates the SSRS report parameters.
/// </summary>
/// <returns>
///    true if successful; otherwise, false.
/// </returns>
public boolean validate()
{
    boolean ret = true;
    if (!fromDate)
    {
        fromDate = systemdateget();
    }

    if (!toDate)
    {
        toDate = systemdateget();
    }

    if (toDate < fromDate)
    {
        ret = checkFailed("@SYS16982");
    }

    return ret;
}

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

UI Builder : Using it for Multiselect lookup

class DIPL_CustTransUIBuilder extends SysOperationAutomaticUIBuilder
{
    DIPL_CustTransContract              contract;
    DialogField                         dlgCustAccount;
    DialogField                         dialogFromdate;
    DialogField                         dialogTodate;
    SysLookupMultiSelectGrid            sysMultiGridCustAccount;
    SysLookupMultiSelectCtrl            sysMultiLookupCustAccount;
    container                           custAccountCon;

}
--------------------------------------------------------------------------------------------------------------------------

public void build()
{
    contract    = this.dataContractObject() as DIPL_CustTransContract;

    dialogFromdate  = this.addDialogField(methodStr(DIPL_CustTransContract, parmFromDate), contract);
    dialogTodate    = this.addDialogField(methodStr(DIPL_CustTransContract, parmToDate), contract);

}

--------------------------------------------------------------------------------------------------------------------------
private void CustAccountLookup(FormStringControl custAccountLookup)
{

    sysMultiGridCustAccount = SysLookupMultiSelectGrid::construct(custAccountLookup, custAccountLookup);
    sysMultiGridCustAccount.parmQuery(this.CustAccountQuery());
    sysMultiGridCustAccount.run();

    sysMultiGridCustAccount.setSelected();

}
--------------------------------------------------------------------------------------------------------------------------

private Query CustAccountQuery()

{

    Query                           query;
    QueryBuildDataSource            queryBuildDataSource;

    query = new Query();

    queryBuildDataSource = query.addDataSource(tableNum(CustTable));
    query.dataSourceTable(tablenum(CustTable)).addDataSource(tableNum(DirPartyTable));
    query.dataSourceTable(tablenum(DirPartyTable)).joinMode(JoinMode::InnerJoin);
    query.dataSourceTable(tablenum(DirPartyTable)).relations(true);
    query.dataSourceTable(tablenum(DirPartyTable)).addSelectionField(fieldNum(DirPartyTable,  Name));
    queryBuildDataSource.addSelectionField(fieldNum(CustTable,AccountNum));

    return query;

}

-------------------------------------------------------------------------------------------------------------------------
public  void getFromDialog()
{
    super();

    custAccountCon = sysMultiLookupCustAccount.getSelectedFieldValues();

    if (custAccountCon)
    {
        contract.parmCustAccount(con2List(custAccountCon));
    }

}
--------------------------------------------------------------------------------------------------------------------------
public void postBuild()
{

    super();

    contract = this.dataContractObject() as DIPL_CustTransContract;

}
--------------------------------------------------------------------------------------------------------------------------

public void postRun()
{

    dialog.dialogForm().formRun().controlMethodOverload(false);

    dlgCustAccount = this.addDialogField(methodStr(DIPL_CustTransContract, parmCustAccount), contract);
    dlgCustAccount.lookupButton(3);

    dlgCustAccount              = this.bindInfo().getDialogField(contract,methodStr(DIPL_CustTransContract, parmCustAccount));
    sysMultiLookupCustAccount   = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().formRun(), dlgCustAccount.control(), this.CustAccountQuery());

}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

DP:

/// <summary>
///    The <c>DIPL_CustTransDP</c> class is the Report Data Provider class for the <c>CustTransaction</c> SSRS
///    report.
/// </summary>
[
    SRSReportParameterAttribute(classstr(DIPL_CustTransContract))
]
class DIPL_CustTransDP  extends   SRSReportDataProviderBase //SrsReportDataProviderPreProcess
{
    DIPLCustTransTmp                    diplCustTransTmp;
    CustTable                           custTable;
    DirPartyTable                       dirPartyTable;
    CustTrans                           custTrans;
    ProjTable                           projTable;
    ProjInvoiceJour                     projInvoiceJour;
    TaxTrans                            taxTrans;
    FromDate                            fromDate;
    ToDate                              toDate;

    DimensionAttributeLevelValueView    dimensionAttributeLevelValueView;
    DimensionAttributeValueSetItemView  dimensionAttributeValueSetItemView;
    DimensionAttribute                  dimensionAttribute;
    LedgerJournalTrans                  ledgerJournalTrans;

    #define.FromDate('FromDate')
    #define.ToDate('ToDate')

}
--------------------------------------------------------------------------------------------------------------------------
/// <summary>
/// Fetches the data from <c>DIPLCustTransTmp</c> temporary table.
/// </summary>
/// <returns>
/// The data from the <c>DIPLCustTransTmp</c> temporary table.
/// </returns>
[
    SRSReportDataSetAttribute('DIPLCustTransTmp')
]
public DIPLCustTransTmp getDIPLCustTransTmp()
{
    select diplCustTransTmp;
    return diplCustTransTmp;
}
--------------------------------------------------------------------------------------------------------------------------
public ExchRate getExchRateFind(CurrencyCode _currencyCode, TransDate _transDate)
{

    ExchangeRateHelper          exchangeRateHelper;
    CurrencyExchangeRate        exchangeRate1;
    CurrencyExchangeRate        exchangeRate;
    ;

    exchangeRateHelper  = ExchangeRateHelper::newExchangeDate(Ledger::current(), _currencyCode, _transDate);
    exchangeRate1       = exchangeRateHelper.getExchangeRate1();
    exchangeRate        = exchangeRateHelper.displayStoredExchangeRate(exchangeRate1);

    return exchangeRate;
}
--------------------------------------------------------------------------------------------------------------------------
/// <summary>
/// Inserts data into the temporary table.
/// </summary>
private void insertIntoTempTable()
{
    diplCustTransTmp.TransactionDate    = custTrans.TransDate;
    diplCustTransTmp.InvoiceDate           = projInvoiceJour.InvoiceDate;
    diplCustTransTmp.CustomerName     = custTable::find(custTrans.AccountNum).name();
    diplCustTransTmp.ProjectName         = ProjTable::find(dimensionAttributeValueSetItemView.DisplayValue).Name;
    diplCustTransTmp.Invoice                  = custTrans.Invoice;
    diplCustTransTmp.CurrencyCode       = custTrans.CurrencyCode;
    diplCustTransTmp.ExchangeRate       = this.getExchRateFind(custTrans.CurrencyCode,custTrans.TransDate);
    diplCustTransTmp.GrossAmount       = taxTrans.SourceBaseAmountCur;
    diplCustTransTmp.TaxAmount          = taxTrans.SourceTaxAmountCur;
    diplCustTransTmp.TaxCode               = taxTrans.TaxCode;
    diplCustTransTmp.AmountInCur       = custTrans.AmountCur;
    diplCustTransTmp.AmountInINR      = CustTrans.AmountMST;
    diplCustTransTmp.Description           = ledgerJournalTrans.Text;
    diplCustTransTmp.Voucher                = CustTrans.Voucher;
    diplCustTransTmp.TaxValue              = taxTrans.TaxValue; 

    diplCustTransTmp.insert();
}
--------------------------------------------------------------------------------------------------------------------------

/// <summary>
/// Processes the report business logic.
/// </summary>
[AifDocumentCreateAttribute, SysEntryPointAttribute(true)]
public void processReport()
{
    ListEnumerator                      custAccountListIterator;
    CustAccount                         custAccount;
    List                                parmCustAccount;
    List       list                 = new List(Types::String);
    DIPL_CustTransContract contract = this.parmDataContract() as DIPL_CustTransContract;
    fromDate                        = contract.parmFromDate();
    toDate                          = contract.parmToDate();
    parmCustAccount                 = contract.parmCustAccount();

    if (parmCustAccount != null)
    {
        custAccountListIterator = parmCustAccount.getEnumerator();

        while (custAccountListIterator.moveNext())
        {
            custAccount = custAccountListIterator.current();

            while select custTrans
                where custTrans.AccountNum              == custAccount
                    && custTrans.TransDate              >= fromDate
                    && custTrans.TransDate              <= toDate
            outer join projInvoiceJour
                    where ProjInvoiceJour.LedgerVoucher == CustTrans.Voucher
            outer join taxTrans
                    where TaxTrans.Voucher              == ProjInvoiceJour.LedgerVoucher
            {
                select firstOnly RecId,Name from dimensionAttribute
                    where DimensionAttribute.Name == "@SYS105167";

                select DimensionAttributeValueSet,DisplayValue,DimensionAttribute from dimensionAttributeValueSetItemView
                    where dimensionAttributeValueSetItemView.DimensionAttributeValueSet == custTrans.DefaultDimension
                        && dimensionAttributeValueSetItemView.DimensionAttribute        == dimensionAttribute.RecId;

                select firstOnly Text from ledgerJournalTrans
                    where ledgerJournalTrans.Voucher == custTrans.Voucher;

                this.insertIntoTempTable();
            }
        }
    }
}

3 comments:

  1. https://www.youtube.com/playlist?list=PLWSxgDbjVWTjxvgnaAZ0iK8o5dYHAYhrq

    Collection of Microsoft ERP Clips || ERP Licensing, Technical, Functional ,Manager Learning Videos Listing

    ReplyDelete
  2. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing. contract management

    ReplyDelete
  3. All the contents you mentioned in post is too good and can be very useful. I will keep it in mind, thanks for sharing the information keep updating, looking forward for more posts.Thanks kündigen

    ReplyDelete

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...