Showing posts with label General. Show all posts
Showing posts with label General. Show all posts

Tuesday, July 17, 2018

Develop Cubes

The "Create New Cubes" demonstration will create a cube that enables you to
analyze data from Microsoft Dynamics AX 2012. During the demonstration, you
will use the Business Intelligence (BI) properties in Microsoft Dynamics AX
2012 to specify measures and attributes for the cube. Additionally you will
generate an Analysis Services project so that you can work with the cube in SQL
Server Business Intelligence Development Studio (BIDS).


In this demonstration's sequence of steps, you will create an analysis cube called
"Sales analysis" that will allow you to analyze the following data for the Contoso
group of companies:

• Sales revenue by quarter, months, and weeks

• Sales revenue by payment mode

• Average sales by customer group

The demonstration steps include the following tasks:

• Creating a perspective for a cube

• Specifying cube measure and attributes

• Generating an Analysis Services project

• Deploying a cube

• Browsing cube data

Before performing the steps in the demonstration, you will need to have the following installed:

• Microsoft Dynamics AX with demo data

• SQL Server Business Intelligence Development Studio

• Analysis Services extensions for Microsoft Dynamics AX


Best Regards,
Hossein Karimi

Saturday, July 7, 2018

Parm Tables

When sales orders, purchase orders, or production orders are updated to a new
status, Microsoft Dynamics AX uses Parm tables to store what will be updated.
This allows the user to view and modify what will be updated without affecting
the original order. It also enables the update to be processed by the batch system.




The user can view and edit the Parm tables in the SalesEditLines orPurchEditLines forms. In the previous figure, the SalesParmLine table appears
on the
Lines tab, and the SalesParmTable appears on the SalesOrders tab.

To use the Parm tables, a ParmId is created. This is a sequential number taken
from the System ID number sequence set up on the Company Info table. The
ParmId ensures the tables are linked correctly using a unique identifier for each
update - one order can be updated multiple times.
The table records are then created using data from the appropriate tables. For
example,
PurchParmTable is initialized using data from PurchTable, andPurchParmLine is initialized using data from PurchLine.
Note the use of
InitFrom methods on most of these tables.
In the
SalesFormLetter.CreateParmLine() method the SalesParmLine record
is set from
SalesLine table by use of the SalesParmLine.initFromSalesLine()method.

Best Regards,
Hossein Karimi  

InitFrom

Often, a record has default values for fields initialized with data copied from
another table. For example, when a sales order is created and a customer account
is specified, fields including Invoice Account, Delivery Address, Tax Group, and
Currency are copied from the
CustTable record to the SalesTable. This is done
in the
SalesTable.InitFromCustTable() method which contains a list of field
assignments between the two tables. This is a common technique of initializing
fields in one table from another table, and is always the first place to analyze.
For example, to add the new field "Fragile" to the BOM table that defaults from
another new field "Fragile" in the
InventTable, consider adding the following
line to
BOM.InitFromInventTable() :


1
this.fragile = inventTable.fragile;

Best Regards,
Hossein Karimi

Temporary Tables

A temporary table is defined in the AOT as a normal table, but with the
TableType property set to either InMemory or TempDB. Data is not persisted in
a temporary table, and only remains while the table is in scope. If TableType is
set to InMemory, the data is stored in memory or in a temporary file if memory is
full. TempDb means it is stored in a table in SQL, and can be joined to regular
tables at the database tier.
A typical example is a class which initializes a temporary table and inserts some
records, which should be shown in a form. The class has a variable _
tmpTablewhich holds the data and the form has a data source tmpTable_DS which should
show the same data. This is solved by using the method
tmptable_DS.setTmpData(_tmpTable). This disregards the individual file
allocated to
tmptable_DS. Now, both _tmpTable and tmptable_DS will access
the same pool of data, as if they were normal table variables. The allocated file
now shared between _
tmpTable and tmptable_DS is deleted once both variables
have gone out of scope.
Instead of making a dedicated definition of a temporary table in the AOT,
consider making a temporary instance of a database table (in other words, a nontemporary table which is part of the SQL database). Do this using the .
setTmp()method before accessing the variable. Be careful with this option, as you can
activate other methods which act as if it is real database data and cause
subsequent updates in other tables. See the following example, which copies all
customers from Australia to a temporary table.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
static void CopyPersistedTableToTemp(Args _args)
{
  CustTable custTable;
  CustTable tmpCustTable;

  tmpCustTable.setTmp();
  while select custTable
  where custTable.CountryRegionId == "AU"
  {
    tmpCustTable.data(custTable.data());
    tmpCustTable.doInsert();
  }
}

Best Regards,
Hossein Karimi

Locking

So far you have seen that the database server can access data faster when the
number of requests to the database is minimized, by using efficient queries and
caching.
Another issue is if multiple users want to lock the same record at the same time.
Only one user can lock the record, and the rest wait in a queue until the record is
released. This has a substantial effect on the time used to perform a function.
Locks are typically done in transactions where more than one record is locked at
a time. The following example illustrates two different processes which lock
different items:
Process 1 Process 2
Item C - Locked -
Item A - Locked -
Item B - Locked Item G - Locked
Item G - Waiting for lock from
Process 2
Item A - Waiting for lock from
Process 1

This situation is called a dead lock; one of the transactions must be aborted to
resolve the issue.
Locking is the biggest issue with scalability, which means that many users are
working with the same functions and data.
To reduce locking, consider using Optimistic Concurrency Control (OCC). When
the risk of overlapping transactions modifying the same data is small, optimistic
locking can increase concurrency and thus transaction throughput. Enable OCC
for a table by setting the property
OccEnabled to Yes.

NOTE: Only a few tables in the standard application do not use Optimistic
Concurrency Control.
Strategies to use to avoid or reduce the locking problem are as follows:

• Keep the transactions as short in time as possible. Do not
compromise the integrity of the data.


• Try to avoid locking central resources.

• Try to lock central resources in the same order. This avoids the dead
lock situation discussed previously. This serializes the process,
which means that only one user can perform this at a time.


• Never implement dialog with the user inside a transaction.

Locking is held for the time it takes to finish the process. If the process has poor
performance because of missing optimization of AOS and database
communication, the locking is a bigger issue and needs to be addressed first.


Best Regards,
Hossein Karimi

Display Method Caching

Caching display methods improves the performance of display functions if they
are calculated on the AOS and improves performance when records are
transferred from the server to the client.
Only methods that are explicitly added to the cache are affected by the new
caching mechanism. To sign up a method for caching, the method
cacheAddMethod on the form data source should be called after super() in the
init method of the data source.

The call to cacheAddMethod also determines how frequently the cached display
method value is updated. The value is filled in upon fetching data from the backend, and it is refreshed when reread is called on the data source. Additionally, by
default, the display method values are also updated when the record is written to
the database. But that can be changed using the _updateOnWrite parameter in the
cacheAddMethod.
Only display methods that are of display type can be cached. Edit methods
cannot be cached. Only display methods placed on the table, can be cached.
One example of the initialization is found in \Forms\PurchTable\Data
Sources\PurchLine\Methods\init.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
purchLine_ds.cacheAddMethod(tablemethodstr(PurchLine,
receivedInTotal));
purchLine_ds.cacheAddMethod(tablemethodstr(PurchLine,
invoicedInTotal));
purchLine_ds.cacheAddMethod(tablemethodstr(PurchLine,
itemName));
purchLine_ds.cacheAddMethod(tablemethodstr(PurchLine,
displayBudgetCheckResult));
purchLine_ds.cacheAddMethod(tablemethodstr(PurchLine,
calcPendingQtyPurchDisplay));

Display methods not based on cached data, are candidates for display method
caching.


Best Regards,
Hossein Karimi

Record View Caching

Use record view caching to cache the records from a select statement (a result
set). Result set caching is made available through the
RecordViewCache class.
The cache is instantiated using a
select with the nofetch option. If the
instantiating
select is a join, a temporary table or is instantiated without thenofetch option, the cache is not instantiated and an error is reported. The selectclause of the select defines the result set and only "==" predicates are accepted.
The following example illustrates the instantiating of a record view cache:


1
2
3
4
5
SalesLine salesLine;
RecordViewCache salesLineCache;
select noFetch salesLine
where salesLine.SalesId =="100";
salesLineCache = new recordViewCache(salesLine);

The cache is not shared between Microsoft Dynamics AX clients, and is
deactivated as soon as the cache object goes out of scope or is destroyed.
The cache is used when a
select is from the same table, not a join and at least
matches the
where clause that the cache was instantiated with.
If the table is not set up for Optimistic concurrency then using the forupdate
option on the
select within TTS results in database locks on all the rows that are
put into the cache. A subsequent
select forupdate within the same TTS is
selected from the cache and not from the database as the row is already locked.
Updates and deletes that match the instantiating
where clause simultaneously
maintain the database and the cache. Updates and deletes are not in the above
category do not affect the result
-set.
The reread method retrieves data from the database and updates the copy data.
The cache can be instantiated using a
select without a where clause. This
effectively creates a copy of the table in memory and functions like a personal
table copy.
The cache is useful for caching tables that are not of static nature, or that contain
so many records that the other caching methods would be impractical.
Because of concurrency issues, the
forupdate keyword on the instantiating X++select should only be used when all the records in the result set will be updated.
Otherwise, it is a better strategy to
select forupdate the records that are updated
or use Optimistic concurrency on the tables.
Do not use field
-lists unless you are certain that the omitted fields will never be
used. There is no warning or error when selecting fields from the cache that were
not included in the
select that instantiated the result set.
Inserts normally do not affect the cache even when the record would match the
where clause defining the result-set.
When you use this form of caching, consider the memory consumption, as there
is no internal limitation to the memory allocated for a single table. Different
application behavior, with regard to exploiting caching when it is running on
server versus client, could be an option.


One example of using record view caching is the class InventMovement. This
holds information about inventory transactions related to one SalesLine,
PurchLine and more. The cache is defined as a RecordViewCache object in
\Classes\InventMovement\classDeclaration.
The cache is initialized by the method
\Data\Dictionary\Tables\InventTrans\Methods\viewCacheInventTransOrigin



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
public static RecordViewCache
viewCacheInventTransOrigin(InventTransOriginId
_inventTransOriginId, boolean _forupdate = false)
{
  InventTrans inventTrans;
  inventTrans.selectForUpdate(_forupdate);
  select nofetch inventTrans where
  inventTrans.InventTransOrigin == _inventTransOriginId;
  return new RecordViewCache(inventTrans);
}

According to the cross reference, this method is called from
\Classes\InventMovement\viewCacheInventTransId.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
void viewCacheInventTransOrigin()
{
  if (viewCacheInventTrans)
    return;
  viewCacheInventTrans = null;
  viewCacheInventTrans =
  
 InventTrans::viewCacheInventTransOrigin(this.InventTransOri
ginId(),true);
}

Best Regards,
Hossein Karimi

Entire Table Caching

The entire table caching loads all the records in the table the first time one record
is fetched. There is no limitation on the number of records cached.
An individual cache is maintained for each data area in Microsoft Dynamics AX.
The AOS holds the cache. This is shared between all clients connected to the
AOS. The client supplements this AOS caching with a FoundAndEmpty single
record caching if possible.
The entire table caching is not used when making a join with other tables which
is not entire table cached.

The entire table caching is selected by the CacheLookup property setting on the
table. The individual users can disable the caching clicking
Tools > Options >Preload. This form also provides an overview of which tables are configured by
using entire table caching.




Best Regards,
Hossein Karimi

Single-Record Caching

Microsoft Dynamics AX offers record caching. Rows selected through a cachekey are cached and successive look-ups specifying the cache-key are then served
from the record cache. The record-cache holds the rows that match frequently
issued single
-row queries.
The cache
-key is the Primary Key on the cached table. If a Primary Key does not
exist, the first unique index is used.


Because only single-row queries go into the cache, the cache is small with a
default value of 100 rows on the client and 2000 rows on the AOS.
Four single record cache settings are used with tables:
CacheLookup Result
None No data is cached or retrieved from cache for this table.
No caching should be used for tables that are heavily
updated or where it is unacceptable to read outdated
data.
NotInTTS All successful caching key selects are cached.
When in TTS (after ttsbegin), the record is read once
from the database and subsequently from cache. The
record is select-locked when read in TTS which ensures
that the record cached is not updated as long as the TTS
is active.
A typical example of its use is the CustTable in the
standard application. It is acceptable to read outdated
data from cache outside TTS, but when data is used for
validation or creating references it is ensured that it is
real-time data.
Found All successful caching key selects are cached. All
caching key selects are returned from cache if the record
exists there. A
select forupdate in TTS forces reading
from the database and replaces the record in the cache.
This is typically used for static tables like ZipCodes
where the normal case is that the record exists.
FoundAndEmpty All selects on caching keys are cached, even selects not
returning data.
All caching key selects are returned from caching if the
record exists there or the record is marked as non
existing in the cache.
An example of this kind of caching is found in the
InventTxt table in the standard application. For this
table it is a normal case that no record exists. Therefore,
in this case it is of great value to register the non
existing keys.

Important features about single-record caching are as follows:

• The caching only works when selecting exactly one record, with a
distinct
where on the primary key.

• The cache will not support fetch of multiple records in a query or a
"while select".


• The cache does not support data retrieved by joining more than one
table.

 
The cache on the client is not updated with changes done from other clients. This
means that one client can cache and use invalid information.
The single record caching is selected by the CacheLookup property setting on the
table.
You can use the AOT find tool to list some examples of this setting.


Best Regards,
Hossein Karimi

Read-ahead Caching

The SQL interface in Microsoft Dynamics AX provides read-ahead caching and
uses a buffer to pre
-fetch rows. The read-ahead adapts to the queries executed.
As an example, a query to show rows in a form pre
-fetches in chunks that
correspond to the number of rows currently visible in the form, whereas a multirow select with the
FirstOnly keyword will not pre-fetch.

Best Regards,
Hossein Karimi

Caching

The previous sections have discussed how to optimize communication with the
database by structuring SQL statements that make the database access data in the
correct way. But the most optimal strategy is to have no communication with the
database or to minimize the number of communications with the database server.
The concept of caching is to remember the information retrieved from the
database and use this memory when the same data is needed at a later time.
However, this strategy has one large drawback, if the remembered information is
no longer valid, this could compromise the consistency of the database, as the
updates will be made based on invalid data.
This section covers data caching done by Microsoft Dynamics AX AOS and/or
client. Microsoft Dynamics AX supports the following kinds of caching:
• Read-ahead caching• Single-record caching• Entire table caching• Record view caching• Display method caching• Global object cache• Date effective join cache• Unique index cache extension• Cache lookup for table groups
The remainder of this section explains the first five above mentioned data
catching
 .

Best Regards,
Hossein Karimi

Saturday, June 23, 2018

Architecture

Microsoft Dynamics AX has a three-tier architecture.Three-Tier ArchitectureThree-tier architecture is defined as having a separate database, server and client
where:
• The database stores the data.• The server runs the application business logic.• The client application allows users to connect to the server to access
business logic and use the data in the database.
In Microsoft Dynamics AX the three tiers include the following:
• A SQL Server Database that houses the data entered into, and used
by, the Microsoft Dynamics AX application. It also houses the model
store that contains the application elements. (Application elements
are explained in the following lesson)
• An Application Object Server (AOS) is a service that runs most of
the business logic. This runs continuously on a central server.

•The Client application is the user interface through which an enduser accesses Microsoft Dynamics AX. There are various clients
available including the Microsoft Dynamics AX rich client and
Enterprise Portal.

Wednesday, June 20, 2018

Client Workspace

The client workspace is the standard rich client interface that an end-user uses. The workspace consists of various components:
 Navigation Pane 
The Navigation pane is the menu on the left side of the screen that shows all of the modules the current user has access to.
Content Pane
The content pane displays role centers, list pages and area pages. 
• Role centers display specific data, reports, alerts, and common tasks associated with a user's role in the organization. The role center is displayed when an end-user opens the application or goes to Home in the Navigation pane. 
• List pages display lists of data. They are optimized to view and search through a list of records and act on information. 
• Area pages display all menu items relevant to the module selected in the Navigation pane. They are grouped logically to make it easier for end-users to find what they need.


Customers List Page
In the Navigation pane, click Accounts Receivable > Common > Customers > All customers. This brings up a list of all customers in the system.  In the center of the form is a grid that displays a list of customers. At the top of the screen is the Action Pane that contains buttons to open other forms and take actions related to the selected customer. On the right are FactBoxes that show data related to the selected customer.  To create a new customer, click New > Customer in the Action Pane. A new form opens where you can enter data for the new customer. Fields with a red wavy line are mandatory.
In the grid on the list of customers, click the field header of the Customer account field. Doing this sorts the data by customer account number order.

Wednesday, June 13, 2018

Find online “users” in Dynamics AX with query

Without having to log into Ax you can find online “users” in Dynamics AX with query
select * from SYSCLIENTSESSIONS where STATUS = 1 and CLIENTTYPE = 0
Status = 1 – This means that the user is online
ClientType = 0 – This means that the user is listed as “user” in the list of online users in Ax.
Best Regards,
Hossein Karimi

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...