Tuesday, 22 April 2014

Number Sequence - New module

Number Sequence - New module

 

New Number Sequence for new AX Module

1. Edit the baseEnum NumberSeqModule, adding a reference for your new module (Pre Purchase)

2. Create a new EDT say PurchaseRequisitionId which will be used in the module

3. Create new class say NumberSeqReference_PrePurchase that extends NumberSeqReference

The 3 methods in that class are:
//Class Declaration
public class NumberSeqReference_PrePurchase extends NumberSeqReference
{
}

//First method
protected void loadModule()
{
NumberSequenceReference numRef;
;
/* Setup PurchaseRequisitionId */
numRef.dataTypeId = typeid2extendedtypeid(typeid(PwC_PurchaseRequisitionId));
numRef.referenceHelp = literalStr("Unique key for Purchase Requisition identification. The key is used when creating new Purchase Requisitions."); // Use Labels here
numRef.wizardContinuous = true;
numRef.wizardManual = NoYes::No;
numRef.wizardAllowChangeDown = NoYes::No;
numRef.wizardAllowChangeUp = NoYes::No;
numRef.sortField = 1;
this.create(numRef);
}

//Second Method
static NumberSeqModule numberSeqModule()
{
return NumberSeqModule::PrePurchase; // Your Base Enum
}

4.Modify the NumberSeqReference Class for the following methods

Classes\NumberSeqReference\moduleList
Add the following code

// PrePurchase Begin

moduleList += NumberSeqReference_PrePurchase::numberSeqModule();

// PrePurchase End

Classes\NumberSeqReference\construct
Add the following code

// Pre Purchase addition begin

case (NumberSeqReference_PrePurchase::numberSeqModule()):
return new NumberSeqReference_PrePurchase(_module);

// Pre Purchase addition end

5. Create a parameters table and form
You should create a parameters table and form for your new module. The easiest way is generally to duplicate an existing Parameters table and modify it as required.
The important elements on the new parameter table are the numberSeqModule() and numberSeqReference() methods.

client server static NumberSeqModule numberSeqModule()
{
return NumberSeqReference_ PrePurchase::numberSeqModule();
}

client server static NumberSeqReference numberSeqReference()
{
return NumberSeqReference::construct(NSParameters::numberSeqModule());
}

In the parameters form, you must ensure that the code in the numberSeqPreInit(), numberSeqPostInit() and NumberSequenceType.executeQuery() methods correctly reflect your new number sequence elements.

And also add this code into this TableParameters
static client server NumberSequenceReference numRefSomeMethodID()
{
return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(Your EDT)));
}

6.Add this declaration in the form ClassDeclaration

public class FormRun extends ObjectRun
{
NumberSeqFormHandler numberSeqFormHandler;
}

7.Add this method to the form where you want Number sequences

NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler=
NumberSeqFormHandler::newForm(YourTableParameters::numRefSomeMethodID().NumberSequence,
element,
YourTable_DS,
fieldnum(YourTable,YourField));
}
return numberSeqFormHandler;
}

Create a new Number Sequence in BASIC module

Path : Basic / Setup / Numbersequnces / Numbersequnces
After Creating that , run the wizard.
Now open Your form to see the Number sequence.

Monday, 21 April 2014

if(LedgerJournalTable.PaymentRequest==NoYes::Yes)
   {
        LedgerJournalTrans_PaymentjournalID.enabled(true);
        JournalAmount.enabled(true);
    }
    else
        {
            LedgerJournalTrans_PaymentjournalID.visible(false);
           JournalAmount.visible(false);
         }

Tuesday, 1 April 2014

Display method

display Amount JournalAmount()
{
    Paymentrequest Paymentrequest;
    Paymentrequestline Paymentrequestline;

    select Paymentrequest where Paymentrequest.PaymentjournalID == this.PaymentjournalID;
    select sum(Amount) from Paymentrequestline where Paymentrequestline.JournalNum == Paymentrequest.JournalNum;
    return Paymentrequestline.Amount;
Default Currency  :

//AX 2009 
//Datasource   field name 
Cctrans.transcurrencycode = companyInfo::find().currencycode;
AX 2012 
Cctrans.transcurrencycode = companyInfo::standardcurrency();

                           Default  today  date: 

  Cctrans.transdata= today  

Thursday, 27 March 2014

Total amount display

display Amount totalAmount()
{
    SalesLine       salesLine;
    ;
    select sum(LineAmount) 
        from salesLine 
            where salesLine.SalesId == this.SalesId;
    return salesLine.LineAmount;
}

Wednesday, 26 March 2014

Table level display method

public void modifiedField(FieldId _fieldId)
{
    super(_fieldId);
    if(_fieldId == fieldNum(Paymentrequest, Name))
    {
        this.Descripation = LedgerJournalName::find(this.Name).Name;
    }
}

Monday, 17 March 2014

Type of Joins and Linked Type in AX 2009

Diffrent Type of Joins and Linked Type in AX 2009


Different type of Joins and Link Type

Car Table

CarId
ModelYear
CarBrand
Model
Mileage
ModelYear
CarId
CA101
2008
Mahindra
Scorpio
15
2008
CA101
CA102
2009
Suzuki
800
12
2009
CA102
CA103
2007
Hundai
i20
5
2007
CA103
CA104
2007
Toyato
Inova
3
2007
CA104
CA105
2009
BMW
 
5
2009
CA105
CA106
2010
Benz
AZ12
10
2010
CA106

 
Rental Table

RentalId
CustAccount
CarId
FromDate
ToDate


RE101
1104
CA101
10/12/2010
10/29/2010

RE102
1102
CA102
11/17/2010
12/14/2010

RE103
1203
CA103
11/24/2010
12/15/2010

RE104
1301
CA104
12/10/2010
1/5/2011


RE105
1304
CA101
1/3/2011
1/18/2011


RE108
1303
 
 
 
 
 
RE107
1202
 
 
 
 
 
RE106
2024
CA103
1/10/2011
1/29/2011




 
Inner Join

Select records from main table that have matching record form join table.

Main table record and join table records are joined together  and show as single record.

Code                                                                                                                                                   

static void JoinExamples(Args _args)                                                                                                      

{                                                                                                             

    CarTable carTable;                                                                                                      

    RentalTable rentalTable;                                                                                                          

    ;                                                                                                          

    while select carTable join rentalTable                                                                                                

        order by carTable.CarId                                                                                                        

        where carTable.CarId == rentalTable.CarId                                                                                                 

                                                                                                               

        {                                                                                                     

            info(strfmt("Car id is %1 renatla id is %2",carTable.CarId, rentalTable.RentalId));                                                                                                  

        }                                                                                                     

}

               
Output                                                                                 


Outer Join                                                                          

                                                                               

Select all the records from main table and related records from join table                                                                                                                                           

If there is no match, the field from join table is empty                                                                   

Code

while select carTable outer  join rentalTable                                                                                                       

        order by carTable.CarId                                                                                                        

        where carTable.CarId == rentalTable.CarId 

Output



Exists Join                                                                                                                                                                                          

Selecting record from main table only if there is matching record in join table.                                   

It shoul be return only main table record, not a related table record.                                                                      

Code

while select carTable Exists  join rentalTable                                                                                                       

        order by carTable.CarId                                                                                                        

        where carTable.CarId == rentalTable.CarId 

Output



 

Not Exists Join                                                                                                                                                                 

Selecting record from main table only if there is not matching record in join table.                           

It is directly irrelevant to the Exists join.                

Output                

           

 
Link Type:  Delayed

A pause is inserted before linked child data sources are updated. This enables faster navigation in the parent data source because the records from child data sources are not updated immediately.

Form Output



Form Design in Data Source Level:



 

Link Type: Active

The child data source is updated immediately when a new record in the parent data source is selected. Continuous updates consume lots of resources.

Link Type: Passive

Linked child data sources are not updated automatically. Updates of the child data source must be programmed on the active method of the master data source.

SQL/SSRS Interview questions I thought of blogging some SQL/SSRS interview questions.

Below are some. I will add more, when I complete the compilation 1. What is OLTP(Online Transaction Processing)? OLTP stands ...