Rechnung per Code drucken

Der nachstehende Job demonstriert, wie man in Dynamics AX 2012 eine vorhandene Rechnung/Ausgangsrechnung per Code (nach-)drucken kann. Im Beispiel erfolgt die Ausgabe am Bildschirm.

static void printSalesInvoiceThroughCode(Args _args)
{
    SalesInvoiceJournalPrint salesInvoiceJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustInvoiceJour::findRecId(5637188088));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen);

    // Initalize
    salesInvoiceJournalPrint = SalesInvoiceJournalPrint::construct();
    salesInvoiceJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesInvoiceJournalPrint.parmUsePrintManagement(false);
    salesInvoiceJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesInvoiceJournalPrint.printJournal(set);
}

Ändert man die Parameter der SRSPrintDestinationSettings kann man den Bericht natürlich auch an einen Drucker senden, eine Datei erstellen oder den Bericht per Mail versenden.

Das folgende Beispiel erstellt eine PDF-Datei.

static void printSalesInvoiceThroughCode(Args _args)
{
    SalesInvoiceJournalPrint salesInvoiceJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustInvoiceJour::findRecId(5637188088));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::PDF);
    srsPrintDestinationSettings.fileName(@'c:\temp\invoice.pdf');
    srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::File);
    srsPrintDestinationSettings.numberOfCopies(1);
    srsPrintDestinationSettings.overwriteFile(true);

    // Initalize
    salesInvoiceJournalPrint = SalesInvoiceJournalPrint::construct();
    salesInvoiceJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesInvoiceJournalPrint.parmUsePrintManagement(false);
    salesInvoiceJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesInvoiceJournalPrint.printJournal(set);
}

Weiters kann man auf diese Art & Weise auch mehrere Rechnungen auf einmal drucken, dazu muss man lediglich die entsprechenden CustInvoiceJour-Datensätze dem Set "set" hinzufügen:

    ...   
    // Add record
    set.add(CustInvoiceJour::findRecId(5637155842));
    set.add(CustInvoiceJour::findRecId(5637145354));
    ...

Wer die Rechnung zusätzlich noch im Druckarchiv speichern möchte, kann dies durch folgende Zeile erreichen:

    ...   
    srsPrintDestinationSettings.parmPrintToArchive(true);
    ...
Dieser Beitrag bezieht sich auf die Version:
Dynamics AX 2012

Lionel Folkes 13.12.2017 21:57 | #1


TKe 25.04.2018 15:48 | #2


Kommentar hinzufügen
 
 

 

 
 
 
Beiträge des aktuellen Monats
März 2024
MoDiMiDoFrSaSo
 123
45678910
11121314151617
18192021222324
25262728293031
 
© 2006-2024 Heinz Schweda | Impressum | Kontakt | English version | Mobile Version
Diese Webseite verwendet Cookies, um Benutzern einen besseren Service anzubieten. Wenn Sie weiterhin auf der Seite bleiben, stimmen Sie der Verwendung von Cookies zu.  Mehr dazu