Popular Posts

Wednesday, 6 July 2011

Ax Number Sequence Code

Ax Number Sequence


ClassDeclaration:
NumberSeqFormHandler    numberSeqFormHandler;
Close:
void close()
{
    if (numberSeqFormHandler)
    {
        numberSeqFormHandler.formMethodClose();
    }

    super();
}

numberSeqFormHandler:

NumberSeqFormHandler numberSeqFormHandler()
{
    if (!numberSeqFormHandler)
    {
        numberSeqFormHandler = numberSeqFormHandler::newForm(HPRPARAMETERS::numRefLeaveId().NumberSequence,
                                                             element,
                                                             HPRLEAVEAPPLTABLE_ds,
                                                             fieldnum(HPRLEAVEAPPLTABLE,LeaveId));
    }
    return numberSeqFormHandler;
}

ValidateWrite:   At DataSource Level

public boolean validateWrite()
{
    Boolean ret;

    ret = super();

    if (ret && !element.numberSeqFormHandler().formMethodDataSourceValidateWrite())
    {
        ret = false;
    }


    return ret;
}

LinkActive:   At DataSource Level
public void linkActive()
{
    element.numberSeqFormHandler().formMethodDataSourceLinkActive();
    super();
}


Write: At DataSource Level

void write()
{
    ;
    ttsbegin;

    element.numberSeqFormHandler().formMethodDataSourceWrite();

       super();

    ttscommit;
}
Delete: : At DataSource Level

void delete()
{
    ttsbegin;

    element.numberSeqFormHandler().formMethodDataSourceDelete();

    super();

    ttscommit;
}
Create:  At DataSource Level

void create(boolean append = false,
            boolean extern = false)  // If created externally
{;
    super(append);

    if (!extern)
    {
        element.numberSeqFormHandler().formMethodDataSourceCreate();
    }
}



Open NumberSeqReference_Production class and go to load module

    numRef.dataTypeId              = typeId2ExtendedTypeId(typeid(ProdId));
    numRef.referenceHelp           = literalstr("@SYS53760");
    numRef.wizardContinuous        = true;
    numRef.wizardManual            = NoYes::No;
    numRef.wizardAllowChangeDown   = NoYes::No;
    numRef.wizardAllowChangeUp     = NoYes::No;
    numRef.sortField               = 1;
   
    this.create(numRef);

Go to ProdParameters and add following method

static client server NumberSequenceReference numRefNum()
{
    return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(ProdId)));
}

AX Finance Module Vedios

Tuesday, 5 July 2011

Difference Between Array and Container

Difference Between Array and Container :
Array : 1.In this array are single dimension. 
             2.You can define array in only single data type.
Containers:1.To avoid single dimension to use Containers.
                    2.To define in containers use multiple datatypes.

Excel creation through x++

Excel Creation Through X++
static void ExportingFields4mCustTable(Args _args)
{
    CustTable CustTableLocal;
SysExcelApplication excelApp;
SysExcelWorkSheet excelWorksheet;
SysExcelRange excelRange;
SysExcelCells excelCells;
SysExcelCell excelCell;
ComVariant cellValue;
Int i=1;
;
excelApp = SysExcelApplication::construct();
cellValue = new ComVariant() ;
excelApp.workbooks().add();
excelWorksheet = excelApp.worksheets().itemFromNum( 1 );
excelCells = excelWorksheet.cells();
while select * from CustTableLocal
{
excelCells.item(i+4,4).value(cellValue.bStr(CustTableLocal.AccountNum));
excelCells.item(i+4,5).value(cellValue.bStr(CustTableLocal.Name));
i++;
}
excelApp.visible(true);

}

Sunday, 3 July 2011

To Leave On First Record In Table

To Leave On First Record In Table :
static void Job5(Args _args)
{
    InventTable inventTable, inventTable2;
    ;
    select firstonly inventTable2;
    while select inventTable
        where   inventTable.RecId != inventTable2.RecId
    {
        info(strfmt('Item No. = %1',inventTable.ItemName));
    }

}

Thursday, 30 June 2011

Pack & UnPack


Pack and unpack
Pack
this method is a standard method inherited from RunBase. It is used to save
the values that the user selects and store them until the next time the user executes
the class.
Public container pack ()
{
return [#CurrentVersion, #CurrentList];
}

===
unpack
Standard method inherited from RunBase and used to fetch the values that the user
selected the previous time he executed the class.
public boolean unpack(container packed Class)
{
Version version = RunBase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:
[version, #CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}

Indexes


Indexes:
                 In unique index u put in 2 or more fields it validates 2 fields and 2 rows are same it shows error otherwise if one filed allows duplicate values.