Bestellung per Code drucken

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

static void printPurchaseOrderThroughCode(Args _args)
{
    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);
}

Ä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 printPurchaseOrderThroughCode(Args _args)
{
    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);
}

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

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

Wer die Bestellung 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

Kommentar hinzufügen
 
 

 

 
 
 
Beiträge des aktuellen Monats
Mai 2024
MoDiMiDoFrSaSo
 12345
6789101112
13141516171819
20212223242526
2728293031 
 
© 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