最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

Create a Transfer Journal using AX 2012 R2 Document Services and C#

网络文摘 William 3075浏览 0评论
 

 
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!
 
 

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址