Feb 1, 2012

Replacing standard report with our report

Here i want to discuss about that how can we replace SalesInvoice standard report with our MySalesInvoicereport  in which i hav SalesTable and SalesLine as datasources

Then do the following ,


In printjournal() of custInvoiceJour table just change the menuitem  SalesInvoice to MyReportSalesInvoice

salesInvoiceMenu = new MenuFunction(menuitsemoutputstr(MyReportSalesInvoice),MenuItemType::Output);

Go to our MySalesInvoicereport 

In class declaration and declare the variables as

    SalesFormLetter                               salesFormLetter;
    SalesFormLetterReport_Invoice       salesFormLetterReport;
    RecordSortedList                             journalList;
    Salesid                                              salesid;               
     custInvoiceJour                                            custInvoiceJour;

In init() write the code as

super();

if (classidget(element.args().caller()) == classnum(SalesFormLetter_Invoice))
    {
        salesFormLetter = element.args().caller();
    }
else
    {
        if (element.args().record())
            journalList         = FormLetter::createJournalListCopy(element.args().record());
        else
            journalList         = element.args().object();
    }
    if (!journalList)
        throw '';
    journalList.first(custInvoiceJour);
    if (!custInvoiceJour)
        throw error("@SYS26348");
salesid  =  custInvoiceJour.salesId


In fetch() try to run the report on the basis of CustInvoiceJour

public boolean fetch()
{
    boolean ret;
    ;
    ret = true;
    select SalesTable_1 where SalesTable_1.SalesId == _salesId;
    if(SalesTable_1)
    element.send(SalesTable_1);
    while select salesLine_1 where salesLine_1.SalesId == _salesId
    {
    element.send(salesLine_1);
    }
    return ret;
}