Category: SSRS Ax 2012

Using UIBuilder in SSRS contract class

Hi, Below sample code used to get lookups.

In this scenario, i need to get itemid lookup based on Invoice id selected.

UIBuilder class

  1. public class testUIBuilder extends SysOperationAutomaticUIBuilder
    {
    testContract contract;
    DialogField dialogInvoiceId;
    DialogField dialogItemId;
    }
  2. public void build()
    {
    Dialog dialogLocal = this.dialog();
    contract = this.dataContractObject();
    this.addDialogField(methodStr(testContract,parmInvoiceId), contract);
    this.addDialogField(methodStr(testContract,parmItemId), contract);
    }
  3. public void getFromDialog()
    {
    contract = this.dataContractObject();
    super();
    }
  4. public void initializeFields()
    {
    contract = this.dataContractObject();
    }
  5. public void lookupItem(FormStringControl _control)
    {
    Query query = new Query();
    QueryBuildDataSource queryBuildDataSource, queryBuildDataSource1;
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(CustInvoiceTrans), _control);
    ;

    sysTableLookup.addLookupfield(fieldnum(CustInvoiceTrans, ItemId),true);

     

    queryBuildDataSource = query.addDataSource(tablenum(CustInvoiceTrans));

    queryBuildDataSource1 = queryBuildDataSource.addDataSource(tablenum(CustInvoiceTrans));

    queryBuildDataSource1.addRange(fieldnum(CustInvoiceTrans, InvoiceId)).value(queryvalue(dialogInvoiceId.value()));

    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();
    }

  6. public void postBuild()
    {
    ;
    super();
    dialogInvoiceId = this.bindInfo().getDialogField(
    this.dataContractObject(),
    methodStr(testContract,parmInvoiceId));

    dialogItemId = this.bindInfo().getDialogField(
    this.dataContractObject(),
    methodStr(testContract,parmItemId));
    // register override method for lookup customer
    dialogItemId.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(testUIBuilder,lookupItem),this);

    }

  7. public void postRun()
    {
    Dialog dialogLocal = this.dialog();
    super();
    // This method should be called in order to handle events on dialogs.
    dialogLocal.dialogForm().formRun().controlMethodOverload(false);
    }

Contract class

  1. [
    DataContractAttribute,
    SysOperationContractProcessingAttribute(classStr(testUIBuilder))]
    public class testContract implements SysOperationValidatable
    {
    InvoiceId invoiceId;
    ItemId itemId;
    }
  2. [
    DataMemberAttribute(‘InvoiceId’),
    SysOperationDisplayOrderAttribute(‘1’)
    ]
    public InvoiceId parmInvoiceId(InvoiceId _invoiceId = invoiceId)
    {
    invoiceId = _invoiceId;
    return invoiceId;
    }
  3. [
    DataMemberAttribute(‘ItemId’),
    SysOperationDisplayOrderAttribute(‘2’)
    ]
    public ItemId parmItemId(ItemId _itemId = itemId)
    {
    itemId = _itemId;
    return itemId;
    }

 

Advertisements

Report printing Extra page

Hi, If report printing extra page please check below logic.

Body Width <= Page Width – (Left Margin + Right Margin)

Horizontal usable area:

X = Page.Width – (Left Margin + Right Margin + Column Spacing)

Vertical usable area:

Y = Page.Height – (Top Margin + Bottom Margin + Header Height + Footer Height)

Any time objects on your report (including the Body itself) extend past the usable area either because they are defined like that or because they grow at runtime, the physical page renderers have no choice but to break onto a new page.

Filtering data in SSRS Query

Hi,

Below is the sample code written to filter the data based on Query used by report and apply on custom query in DP class;

//DP class

queryVendInvoiceJour=this.parmQuery();

//Get filtered/selected value from standard query 
qrOrderAccount = queryVendInvoiceJour.dataSourceName(‘VendInvoiceJour’).rangeField(fieldNum(VendInvoiceJour,OrderAccount));

//Writing custom query based on requirement but applying the selected ranges to custom query

q=new Query();
qbdsVendInvoiceJour = q.addDataSource(tablenum(VendTrans));
qrVendInvoiceJour = qbdsVendInvoiceJour.addRange(fieldNum(VendTrans,AccountNum));
q.dataSourceNo(1).rangeField(fieldNum(VendTrans,AccountNum)).value(qrOrderAccount.value());

qr = new QueryRun(q);

 

This will help to overwrite the Query used in Report using the custom query by applying same ranges selected by user.

HAPPY DAXing 🙂

SSRS : Contract Class & Debug it

Hi,

Below is the sample code to Develop the contract class.

Here I need to pass the “Date” as the parameter, based on the selected data I need to get the data.

1) [DataContractAttribute]

class SrsRDPContractIndemnity

{

StartDate        tillDate;

}

2)  [DataMemberAttribute(“Date”)]

public StartDate asOfDate(StartDate _tilldate = today())

{

tillDate = _tilldate;

return tillDate;

}

Debug the contact class: 

static void SSRS_ContractclsDEBUG(Args _args)

{

ProdRouteTrans  prodRouteTrans;

//ACWAPIPETotalItemProdPerMonthTmp  acwaPIPETotalItemProdPerMonthTmp;

MZK_PayrollIndemnityTmp payrollIndemnityTmp;

IndemnityRDP dataprovider = new IndemnityRDP();

SrsRDPContractIndemnity    contract    = new SrsRDPContractIndemnity();

;

contract.asOfDate(today());

dataProvider.parmDataContract(contract);

dataProvider.processReport();

payrollIndemnityTmp = dataProvider.getDate();

}

SSRS : RDP class & Debug it

HI,

Below is the sample code for developing RDP class for SSRS reports

[SRSReportQueryAttribute (querystr(HcmWorkerListPage_Perment)), //My Query

SRSReportParameterAttribute(classStr(SrsRDPContractIndemnity))] //class name

1) class IndemnityRDP extends SRSReportDataProviderBase

{

MZK_PayrollIndemnityTmp        tmpPayrollIndemnity;

Mzk_PayrollIndemnityonly       payrollIndemnityonlycls;

}

2)

[SRSReportDataSetAttribute(“MZK_PayrollIndemnityTmp”)] //tmp table

Public MZK_PayrollIndemnityTmp getDate()

{

select * from tmpPayrollIndemnity;

return tmpPayrollIndemnity;

}

3)

[SysEntryPointAttribute(false)]

public void processReport()

{

QueryRun                    queryRun;

Query                       query;

    SrsRdpContractIndemnity  dataContract;

QueryBuildRange             qbrHcmWorker;

QueryBuildRange             qbrJourTrans;

StartDate                   tillDate;

QueryBuildDataSource          qbsHcmworker;

HcmWorker                   getHcmworker;

// Get the query from the runtime using a dynamic query.

query = this.parmQuery();

// Get the parameters passed from runtime.

dataContract    = this.parmDataContract();

tillDate = dataContract.asOfDate();

// Add parameters to the query.

qbsHcmworker = query.dataSourceTable(tablenum(HcmWorker));

if(tillDate)

{

qbrHcmWorker = qbsHcmworker.findRange(fieldnum(HcmWorker, NewHcmEmployeeType));

// If an invent JournalId has not been set, then use the parameter value to set it.

if(!qbrHcmWorker.value())

qbrHcmWorker.value(int2str(any2int(MZK_EmployeeType::Permanent)));

}

// Run the query with modified ranges.

queryRun    = new QueryRun(query);

ttsbegin;

while (queryRun.next())

{

getHcmworker = queryRun.get(tableNum(HcmWorker));

this.insertTmpTable(getHcmworker, tillDate);

}

ttsCommit;

}

4)

private void insertTmpTable(HcmWorker _hcmWorker,

StartDate  _tilldate=today())

{

HcmPayrollLine      hcmPayrollLline;

HcmEmployment       hcmEmployment;

utcDateTime         joinDateTime;

date                joinDate;

 

payrollIndemnityonlycls = new Mzk_PayrollIndemnityonly();

tmpPayrollIndemnity.Worker                  =   _hcmWorker.RecId;

tmpPayrollIndemnity.NewHcmEmployeeType      =   _hcmWorker.NewHcmEmployeeType;

tmpPayrollIndemnity.CitizenshipCountryRegion=   _hcmWorker.Nationality();

tmpPayrollIndemnity.Joindate                =   _hcmWorker.Joindate();

tmpPayrollIndemnity.Tilldate                =   _tilldate;

tmpPayrollIndemnity.Name                    =   _hcmWorker.name();

tmpPayrollIndemnity.Service                 =   (_tilldate – tmpPayrollIndemnity.Joindate)/365;

joinDateTime = DateTimeUtil::applyTimeZoneOffset(    hcmEmployment::findByWorker(_hcmWorker.RecId).ValidFrom, DateTimeUtil::getUserPreferredTimeZone());

joindate = any2date(joinDateTime);

tmpPayrollIndemnity.Indemnity   =   payrollIndemnityonlycls.payrollGeneration(_hcmWorker.RecId,joindate,_tilldate);

tmpPayrollIndemnity.insert();

}

Debug code for RDP:

static void SSRS_RDPclsDEBUG(Args _args)

{

//MachineBreakDownSlipTmp ACWATransferhistoryTmp;

MZK_PayrollIndemnityTmp payrollIndemnityTmp;

IndemnityRDP dataprovider = new IndemnityRDP();

//MachineBreakDownSlip_queryDP dataprovider = new MachineBreakDownSlip_queryDP();

dataProvider.processReport();

payrollIndemnityTmp = dataProvider.getDate();

}