Dieser Beitrag bezieht sich auf die Version:
Dynamics AX 2012
Dynamics AX 2012
|
|
Kommentar zu: Rechnung per Code drucken
|
|
|
|
|
|
Dieser Beitrag bezieht sich auf die Version:
Dynamics AX 2012
Kommentar zu: 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.
{
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.
{
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);
...