Monday, November 26, 2012

Lookups on Dialog: SysTableLookup and registerOverrideMethod

SysTableLookup can be used in dialogs to create custom lookups.
control.registerOverrideMethod can be used to register the methods to override by an object
Here is the example which shows basic usage of both. We will create a dialog and get a lookup of account numbers on a control
protected Object dialog()
{
    FormStringControl control;
    ;

    dialog = super();
    dialogFeildAccountNum = dialog.addField(extendedTypeStr(AccountNum));
    control = dialogFeildAccountNum.control();
    control.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(DialogLookup, accountNumLookup), this);
   
    return dialog;
}
Here is the method:
private void accountNumLookup(FormStringControl _control)
{
    SysTableLookup          sysTableLookup;
    QueryBuildDataSource    queryBuildDataSource;
    Query                   query = new Query();

    queryBuildDataSource = query.addDataSource(tablenum(CustTable));

    sysTableLookup = SysTableLookup::newParameters(tablenum(CustTable), _control);
    sysTableLookup.addLookupfield(fieldnum(CustTable, AccountNum),  true);
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

DictEnum class in AX2012


The DictEnum class obtains meta-information about the base enumeration enumerations in the AOT.
This can be used when you want to access an enum properties or values at run time.
Can be initialized as below:
DictEnum            dictEnum;
dictEnum = new DictEnum(enumNum(DMFEntityType));

Now we are ready to all properties of enum DMFEntityType

dictEnum.value2Label(i)- Retrieves the label of a specified enumeration value. ‘i’ being the enumeration value

dictEnum.index2Label(i) - can be used in a for loop where ‘i’ being the iterator index value.  This will retrieve the label of the enumerator at specified index.
dictEnum.index2value(i) - can be used in a for loop where ‘i’ being the iterator index value.  This will retrieve the enumerator value of the enumerator at specified index.

RecordInsertList class in AX2012


The RecordInsertList class allows to insert multiple records in to database.

new() - Creates a new object to hold records for insertion into the database.
add() - Adds a record to a RecordInsertList object for subsequent insertion into the database
insertDatabase() -  Inserts all records, that have not already been inserted, in the current 
RecordInsertList object.  


The following example uses the RecordInsertList class to copy records from one table buffer to another.
void copyBOM(BOMId _FromBOM, BOMId _ToBOM)
{
    RecordInsertList BOMList;
    BOM BOM, newBOM;

    BOMList = new RecordInsertList(tableNum(BOM)); 

    while select BOM
    where BOM.BOMId == _FromBOM
    {
        newBOM.data(BOM);
        newBOM.BOMId = _ToBOM;
        BOMList.add(newBOM); 
     }
    BOMList.insertDatabase(); 
}

Tuesday, November 13, 2012

Data Migration framework User guide and download

Data migration framework user guide:
http://technet.microsoft.com/en-us/library/jj225591.aspx

You can download the tool at Information source. Login using your partnersource account to download.
You can also look at the demo video on the link.

Friday, November 9, 2012

Importing conflicting models in AX 2012


Import an .axmodel file using Microsoft dynamics AX2012 Management shell:

Open the Microsoft dynamics AX2012 Management shell from Adminitrative tools.
At the command prompt, type the following command, and then press ENTER.
axutil import /file:<filename> 
This command installs the specified file in the same layer that it was exported from.

If the installation fails because of a conflict and still you want to import the model to resolve conflicts,you can rerun the command, and use the /conflict:push option to push the element that has the conflict to the related update layer. You can then resolve the conflict. 
axutil import /conflict:push /file:<filename> 

Friday, October 12, 2012

All X++ Editor shortcuts at one place in AX 2012

All X++ Editor shortcuts at one place in AX 2012


Breakpoints
Shortcut key
Remove all breakpoints. CTRL+SHIFT+F9
Insert or remove a breakpoint. F9
Enable or disable a breakpoint. CTRL+F9
Open the Breakpoints dialog. SHIFT+F9
   
Compilation and Help
 
Open the Scripts menu. Scripts icon
Open Help. F1
Show method parameter help. CTRL+SHIFT+SPACEBAR
Execute the current job. F5
Compile. F7
Compile and close a method. F8
Stop method execution (break). CTRL+BREAK
Insert a file. CTRL+ALT+H
Delete
 
Delete from the cursor to the end of the line. Use SHIFT+END to select to end of line and then DELETE
Delete word to the right of the cursor. CTRL+DELETE
Delete the word to the left of the cursor. CTRL+BACKSPACE
Delete the current line. CTRL+X (with cursor in line, no selection)
   
Edit
 
Insert script. <SCRIPT NAME>
Insert document header. ///
Comment selection. CTRL+E, C
Uncomment selection. CTRL+E, U
Convert selection to lowercase. CTRL+SHIFT+U
Convert selection to uppercase. CTRL+U
Display all methods and properties for a selected class. CTRL+SPACEBAR
Copy selection. CTRL+C (with text selected)
Copy line. CTRL+C (with cursor in line, no selection
   
Find and Replace
 
Open the Find dialog. CTRL+F
Open the Replace dialog. CTRL+R
Start incremental search.. CTRL+I
Move to next incremental search match in method. CTRL+I
Reverse the incremental search direction. CTRL+Shift+I
Remove a character from the incremental search string. BACKSPACE
Stop the incremental search. ESC
   
Go to
 
Go to a specific line. CTRL+G
Go to the next page. PAGE UP
Go to the previous page. PAGE DOWN
Go to the top of the code. CTRL+HOME
Go to the bottom of the code. CTRL+END
Go to the start of line. HOME
Go to the end of line. END
Move one word to the left. CTRL+LEFT ARROW
Move one word to the right. CTRL+RIGHT ARROW
Go to the method definition. F12
Go to the next error message. F4
   
Look up
 
Look up a label. CTRL+ALT+SPACEBAR
Show label text. CTRL+L
Look up a definition. F12
Show the syntax of a method or property. CTRL+SPACEBAR
   
Save
 
Save the selected text to a separate file. ALT+S
Close the current TAB, discarding all changes since the last save. F6
Close and save the current code editor window. F8
Close the current window. CTRL+F4
   
Select
 
Select all. CTRL+A
Cancel a selection. ESC
Select columns. ALT+MOUSE SELECT
Select a line. ALT+L
Select one word to the left. CTRL+SHIFT+LEFT ARROW
Select one word to the right. CTRL+SHIFT+RIGHT ARROW
Select text from the cursor to the start of the line. SHIFT+HOME
Select text from the cursor to the end of the line. SHIFT+END
Select the previous page. SHIFT+PAGE UP
Select the next page. SHIFT+PAGE DOWN
Select text from the cursor to the top of the code. CTRL+SHIFT+HOME
Select text from the cursor to the bottom of the code. CTRL+SHIFT+END
Indent the selected text. TAB
Remove indentation. SHIFT+TAB
Select area/column/block ALT+MOUSE SELECT
Cancel selection ESC
Show white space CTRL+SHIFT+S
   
Undo and Redo
 
Undo the last action. CTRL+Z (previous ten actions)
Redo the last action after an Undo. CTRL+Y (previous ten actions)

How to get Table field properties through X++ Code


Here is a job of how you can do that:

 

static void Job5(Args _args)

{

    TreeNode            vendFldsRoot = treeNode::findNode(@"\Data Dictionary\Tables\VendTable\Fields");

    TreeNodeIterator    vendFldsIterator;

    TreeNode            vendFlds;

    NoYes               visibleProp;

    ;

 

    vendFldsIterator = vendFldsRoot.AOTiterator();

    vendFlds = vendFldsIterator.next();

 

    while(vendFlds)

   {

        if(vendFlds.AOTgetProperty('Visible') == 'No')

        info(strfmt("field %1", vendFlds.treeNodeName()));

        vendFlds    =   vendFldsIterator.next();

    }

 

}

 

Thanks,
Swapna.

Thursday, October 11, 2012

Transaction integrity checking- TTS in Axapta

The database transactions in any system should be consistent and should have predictable results. There should be integrity or check whether we successfully completed our transaction. If the transaction causes and error/exception it must be able to roll back to the state before starting the transaction.
Below statements are used in X++ for the Transaction integrity checking:
  1. TTSBEGIN - This indicates beginning of a transaction.
  2. TTSCOMMIT - This indicates the successful completion of a transaction with out any errors and exceptions
  3. TTSABORT - This statement is used as an exception when something goes wrong in the trasaction. This statement rolls back the database transaction to the state before TTSBEGIN. This statement is automatically called by the system in case of exceptions.
AX keeps track of the Nested TTS statements by using a level counter which is incremented by one for each TTSBEGIN and decremented by one for each TTS COMMIT

Example for usage of TTS:
Custtable custTable;
;
ttsBegin;

select forUpdate custTable where custTable.AccountNum == '4000';
custTable.NameAlias = custTable.Name;
custTable.update();

ttsCommit;
 

Tuesday, October 9, 2012

Database Model Diagrams in Axapta

I am going to explain how to easily get Database Model Diagrams for set of tables you wish to in Axapta.
Here are the steps to do:
  1. Create a new Shared project.
  2. Drag all the tables you need for the datamodel diagram in to your project.
  3. Click Tools > Reverse Engineer. The Reverse Engineering dialog box displays
  4. In the dialog box, select ERX ER Data Model.
  5. Select the project you just created
  6. In the file name give correct path of windows location where you wish to create the .erx file.
  7. Click OK.
  8. Now go to Microsoft Visio
  9. Click File > New > Software and Database (or Database if you are using Microsoft Office Visio 2003) > Database Model Diagram
  10. On the Database menu, point to Import, and then click Import Erwin ERX file.
  11. In the dialog box, click the Browse button, navigate to the location of the .erx file that you generated from the Reverse Engineering tool, select the file, and then click OK.
  12. You will now see that tables you selected appear in Tables and Views window.
  13. Drag items from the Table and Views window onto the diagram surface. After you have added a table to the diagram, you can right-click the table in the diagram, and then click Show Related Tables. This will add all the related tables from the Tables and Views window that are not already in the diagram
You can then modify the diagram as you wish for the ease of understanding like you can delete the unecessary fields.

Exception types in AX2012


Exceptions in AX 2012

AX 2012 has an Exception system enum which cannot be modified. That means we cannot add any new exception types. AX throws these exceptions in following conditions.

Here are these types:

Exception Description

 

Info: Thrown when a message is sent to infolog. Developers should not throw this exception manually.

Warning: Thrown when something illegal has occurred which is non-fatal

Deadlock: Thrown when a database deadlock has occurred. Like when many transactions are waiting for one another.

Error: Thrown when something fatal error has occurred stopping all the transactions.

Break: Thrown when the user has pressed CTRL + C or Break during run time.

Internal: Thrown when something goes wrong with the development in run time.
DDEerror: Thrown when an error occurs in the DDE system class. DDE is Dynamic data exchange which is a inter process communication to exchange data between different applications.
Sequence: ????
Numeric: Thrown when a error occurs in a numerical functions.
CLRError: Thrown when an error occurs during the use of common language runtime functionality.
CodeAccessSecurity:  Thrown when a problem occurs during the use of CodeAccessPermission.demand.
(CodeAccessPermission.demand is used to check whether the permissions required to access an API is granted to the calling code.
UpdateConflict: Thrown when a record is updated using Optimistic concurrency control when the recVersion of buffer and database are not equal. The trasaction can be retried. (Use a retry statement in the Catch block)
UpdateConflictNotRecovered: Thrown when a transaction is not completed which is using Optimistic concurrency control. The transaction cannot  be retried.
 

 

Thursday, October 4, 2012

Swapna Kallu's Blog: InventDimGroupSetup in AX2012

Swapna Kallu's Blog: InventDimGroupSetup in AX2012: Here is a piece of code how you can get to know the dimension is active on your product or not in AX 2012. static void DimensionTest(Arg...

InventDimGroupSetup in AX2012


Here is a piece of code how you can get to know the dimension is active on your product or not in AX 2012.

static void DimensionTest(Args _args)
{
    InventTable inventTable;
    InventDimGroupSetup inventDimGroupSetup;
    InventDimGroupFieldSetup inventDimGroupFieldSetup;
    ;
    select * from inventTable where inventTable.ItemId == "Test";
    inventDimGroupSetup = InventDimGroupSetup::newInventTable(inventTable);
    inventDimGroupFieldSetup = inventDimGroupSetup.getFieldSetup(fieldNum(InventDim, WMSPalletId));
    if(inventDimGroupFieldSetup.isActive())
    info("Its active");
   
}

Tuesday, September 25, 2012

What is the difference between Yield and return?

Because investors are very concerned with how well their investments are performing or how they are expected to perform, knowing how to gauge such performance is essential. This makes understanding the difference between yield and return important. 

While both terms are often used to describe the performance of an investment, yield and return are not one and the same thing. Knowing what each measure takes into account and recognizing that each considers different time periods is key.

Return, also referred to as "total return", expresses what an investor has actually earned on an investment during a certain time period in the past. It includes interest, dividends and capital gain (such as an increase in the share price). In other words, return is retrospective, or backward-looking. It describes what an investment has concretely earned.

Yield, on the other hand, is prospective, or forward-looking. Furthermore, it measures the income, such as interest and dividends, that an investment earns and ignores capital gains. This income is taken in the context of a certain time period and then annualized, with the assumption that the interest or dividends will continue to be received at the same rate. Yield is often used to measure bond or debt performance; in most cases, total return will not be the same as the quoted yield due to fluctuations in price. 

Basic information on Products in AX 2012

Swapna Kallu's Blog: Understanding Product structure in AX 2012

Swapna Kallu's Blog: Understanding Product structure in AX 2012: Product structure information is a key aspect of producing a manufactured item.  The product structure is typically called a bill of mate...

Understanding Product structure in AX 2012


Product structure information is a key aspect of producing a manufactured item.  The product structure is typically called a bill of material (BOM) in the context of discrete manufacturing, and a formula in the context of process manufacturing.  These terminology differences have a special significance within Microsoft Dynamics AX 2012, since the production type assigned to a manufactured item (of BOM or Formula) impacts software functionality.  The terms BOM approach andformula approach will be used to differentiate the two approaches. 
This article focuses on process manufacturing scenarios, and how to choose between the BOM approach versus formula approach for modeling product structure.  Many scenarios can be modeled using either approach or a combination of the two approaches, so understanding the functional differences is key to making the right choice.   
The two approaches reflect the design history of Dynamics AX, which initially employed the BOM approach and subsequently added the formula approach.The formula approach supports additional functionality for addressing the requirements of process manufacturing, such as co/by-products, catch weight items, substitute ingredients and formula size considerations.  A combination of the two approaches can be used within one product structure, such as a BOM approach for a parent item and the formula approach for a manufactured component (and vice versa). 

OLTP vs. OLAP

 
OLTP vs. OLAP

We can divide IT systems into transactional (OLTP) and analytical (OLAP). In general we can assume that OLTP systems provide source data to data warehouses, whereas OLAP systems help to analyze it.


olap vs oltp


- OLTP (On-line Transaction Processing) is characterized by a large number of short on-line transactions (INSERT, UPDATE, DELETE). The main emphasis for OLTP systems is put on very fast query processing, maintaining data integrity in multi-access environments and an effectiveness measured by number of transactions per second. In OLTP database there is detailed and current data, and schema used to store transactional databases is the entity model (usually 3NF).

- OLAP (On-line Analytical Processing) is characterized by relatively low volume of transactions. Queries are often very complex and involve aggregations. For OLAP systems a response time is an effectiveness measure. OLAP applications are widely used by Data Mining techniques. In OLAP database there is aggregated, historical data, stored in multi-dimensional schemas (usually star schema).