Showing posts with label Common. Show all posts
Showing posts with label Common. Show all posts

Monday, November 7, 2011

Get the active comapny in AX 2009 - curExt()

Use the curExt() function to get the active company in AX;

static void curExtExample(Args _arg)
{
str CompanyId;
;

CompanyId = curExt();
Info(CompanyId);
}

You would also use the following with the same results. However, the above is much more elegant.

static void curExtExample(Args _arg)
{
str CompanyId;
;

CompanyId = CompanyInfo::Find().DataAreaId;
Info(CompanyId);
}

Take Care!

Thursday, August 25, 2011

Application Object Server (AOS) architecture

The Application Object Server (AOS) provides the infrastructure to execute the business logic of the Microsoft Dynamics AX application. The AOS handles the required connectivity, security, and database connection management. You can install the AOS on a single computer or on multiple computers and group these computers in a load-balanced cluster.

In Microsoft Dynamics AX 2009,you can create a single cluster or multiple clusters of AOS servers.

Microsoft Dynamics AX requires Windows-integrated authentication for all servers in the system, which means that you must be running Active Directory. For security reasons, the AOS must be installed on a Windows server operating system.

A system used for demonstrations, development, or testing can be set up to use more than one AOS instance. For details about developer installations of Microsoft Dynamics AX 2009, see the Installation Guide.
In Microsoft Dynamics AX, the AOS is implemented as a Microsoft Windows

Service to take advantage of the following features:
  • Windows service applications run in the security context of a specific user account that is different from any logged-on user or the default computer account. The AOS service uses a system account for authentication during start up. This account is used by the AOS to access the file server and database server.
  • A Windows service application runs in its own Windows session and takes advantage of the service control manager (SCM, a feature of the Windows Server 2003 operating system or higher) to maintain status information and to provide the user interface for managing the AOS.
  • Windows services can be configured to start at system startup or upon demand, and they continue to run even when no user is logged into the system.
  • Server status can be reported to the Windows event log, allowing administrators to view errors and warnings that can aid in troubleshooting problems.
The following diagram provides a view of the architecture of the AOS.




Monday, August 1, 2011

Create Electronic Payment Format - AX 2009

Electronic payments are being used heavily today. It is importnat to understand how these work and how to implement them as they save lots of time and even more paperwork. In addition, AX 2009 provides some out-of-the-box payment templates, but they are not very felxible and very often we need to create our own.

Now the good thing about creating our own is that we can inherit from two base classes. (1) VendOutPaym and (2) VendOutPaymRecord.

VendOutPaym is ussually used to create the header and closing records of a payment file. On the other hand, VendOutPaymRecord is used to create the the lines records of the payment file. So, if we have a payment journal (AP > Journals > Payments> Payment Journal) with 10 lines, we should see only one header line, (in my case) only one Bank line (after header), 10 line records (Payment journal lines) and one closing line with totals, got the idea?

So, we would have to create two classes. One to write the header and closing records and one to write the journal lines, ok?

Here is the first class to write header and closing records. Because in my file the empey spaces needed to be filled with only 0's, I created a method that's called getProcessedStr that takes a string and an integer. The string is the actual value that will be written into the file but needs extra 0's. The int is the total lenght of this record in the text file.


Wednesday, June 15, 2011

Mark Customer Invoices for settlement with AX 2009 - Mark Invoices

After creating a payment journal (http://axwonders.blogspot.com/2011/06/create-axapta-payment-journal.html ), you might want to mark the invoices for settlement. This task is done by looping through the just created Payment Journal and then by querying the CustTransOpen Table and instantiating the CustTrans table from the CustTransOpen.CustTrans() method.


The following is the code to mark invoices. Also, the code loops through each payment journal transaction.

Also, the logic behind it is that the SpecTrans table needs to have two records in order to offset an open invoice with a transaction. So the code below inserts two records to the SpecTrans table. One is for all the open transactions (invoices - Sales) and the other is for all the payment transactions (paymet - Payment)

For example:

select firstonly invCustTrans where invCustTrans.AccountNum == custTable.AccountNum
            && invCustTrans.TransType == LedgerTransType::Sales
            && !invCustTrans.LastSettleDate;


the code above will select all the customer transactions with a TransType of Sales.

On the other hand, the code below will select all the customer transaction with a TransType of Payment.

select firstonly payCustTrans where payCustTrans.AccountNum == custTable.AccountNum
            && payCustTrans.TransType == LedgerTransType::Payment
            && !payCustTrans.LastSettleDate;


Then we need to insert the two instances of CustTrans into the SpecTrans table:

specOffsetVoucher.insert(invCustTrans.dataAreaId, invCustTrans.TableId, invCustTrans.RecId, invCustTrans.AmountCur, invCustTrans.CurrencyCode, NoYes::No);

specOffsetVoucher.insert(payCustTrans.dataAreaId, payCustTrans.TableId, payCustTrans.RecId, payCustTrans.AmountCur, payCustTrans.CurrencyCode, true);
The following is the whole code: