Dynamics AX Blog - Dynamics AX 2012 - Seite 23

RSS-Feed dieser Version
Verwenden einer Assembly/DLL in Dynamics AXUm eine DLL in Dynamics AX verwenden zu können, muss diese im References-Knoten des AOT hinzugefügt werden.
In beiden Fällen muss nun der Dialog mit OK bestätigt werden. |
Word-Dokument mit Tabelle per Code erstellen
static void CreateWordFileWithTable(Args _args) { COM wordApplication; COM wordTables; COM wordTable; COM wordSelection; COM wordTableRows; COM wordRange; COM wordTableCell; COM wordTableCellRange; COM wordDocuments; COM wordDocument; COM wordTableBorders; ; // Initialize Word object and document wordApplication = new COM("Word.Application"); wordDocuments = wordApplication.documents(); wordDocuments.add(); wordDocument = wordDocuments.item(1); wordSelection = wordApplication.selection(); wordRange = wordSelection.range(); // Get table collection wordTables = wordSelection.tables(); // Create table with 3 rows and 5 columns wordTable = wordTables.add(wordRange, 3, 5); // Fill cell: First line, second column wordTableCell = wordTable.Cell(1, 2); wordTableCellRange = wordTableCell.range(); wordTableCellRange.text("Hello"); // Fill cell: Second line, third column wordTableCell = wordTable.Cell(2, 3); wordTableCellRange = wordTableCell.range(); wordTableCellRange.text("World"); // Enable table borders wordTableBorders = wordTable.borders(); wordTableBorders.enable(true); // Add colored borders wordTableBorders.InsideLineStyle(3); wordTableBorders.OutsideLineStyle(5); wordTableBorders.OutsideColorIndex(2); // Get table row collection and add a new row wordTableRows = wordTable.rows(); wordTableRows.add(); // Open word wordApplication.visible(true); wordApplication.finalize(); } Das per obigem Code erstellte Word-Dokument sieht wie folgt aus: |
AX 2012: Importieren eines Debitoren mit Hilfe des Data import/export frameworks (ODBC)
04.12.2013Microsoft Dynamics AX (Axapta)
Mit Hilfe des Data import/export frameworks ist es möglich, Daten aus externen Systemen in Dynamics AX zu importieren. im folgenden möchte ich dies anhand der Anlage eines Debitoren über eine ODBC-Verbindung demonstrieren.
ODBC-Benutzer DSN einrichten
Erstellen einer VerarbeitungsgruppeErstellen einer Verarbeitungsgruppe (Processing group) unter Data import Export framework > Processing Group: |
AX 2012: Subselects über Computed columns abbildenMit Hilfe von Computed columns von Views sind auch in Dynamics AX Subselects/Subqueries möglich. Im folgenden habe ich eine Methode erstellt, die der Methode inventTable.productName() nachempfunden ist. private static server str compColItemName() { #define.ViewName("ItemNameView") #define.DataSourceName("InventTable") #define.FieldItemId("itemId") #define.FieldProduct("Product") str sProduct; DictView dictView; str translationSQLStr; str productSQLStr; dictView = new DictView(tableNum(#ViewName)); sProduct = dictView.computedColumnString (#DataSourceName, #FieldProduct, FieldNameGenerationMode::FieldList, true); translationSQLStr = strFmt("SELECT Name FROM EcoResProductTranslation WHERE EcoResProductTranslation.Product = %1 AND LanguageId = '%2'", sProduct, CompanyInfo::find().LanguageId); productSQLStr = strFmt("SELECT DisplayProductNumber FROM EcoResProduct WHERE EcoResProduct.RecId = %1", sProduct); return strFmt("isNUll((%1), (%2))", translationSQLStr, productSQLStr); } |
Erstellen einer AX<Table>-KlasseBenötigt man für eine Tabelle eine sog. AX<Table>-Klasse kann man sich diese mit Hilfe der Klasse AxGenerateAxBCClass generieren lassen. Dazu einfach diese Klasse im AOT per rechter Maustaste aufrufen und dem Assistenten folgen. Die auf diese Art & Weise generierte Klasse muss unter manchen Umständen noch etwas bearbeitet werden, dennoch geht der Vorgang rascher von der Hand, als die Klasse komplett selbst erstellen zu müssen. Und wenn sich die Tabelle ändert, beispielweise wenn neue Felder hinzukommen, kann man die AxGenerateAxBCClass einfach nochmals aufrufen und die AX<Table>-Klasse wird entsprechend erweitert. Wie man solche AX<Table>-Klassen verwendet, habe ich u.a. hier beschrieben. |
Erstellen einer Entität - beispielsweise eines Debitoren - per Code unter Verwendung von AX<Table>-Klassen
12.11.2013Microsoft Dynamics AX (Axapta)
Folgender Job soll veranschaulichen, wie man unter Verwendung von sog. AX<Table>-Klassen Entitäten in Dynamics AX per Code anlegen kann, ohne dabei - wie in diesem Beitrag beschrieben - direkt in die Tabellen zu schreiben.
Nachteile:
static void CreateCustomerAXClass(Args _args) { AxCustTable axCustTable; AxDirPartyTable AxDirPartyTable; CustTable CustTable; DirPartyTable DirPartyTable; AccountNum accountNum = "4711"; Name name = "Debitor 4711"; currencyCode currencyCode = "EUR"; custGroupId custGroupId = "DINL"; taxGroup taxGroup = "DINL"; languageId languageId = "de-AT"; ttsBegin; // Create or update Customer axCustTable = axCustTable::construct(); axCustTable.validateInput(true); axCustTable.continueOnError(true); // Validate fields without stopping error CustTable = CustTable::find(accountNum, true); if(CustTable) { axCustTable.custTable(CustTable); // Don't use this for new records to get initValue() called } axCustTable.parmAccountNum(accountNum); axCustTable.parmCustGroup(custGroupId); axCustTable.parmTaxGroup(taxGroup); axCustTable.parmCurrency(currencyCode); axCustTable.save(); // Create or update Global address book AxDirPartyTable = AxDirPartyTable::construct(); AxDirPartyTable.validateInput(true); AxDirPartyTable.continueOnError(true); // Validate fields without stopping error DirPartyTable = DirPartyTable::findRec(axCustTable.custTable().Party, true); if(DirPartyTable) { AxDirPartyTable.dirPartyTable(DirPartyTable); } AxDirPartyTable.parmName(name); AxDirPartyTable.parmLanguageId(languageId); AxDirPartyTable.save(); ttsCommit; } |
|
|
|
|
|
|
Mir wurde diese Frage vor kurzem selbst gestellt und konnte diese allerdings nur zum Teil beantworten.
Ich wusste aber noch, daß ich schon einmal eine Seite gesehen hatte, wo dies genau erklärt wird. Aber ich wusste weder noch wo, noch konnte ich sie über diverse Suchmaschinen finden.
Aber in alten Unterlagen fand ich die Quelle dann doch, der Trick um die Quelle auch mit Google und Konsorten zu finden ist, mit dem altem Namen von Microsoft Dynamics AX - Axapta danach zu suchen!
Tut man dies, so findet man rasch folgende Seite:
http://www.axaptapedia.com/index.php?title=Lookups