Create a Transfer Journal using AX 2012 R2 Document Services and C#
Hi there,
On this post I would like to share some C# code to create a Transfer Journal using C#. I have written a few post in the past about services and they will help you understand how to create a service, service groups, deployment, etc.
Create Counting Journals
How to choose the right service
AX 2012 Services and AIF
Services Types
Creating a service in AX 2012
Back to the creation of a Transfer Journal with C#, this is an interesting code as we need to instantiate two different instances of the InventDim Table; InventDimIssue and InventDimReceipt.
InventDimIssue can be thought as the From values and InventDimReceipt can be thought as the To values (i.e. From Warehouse ==> To Warehouse).
In addition, another interesting point is that AX uses the InventJournalTable and InventJournalTrans for all the inventory journal entries, and we specified, in C#, which entity (AXD) will be using.
The following is the code:
private void InventTransferJourTest()
{
InventTransferJournal.CallContext callContext = new InventTransferJournal.CallContext();
InventTransferJournal.TransferJournalServiceClient servClient = new InventTransferJournal.TransferJournalServiceClient();
InventTransferJournal.AxdTransferJournal transjournal = new InventTransferJournal.AxdTransferJournal();
InventTransferJournal.AxdEntity_InventJournalTable journalheader = new InventTransferJournal.AxdEntity_InventJournalTable();
//Header
callContext.Company = "CEU";
journalheader.JournalNameId = "TransferJourId";
journalheader.Description = "Transfer Journal";
//End header
//Lines
InventTransferJournal.AxdEntity_InventJournalTrans journalLines = new InventTransferJournal.AxdEntity_InventJournalTrans();
journalLines.ItemId = "123456";
journalLines.Qty = 45;
journalLines.TransDate = DateTime.Now;
InventTransferJournal.AxdEntity_InventDimIssue inventDimIssue = new InventTransferJournal.AxdEntity_InventDimIssue();
inventDimIssue.InventBatchId = "RUT";
inventDimIssue.InventLocationId = "21";
inventDimIssue.InventSiteId = "1";
journalLines.InventDimIssue = new InventTransferJournal.AxdEntity_InventDimIssue[1] { inventDimIssue };
InventTransferJournal.AxdEntity_InventDimReceipt inventDimReceipt = new InventTransferJournal.AxdEntity_InventDimReceipt();
inventDimReceipt.InventSiteId = "2";
inventDimReceipt.InventLocationId = "11";
inventDimReceipt.InventBatchId = "RSR";
journalLines.InventDimReceipt = new InventTransferJournal.AxdEntity_InventDimReceipt[1] { inventDimReceipt };
//End Lines
journalheader.InventJournalTrans = new InventTransferJournal.AxdEntity_InventJournalTrans[1] { journalLines };
transjournal.InventJournalTable = new InventTransferJournal.AxdEntity_InventJournalTable[1] {journalheader};
try
{
servClient.create(callContext, transjournal);
}
catch (Exception e)
{
MessageBox.Show(e.InnerException.ToString());
}
}
That's all for today and stay tuned as in the next few weeks I will be talking about TFS and how to work with AX 2012 in a way that we utilize the TFS server to its max capacity.
Have a great weekend!
与本文相关的文章
- 安装 ExFlow ISV 时出现的问题/Issue while installing ExFlow ISV
- D365: 如何在 X++ 中获取最后一个工作流程审批人/D365: How to get last workflow approver in X++
- 如何在 D365 F&O 中手动创建物料批次/How to create Item Batch manually in D365 F&O
- D365FO: 通过 X++ 中获取用于显示的维度值/D365FO: Get dimension display value in X++
- D365: When and how to use postLoad() method
- Consignment Inventory Handling in D365 Finance and Operations