This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
Dynamics AX 2012
|
|
|
|
|
|
This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
|
The following job demonstrates, how you can print an existing Purchase order through code. The example sends the report to screen.
{
PurchPurchOrderJournalPrint purchPurchOrderJournalPrint;
Set set = new Set(Types::Record);
SRSPrintDestinationSettings srsPrintDestinationSettings;
// Add record
set.add(VendPurchOrderJour::findRecId(5637179849));
// Set printer settings
srsPrintDestinationSettings = new SRSPrintDestinationSettings();
srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen);
// Initalize
purchPurchOrderJournalPrint = PurchPurchOrderJournalPrint::construct();
purchPurchOrderJournalPrint.parmPrintFormletter(NoYes::Yes);
purchPurchOrderJournalPrint.parmUsePrintManagement(false);
purchPurchOrderJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());
// Print
purchPurchOrderJournalPrint.printJournal(set);
}
Changing the parameter of the instance of SRSPrintDestinationSettings allows you to send the purchase order to printer, file or mail. The next example creates a PDF-file.
{
PurchPurchOrderJournalPrint purchPurchOrderJournalPrint;
Set set = new Set(Types::Record);
SRSPrintDestinationSettings srsPrintDestinationSettings;
// Add record
set.add(VendPurchOrderJour::findRecId(5637179849));
// Set printer settings
srsPrintDestinationSettings = new SRSPrintDestinationSettings();
srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::PDF);
srsPrintDestinationSettings.fileName(@'c:\temp\purchaseorder.pdf');
srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::File);
srsPrintDestinationSettings.numberOfCopies(1);
srsPrintDestinationSettings.overwriteFile(true);
// Initalize
purchPurchOrderJournalPrint = PurchPurchOrderJournalPrint::construct();
purchPurchOrderJournalPrint.parmPrintFormletter(NoYes::Yes);
purchPurchOrderJournalPrint.parmUsePrintManagement(false);
purchPurchOrderJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());
// Print
purchPurchOrderJournalPrint.printJournal(set);
}
If you want to print multiple purchase orders at once, you have to add the corresponding VendPurchOrderJour-records to the set called "set:
// Add record
set.add(VendPurchOrderJour::findRecId(5637155842));
set.add(VendPurchOrderJour::findRecId(5637145354));
...
To save the purchase order additionally to print archive, you can add the following line:
srsPrintDestinationSettings.parmPrintToArchive(true);
...