Wednesday, December 22, 2010

Run SalesConfirmation report through code

Here is an example to print the sales confirmation report through code:

static void printSalesConfirmationReport(Args _args)
{
    Args args;
    ReportRun reportRun;
    SalesFormLetter salesFormLetter;
    PrintJobSettings printJobSettings;
    CustConfirmJour custConfirmJour;
    RecordSortedList list = new RecordSortedList(55);
    SalesTable salesTableUpdate;
    ;

    SELECT firstonly custConfirmJour order by ConfirmID desc
    where custConfirmJour.SalesId ==   salesTable.SalesId ;
    list.ins(custConfirmJour);
    args = new Args(ReportStr(SalesConfirm));
    printJobSettings = new PrintJobSettings();
    printJobSettings.SetTarget(PrintMedium::Screen);
    printJobSettings.suppressScalingMessage(true);

    salesFormLetter = new SalesFormLetter_Confirm(true);
    salesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());
    args.designName("Standard");
    args.caller(salesFormletter);
    args.parmEnum(PrintCopyOriginal::Original);
    args.parmEnumType(enumnum(PrintCopyOriginal));
    args.object(list);
    reportRun = new ReportRun(args);
    reportRun.setTarget(PrintMedium::Screen);
    reportRun.init();
    reportRun.run();
}

No comments: