Showing posts with label erp. Show all posts
Showing posts with label erp. Show all posts

Monday, December 15, 2014

Create Counting Journal in AX 2012 R2 via C# (Document Services)

Hi There,

Hi, I'd like to show some C# code that will create a Counting journal in AX 2012 R2.


I will be using the InventCountingJournalService service that already ships with AX 2012 R2.

This is a very low cost-high reward approach for the customers.

Let's start:


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(callContextcountJournal);

 }


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!

Tuesday, September 2, 2014

Parallel Compilation

Hello everybody!

I want to start the post #1 of this blog explaining a little bit about a tool that Microsoft implemented on MS Dynamics AX 2012 CU7 -- the parallel compilation. The official page of the parallel compilation is here.

Parallel compilation of an AOS was properly implemented on CU7 version of AX 2012 R2. There are some guys over the web that said that the parallel compilation works for older versions, like CU6. Particularly, I don't believe. I worked in a project that a full AOS compilation on CU6 took 12 ~ 13 hours. CU7 came to help us developers and build engineers to not waste time in a simple task!

Below we have a small script that performs the parallel compilation and also compile the IL code. Note: the axbuild.exe calculate the numbers of workers automatically according to the number of cores on server processor, as well as the process loaded on them.

Use this script only in development environments! Carefully!

SET ServiceName=AOS60$01
SET AOSHost=your_aos_name
SET AOSPort=2712
SET ServerPath="C:\Program Files\Microsoft Dynamics AX\60\Server\your_server_path\bin"
SET ClientPath="C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\bin"
SET AppExe="C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\bin\ax32.exe"

net stop %ServiceName%
net start %ServiceName%

cd\

cd %ServerPath%

axbuild.exe xppcompileall /s=01 /v /a=%ClientPath%

cd\

%AppExe% -aos2=%AOSHost%:%AOSPort% -startupcmd=compileil -lazytableloading -lazyclassloading

net stop %ServiceName%

net start %ServiceName%

If you don't want to run the IL compilation, just remove the line %AppExe% -aos2=%AOSHost%:%AOSPort% -startupcmd=compileil -lazytableloading -lazyclassloading.

Save this script as a batch file (extension .bat). With this, you can schedule tasks using Windows Server.

Enjoy DAXers!

Note: during the day, I pretend to improve this post. There are some more interesting details hidden on the command.

Friday, August 8, 2014

Post Zero

Let's work. Programming is only a matter of code. It is the art of translate what users want into a language that will become a system, a functionality. This blog has the goal to provide some tips and tricks about how programming better in X++, for all audiences -- since AX functional consultants that want to understand how the engine on the background makes the "magic" up to senior architects that had forgotten some small code.

Programming in X++, the language for AX is not easy. Sometimes the code is well-written, compiles fine, but the system does not work as the expect. Many daily problems can be solved changing some system/modules parameters. So, every time, before start a new customization, ask your user, functional consultant or manager if the system does not have a second path to solve the business inquiry. Check if the solution was not given at Microsoft Sure Step or Lifecycle Services (let's talk about them on the future).

If the only way is a change, let's do it. Once. Let's avoid "go-horse process" or "jeitinho brasileiro" (Brazilian readers will know well what I'm talking about).