Wednesday, December 17, 2014

Indexes In Microsoft Dynamics Ax 2012

INDEXES

Indexes are used for faster retrieval of data. Also helps to organize /reorganize data at database level.

There are three types of indexes at database level

1. Primary Index

2. Clustered Index

3. Non Clustered Index


Primary Index
Primary Index is used/helpful in mainting unique records and only works on a single field.

ex: Primary key of a table can be created by using primary index.In this case the records are retrieved in faster way from a table when compared with a table which is not having a primary index.




Clustered Index
Clustered Index is used/helpful in mainting the order of data insertion at the table(database level).

ex: Default clustered index is taken as surrogate key(rec id), in this case the records are stored in recid unique number order. If some string field is selected as a clustered index in a table then the records are stored/Inserted in alphabetic order of that string field.





Non Clustered Index
Any table which is created neither with primary nor clustered Index are called as non clustered index.






FULL TEXT INDEX
Full Text Index is used only on a string data type.It helps to index each and every word into a sentence.

ex: If we take a clustered index for a string column which is having a size of 100. And lets enter a data like "My Country Is Best". Then the data is inserted and saved in a alphabetic order. And if i search for a keyword "my" then i'll get result very fast as it is already indexed with alphabetic order. What if i search for "Country" or "Is" or "Best". I'll get the result but my execution time is at toss. It may take time for normal databases, but in sqlserver 2008 if a column is a full text index then each and every word of string column is considered as a sentence, and every word is indexed as a result if we search for any word which is in middle of the paragraph also will be fetched very fast.

Sunday, December 15, 2013

Number Sequences In Microsoft Dynamics AX 2012

Number Sequences in Dynamics AX are used to generate unique identifiers for master data records or transaction data records that requires identifiers. And that identifier is referred to as a reference.

Number Sequences can be alphanumeric values like 'ABC123'. So in order to maintain this alphanumeric value as a unique identifier we use number sequences to display in required manner.

step 1  :   Create a new string EDT, Give the name and label as 'SampleAcNoSeq' for that edt.

step 2  :   Create New Table ,drag and drop the created string edt to the table,along with new field 'city'.

step 3  :    Go to Organization Administrator in client session,
                  common--number sequences--number sequences.



step 4   :    Give the number sequence code and name , in scope parameter declare the company where it is to be saved,and in segments give the constant value as the required format in what we want to show our number sequence.

step 5   :     If we want to use this number sequence in general ledger module then go to the
                   classes --> NumberSeqModuleLedger --> Load Module

    datatype.parmDatatypeId(extendedTypeNum(SampleAcNoSeq));
    datatype.parmReferenceHelp(literalStr("SampleAcNoSeq"));
    datatype.parmWizardIsContinuous(true);
    datatype.parmWizardIsManual(NoYes::No);
    datatype.parmWizardIsChangeDownAllowed(NoYes::No);
    datatype.parmWizardIsChangeUpAllowed(NoYes::No);
    datatype.parmWizardHighest(999999);
    datatype.parmSortField(10);
    datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
    this.create(datatype);

step 6   :    Write a job to update all the modules to synchronize the labels,edts and objects.

NumberSeqApplicationModule::loadAll( );

step 7   :     Now Restart the Client and as we want to create number sequence in general ledger then go to general ledger module --> setup --> general ledger parameters --> Number Sequences


you will find the reference as our edt name and number sequence code must be given there from filter.

step 8   :    Create a form and add the table which we created earlier after that drag and drop the fields to the design of the form.

step 9   :    declare

NumberSeqFormHandler numberSeqFormHandler;

in class declaration and then create a new method.

step 10   :  Create a Number Sequence Form Handler method(form method) and name it as 'numberSequenceFormHandler' and write the following code

NumberSeqFormHandler numberSeqFormHandler()
{
    if (!numberSeqFormHandler)
        numberSeqFormHandler = NumberSeqFormHandler::newForm(NumberSeqReference::findReference(extendedtypenum(SampleAcNoSeq)).NumberSequenceId,
                                                             element,
                                                             SampleNumberSequenceTable_DS,
                                                             fieldNum(SampleNumberSequenceTable,SampleAcNoSeq)
                                                            );
    return numberSeqFormHandler;
}

step 11   :    Now override the form datasource methods with 
create,write,validatewrite,delete

create:

public void create(boolean _append = false)
{
    element.numberSeqFormHandler().formMethodDataSourceCreatePre();
    super(_append);
    element.numberSeqFormHandler().formMethodDataSourceCreate();

}

write:

    ttsbegin;
    super();
    element.numberSeqFormHandler().formMethodDataSourceWrite();
    ttscommit;

validatewrite:

    boolean ret;
    ret = super();
    ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret) && ret;
    return ret;

delete:

    element.numberSeqFormHandler().formMethodDataSourceDelete();
    super();

step 11:  open the form and you can see the number sequence in the 'SampleAcNoSeq' field.

Tuesday, December 10, 2013

How to Update a record using Update command , difference between update and doupdate methods.

UPDATE


ttsbegin;

select forupdate table15
          where table15.Acno  =  "345";

table15.Amt = 555;
table15.Update( );

ttscommit;


ttsbegin & ttscommit are used for one record to insert/update/delete.


doUpdate

If a update method is overriden at the object level then at the time of update command execution then the value given in the update method is executed.
And if u want to update the value which was given in the update command at any cost then we use doinsert( ) so that the values are not validated and inserts the value to database.

ttsbegin;

select forupdate table15
          where table15.Acno  == 345;

table15.Amt = 555;
table15.doUpdate( );

ttscommit;

Monday, December 9, 2013

Difference Between Insert and doInsert In Dynamics ax 2012

For normal insertion of data into database How To Insert Data into Database Using Insert Command .

doInsert

If a Insert method is overridden in the table level giving the direction to insert a default value for amount as 150.00, then whatever data u insert with above code then the amount data will be 150 only.
But if you want to insert data bypassing the overriden method then we use doInsert().

1.Right Click on method(object level)
2.override method --> insert.
3.this.Amount = 150;

table15 tb15;
;

tb15.id            = 101;
tb15.name      = "naresh;
tb15.Amount  = 125.00;
tb15.doInsert();

In this case the inserted data will be 125.00 as amount because the doInsert( ) overrides the insert method at the object level and takes 125 as input.

How To Insert Record Into Database Using Insert Command

Create a new table with three fields,

table name      table15

1. id                 int
2. name           sring
3. Amount       real

INSERT

Take a new job,

Table15 tb15;
;

tb15.id = 101;
tb15.name = "naresh";
tb15.Amount = 100.00;

tb15.Insert();

execute the job and you can see the data is inserted into database using the Insert Command.

Tuesday, December 3, 2013

Communication Tools In Microsoft Dynamics Ax 2012

There are mainly 4 types of communication tools in dynamics ax 2012 they are,

1. Print

2. Box

3. Info

4. Dialog


PRINT

Pass any datatype in this print method , it will print on the output screen.






BOX

1. Boxes are used to take the defined inputs.
2. For all boxes the base class is 'Box'.
3. All types of box Methods are denoted by static methods inside Box class.
4. Boxes which have yes,no,cancel button then their return type is "Dialogbutton" baseenum.
5. ok , cancel, oncemodal  return type is "Boolean".






Below are the methods that contain in the 'Box' class




INFO

1. Only displays string as a result.
2. for displaying any other type of data we use 'strFmt( )' method to typecast anything to a string.
3. Info does not allow inputs from the user. Its for view purpose only.






DIALOG

1. Any Input to put from a keyboard , and based on data the program to execute then we go for dialog.
2. Its Class Name is 'Dialog'.
3. It is a Class which has more number of static and object classes.