通过 X++ 在 Microsoft Dynamics AX 2009 中打印报表

发布于 2024-09-26 01:45:40 字数 1422 浏览 1 评论 0原文

我正在尝试通过单击按钮打印销售确认报告,该按钮已添加到 Microsoft Dynamics AX 2009 中的销售订单详细信息表单中。在该按钮的单击事件中,我编写了以下代码:

void clicked()
{
    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::Printer);
    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::Printer);
    reportRun.init();
    reportRun.run();
}

代码运行良好,但问题除外直接在打印机上发送报告,打印预览即将到来。

如果你们中的任何人能让我知道这段代码有什么问题,我将非常感激。

Rgds

哈龙

I am trying to print sales confirmation report on a button click which I have added on Sales Order Detail form in Microsoft Dynamics AX 2009. On click event of that button, I have written following code:

void clicked()
{
    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::Printer);
    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::Printer);
    reportRun.init();
    reportRun.run();
}

The code is running fine except on problem that instead of sending the report directly on printer, print preview is coming.

I will be very greateful if anyone of you could let me know what is wrong with this code.

Rgds

Haroon

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

温柔女人霸气范 2024-10-03 01:45:40

由于您没有发送对任何打印机的引用,因此它必须使用默认打印机,这很可能是 Microsoft XPS 或某些具有显示功能的打印机。

我必须将打印机设置发送到报告(销售发票)并添加一些代码来嗅出任何发送的打印机设置。否则,报告将使用适用于该类型报告的任何打印机设置。让它工作使我能够传递各种打印机设置,如电子邮件、PDF 等......:-)

Since you're not sending in an reference to any printer, it would have to use the default printer, which might very well be Microsoft XPS or some display capable printer.

I had to send in the printersetting to the report (SalesInvoice) and add some code to sniff out any sent printersetting. Otherwise, the report will use whatever printersetting that applies to that type of report. Getting that to work enabled me to pass in various printersettings, like Email, PDF, etc, etc... :-)

梦里的微风 2024-10-03 01:45:40

如果您不知道用户设置为默认打印机的设备,那么它将始终打印到默认打印机。如果您的默认设置是打印到屏幕(即使您选择了 Print Medium::Printer),它仍然会转到屏幕。我认为您应该选择 PrintMedium::Screen 并让它始终转到屏幕,以便用户可以选择打印机,否则他们可能不知道报告打印在哪里(我有一些用户有奇怪的选择作为默认打印机,可能位于建筑物对面)。

If you do not know the device that the user has set up as the default printer then it will always print to the default printer. If your default settings are to print to screen (even though you selected Print Medium::Printer) it will still go to screen. I would think that you should select PrintMedium::Screen and have it always go to screen so that the user can select a printer, otherwise they may not know where the report printed (I have some users that have odd choices as their default printer, which may be across the building).

一指流沙 2024-10-03 01:45:40

试试这个:

public void run()
{
     Args               args;
     ReportRun          report;
     str                printer;
     PrintJobSettings   pjs;
;
    args = new Args(reportstr("PwC_ExciseInvoice_Sales"));
    counter = 1;
    pjs = new printJobSettings();


    while(counter <= maxReports)
    {
        args.parm(int2str(counter));
        args.record(custInvoiceJour);
        report = new ReportRun(args);
        pjs.setTarget(PrintMedium::Printer);
        report.setTarget(PrintMedium::Printer);
        report.init();
        report.run();

        counter++;
    }

}

通过这段代码,我调用一个报告三次(变量 maxReports),每次它都直接发送到打印机。

try this:

public void run()
{
     Args               args;
     ReportRun          report;
     str                printer;
     PrintJobSettings   pjs;
;
    args = new Args(reportstr("PwC_ExciseInvoice_Sales"));
    counter = 1;
    pjs = new printJobSettings();


    while(counter <= maxReports)
    {
        args.parm(int2str(counter));
        args.record(custInvoiceJour);
        report = new ReportRun(args);
        pjs.setTarget(PrintMedium::Printer);
        report.setTarget(PrintMedium::Printer);
        report.init();
        report.run();

        counter++;
    }

}

Through this code, I am calling a report Thrice (variable maxReports), everytime it is going directly to the printer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文