Auftragsbestätigung per Code drucken

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

static void printSalesConfirmThroughCode(Args _args)
{
    SalesConfirmJournalPrint salesConfirmJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

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

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

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

    // Print
    salesConfirmJournalPrint.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 printSalesConfirmThroughCode(Args _args)
{
    SalesConfirmJournalPrint salesConfirmJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

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

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

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

    // Print
    salesConfirmJournalPrint.printJournal(set);
}

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

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

Wer die Auftragsbestätigung 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
April 2024
MoDiMiDoFrSaSo
1234567
891011121314
15161718192021
22232425262728
2930 
 
© 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