Hi There,
This post I would like to share some C# code to create a Counting Journal in AX 2012 R2 using the InventCountingJournalService that ships with AX. Let's keep in mind that the AX 2012 R2 document services are a extremely low cost option of providing this features to an external client with no AX development whatsoever.
So, I would like to start from the beginning:
1- Create a Service Group
2- Add the InventCountingJournalService to the Service Group
3- Deploy the Service Group. This will output the following.
4- Get the WSDL URI from the inbound ports form.
5- Go to Visual Studio, create a new windows form project, add a button and double click the button to create a button event.
6- Right - Click the Service References and choose Add Service Reference.
7 - Past the WSDL URI and click GO
8- Give your service a name i.e. InventCountingJournnal
9 - Write the following code and test.
private void InventCountingJournal()
{
InventCountingJournal.CallContext callContext = new InventCountingJournal.CallContext();
InventCountingJournal.CountingJournalServiceClient servClient = new InventCountingJournal.CountingJournalServiceClient();
InventCountingJournal.AxdCountingJournal countJournal = new InventCountingJournal.AxdCountingJournal();
InventCountingJournal.AxdEntity_InventJournalTable journalHeader = new InventCountingJournal.AxdEntity_InventJournalTable();
//Header
callContext.Company = "CEU";
journalHeader.JournalNameId = "CountJour";
journalHeader.Description = "Counting Journal";
//Header
//lines
InventCountingJournal.AxdEntity_InventJournalTrans journalLines = new InventCountingJournal.AxdEntity_InventJournalTrans();
journalLines.ItemId = "12345";
journalLines.Qty = 50;
journalLines.TransDate = DateTime.Now;
InventCountingJournal.AxdEntity_InventDim inventDim = new InventCountingJournal.AxdEntity_InventDim();
inventDim.InventBatchId = "3";
inventDim.InventLocationId = "1";
inventDim.InventSiteId = "3";
journalLines.InventDim = new InventCountingJournal.AxdEntity_InventDim[1] { inventDim };
//Lines
journalHeader.InventJournalTrans = new InventCountingJournal.AxdEntity_InventJournalTrans[1] { journalLines };
countJournal.InventJournalTable = new InventCountingJournal.AxdEntity_InventJournalTable[1] { journalHeader };
servClient.create(callContext, countJournal);
}
You can test this by clicking the button, and calling this method. A new counting journal would be created in AX. Then, you can either have a batch posting all the journals or simply have a user doing it manually.
That's all for now!
This post I would like to share some C# code to create a Counting Journal in AX 2012 R2 using the InventCountingJournalService that ships with AX. Let's keep in mind that the AX 2012 R2 document services are a extremely low cost option of providing this features to an external client with no AX development whatsoever.
So, I would like to start from the beginning:
1- Create a Service Group
2- Add the InventCountingJournalService to the Service Group
3- Deploy the Service Group. This will output the following.
4- Get the WSDL URI from the inbound ports form.
5- Go to Visual Studio, create a new windows form project, add a button and double click the button to create a button event.
6- Right - Click the Service References and choose Add Service Reference.
7 - Past the WSDL URI and click GO
8- Give your service a name i.e. InventCountingJournnal
9 - Write the following code and test.
private void InventCountingJournal()
{
InventCountingJournal.CallContext callContext = new InventCountingJournal.CallContext();
InventCountingJournal.CountingJournalServiceClient servClient = new InventCountingJournal.CountingJournalServiceClient();
InventCountingJournal.AxdCountingJournal countJournal = new InventCountingJournal.AxdCountingJournal();
InventCountingJournal.AxdEntity_InventJournalTable journalHeader = new InventCountingJournal.AxdEntity_InventJournalTable();
//Header
callContext.Company = "CEU";
journalHeader.JournalNameId = "CountJour";
journalHeader.Description = "Counting Journal";
//Header
//lines
InventCountingJournal.AxdEntity_InventJournalTrans journalLines = new InventCountingJournal.AxdEntity_InventJournalTrans();
journalLines.ItemId = "12345";
journalLines.Qty = 50;
journalLines.TransDate = DateTime.Now;
InventCountingJournal.AxdEntity_InventDim inventDim = new InventCountingJournal.AxdEntity_InventDim();
inventDim.InventBatchId = "3";
inventDim.InventLocationId = "1";
inventDim.InventSiteId = "3";
journalLines.InventDim = new InventCountingJournal.AxdEntity_InventDim[1] { inventDim };
//Lines
journalHeader.InventJournalTrans = new InventCountingJournal.AxdEntity_InventJournalTrans[1] { journalLines };
countJournal.InventJournalTable = new InventCountingJournal.AxdEntity_InventJournalTable[1] { journalHeader };
servClient.create(callContext, countJournal);
}
You can test this by clicking the button, and calling this method. A new counting journal would be created in AX. Then, you can either have a batch posting all the journals or simply have a user doing it manually.
That's all for now!
No comments:
Post a Comment