Dynamics AX Blog - Microsoft Dynamics AX (Axapta) - Seite 17

In den letzten Jahren, in denen ich mich fast hauptsächlich mit der Entwicklung im Umfeld von Microsoft Dynamics AX (vormals Axapta) beschäftigt habe, ist das eine oder andere Code-Fragment entstanden, von dem ich mir vorstellen könnte, daß es auch für andere AX-Entwickler ganz nützlich sein könnte. Aber auch Tips und Tricks zu dem mächtigen ERP-System werde ich in dieser Kategorie präsentieren.
RSS-Feed dieser KategorieLieferschein per Code buchenMit Hilfe der folgenden Zeilen möchte ich zeigen, wie man einen Lieferschein per Code buchen kann. static void postSalesPackingslip(Args _args) { SalesTable salesTable = SalesTable::find("000747"); SalesFormLetter salesFormLetter; salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip); salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::All); } |
Rechnung per Code buchenMit Hilfe der folgenden Zeilen möchte ich zeigen, wie man eine Rechnung/Ausgangsrechnung per Code buchen kann. static void postSalesInvoice(Args _args) { SalesTable salesTable = SalesTable::find("000747"); SalesFormLetter salesFormLetter; salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::All); } |
Lieferschein per Code druckenDer nachstehende Job demonstriert, wie man in Dynamics AX 2012 einen vorhandenen (Ausgangs-)Lieferschein per Code (nach-)drucken kann. Im Beispiel erfolgt die Ausgabe am Bildschirm. static void printSalesPackingSlipThroughCode(Args _args) { SalesPackingSlipJournalPrint salesPackingSlipJournalPrint; Set set = new Set(Types::Record); SRSPrintDestinationSettings srsPrintDestinationSettings; // Add record set.add(CustPackingSlipJour::findRecId(5637161120)); // Set printer settings srsPrintDestinationSettings = new SRSPrintDestinationSettings(); srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen); // Initalize salesPackingSlipJournalPrint = SalesPackingSlipJournalPrint::construct(); salesPackingSlipJournalPrint.parmPrintFormletter(NoYes::Yes); salesPackingSlipJournalPrint.parmUsePrintManagement(false); salesPackingSlipJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack()); // Print salesPackingSlipJournalPrint.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. static void printSalesPackingSlipThroughCode(Args _args) { SalesPackingSlipJournalPrint salesPackingSlipJournalPrint; Set set = new Set(Types::Record); SRSPrintDestinationSettings srsPrintDestinationSettings; // Add record set.add(CustPackingSlipJour::findRecId(5637161120)); // Set printer settings srsPrintDestinationSettings = new SRSPrintDestinationSettings(); srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::PDF); srsPrintDestinationSettings.fileName(@'c:\temp\packingslip.pdf'); srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::File); srsPrintDestinationSettings.numberOfCopies(1); srsPrintDestinationSettings.overwriteFile(true); // Initalize salesPackingSlipJournalPrint = SalesPackingSlipJournalPrint::construct(); salesPackingSlipJournalPrint.parmPrintFormletter(NoYes::Yes); salesPackingSlipJournalPrint.parmUsePrintManagement(false); salesPackingSlipJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack()); // Print salesPackingSlipJournalPrint.printJournal(set); } Weiters kann man auf diese Art & Weise auch mehrere Lieferscheine auf einmal drucken, dazu muss man lediglich die entsprechenden CustPackingSlipJour-Datensätze dem Set "set" hinzufügen: ... // Add record set.add(CustPackingSlipJour::findRecId(5637155842)); set.add(CustPackingSlipJour::findRecId(5637145354)); ... Wer den Lieferschein zusätzlich noch im Druckarchiv speichern möchte, kann dies durch folgende Zeile erreichen: ... srsPrintDestinationSettings.parmPrintToArchive(true); ... |
Primäre Adresse per Code anlegenDie nachstehenden Zeilen Code zeigen ein Beispiel, wie man per X++ eine (primäre) Adresse für eine vorhandene Partei im Globalen Adressbuch erstellen kann. Primär wird sie allerdings nur dann, wenn es noch keine primäre Adresse gibt! static void createPartyAddress(Args _args) { DirPartyTable dirPartyTable = DirPartyTable::findByNum("???100000"); DirParty dirParty; DirPartyPostalAddressView dirPartyPostalAddressView; // Create instance of dirParty dirParty = DirParty::constructFromCommon(dirPartyTable, DirUtility::getCurrentDateTime(), dirPartyTable.partyType()); // Create primary address dirPartyPostalAddressView.LocationName = "Office"; dirPartyPostalAddressView.City = "Vienna"; dirPartyPostalAddressView.Street = "Kärtnerring"; dirPartyPostalAddressView.StreetNumber = "18"; dirPartyPostalAddressView.CountryRegionId = "AUT"; dirPartyPostalAddressView.IsPrimary = NoYes::Yes; dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView); } |
Auftragsbestätigung per Code druckenDer 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()); salesConfirmJournalPrint.printJournal(set); } |
Bestellung per Code druckenDer 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()); purchPurchOrderJournalPrint.printJournal(set); } |
|
|
|
|
|
|
Mit Hilfe der folgenden Zeilen möchte ich zeigen, wie man eine Auftragsbestätigung per Code buchen kann.
Wer etwas mehr Kontrolle über die zu buchenden Daten haben möchte, sollte sich die verfügbaren Parameter der salesFormLetter.update() näher ansehen.