dinsdag 28 september 2010

Form - Adding Dimensions to Grid

See example in http://bmdax.blogspot.com/2010/09/adding-dimension-display-button-to-form.html

Form - Temporary Table datasource - loop over data

How to loop over the data in a datasource that is a Temporary Table?

See method \Forms\CustVendTransReorg\Methods\reorganize
This form has a DataSource "TmpCustVendTransReorg" that points to temporary table "TmpCustVendTransReorg"

void reorganize()
{
    TmpCustVendTransReorg   tmpCustVendTransReorgLocal;
    ;
    ttsbegin;
    for (tmpCustVendTransReorgLocal = tmpCustVendTransReorg_ds.getFirst();
         tmpCustVendTransReorgLocal;
         tmpCustVendTransReorgLocal = tmpCustVendTransReorg_ds.getNext())
    {
        custVendTransReorg.reorganize(tmpCustVendTransReorgLocal);
    }
    custVendTransReorg.end();
    ttscommit;
}

Adding Dimension Display Button to Form

You have to add the InventDim datasource to your form,
and add a display menuItemButton: \Menu Items\Display\InventDimParmFixed

To get the menuItemButton working, see the following methods in \Forms\InventItemBarcode
classDeclaration
updateDesign
init
inventDimSetupObject

Pay attention to the methods on both datasources
to guarantee a correct functioning of InventDim !!


For general Dimension editing, use InventDimCtrl_Frm_EditDimensions in the updateDesign method.
If you use i.e. InventDimCtrl_Frm_ItemBarcode, then the mustEnableField method on that class will only allow the ItemDimensions to be enabled.

vrijdag 17 september 2010

Bill of Material : BOMTable - BOMVersion - BOM

BOMTable
The BOMTable table contains all the bills of materials.
A bill of material is connected to a site and an item group.
For each bill of material the information whether it has been approved and by whom is stored.

BOMVersion
The BOMVersion table contains all bill of materials versions.
It connects to the BOMTable table in order to specify to which bill of materials the version refers
and it connects to the InventTable table in order to specify to which item the BOM version is assigned.
The BOMVersion table also connects to the InventDim table in order to specify a site for the BOM version.
Additionally the BOMVersion table stores information regarding approval and activation for each BOM version.

BOM
The BOM table contains bill of materials lines.
A BOM line connects to an item which is to be consumed and a BOM version to which the line applies.


TablePrimary Key
BOMTableBOMId
BOMVersionBOMId, ItemId, RecId
BOMBOMId, LineNum, RecId




BOMTable
|
|
^
BOMVersion
|
|
^
BOM


Sources:
BOMTable http://msdn.microsoft.com/en-us/library/aa672428.aspx
BOMVersion: http://msdn.microsoft.com/en-us/library/aa630970.aspx
BOM http://msdn.microsoft.com/en-US/library/aa844882.aspx

Axapta Filename Extension Naming Conventions

See http://daxcoder.blogspot.com/2008/06/axapta-filename-extension-naming.html

Ax*.123

The first letter represents the owner of the file.
A: Application
K: Kernel

The second letter represents the contents of the file.
L: Label
O: Object
T: Text
D: Developer Documentation
H: Online Help

The third letter represents the type of file.
D: Data
I: Index
C: Cache
T: Temporary

Get current DateTime

Getting current system datetime:

DateTimeUtil::getSystemDateTime();

Getting current date:
SystemDateGet();

DateTimeUtil::getSystemDateTime

Use DateTimeUtil::getSystemDateTime instead of systemDateGet or today.
The today function uses the date of the machine.
The systemDateGet method uses the system date in Microsoft Dynamics AX.
Only DateTimeUtil::getSystemDateTime compensates for the time zone of the user.
Source: http://msdn.microsoft.com/en-us/library/aa605545.aspx

dinsdag 14 september 2010

Post packing slip for a single sales line

public void aduAutoPostPackingSlip(SalesLine            _salesLine,
                                   ADUPostPackingSlip   _aduPostPackingSlip = NoYes::No)
{
    SalesFormLetter salesFormLetter;
    SalesLine       salesLineLocal;
    SalesLine       salesLineUpdate;
    ;

    if (_aduPostPackingSlip == NoYes::Yes && _salesLine)
    {
        ttsbegin;
        salesLineLocal = SalesLine::findRecId(_salesLine.RecId, true);

        if (salesLineLocal)
        {
            //On beforehand (before salesFormLetter.update) set all salesLines of the order, except your line, to sales+inventdelivernow = 0
            //so that you don't accidentally post the delivernow data of another user on you packingslip.
            //this overwrites the existing data of the other users, but this is no problem, since this is data that is usually processed immediately.
            update_recordset salesLineUpdate
                setting      SalesDeliverNow = 0,
                             InventDeliverNow = 0
                where        salesLineUpdate.SalesId == salesLineLocal.SalesId
                          && salesLineUpdate.RecId != salesLineLocal.RecId;

            salesLineLocal.SalesDeliverNow = salesLineLocal.SalesQty;
            salesLineLocal.setInventDeliverNow(); //inventDeliverNow must be filled, otherwise the posting will fail
            salesLineLocal.update();
        }
        ttscommit;

        salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip);
        salesFormLetter.update(_salesLine.salesTable(),
                               systemdateget(),
                               SalesUpdate::DeliverNow,
                               AccountOrder::None,
                               NoYes::No,
                               NoYes::No);
    }
}


See also http://www.mibuso.com/forum/viewtopic.php?p=98005

vrijdag 10 september 2010

Dimension active?

Method on InventTable

public boolean isConfigIdActive()
{
    InventDimSearch dimSearch = new InventDimSearch();
    ;
    if (dimSearch.find(this.DimGroupId,fieldnum(InventDim,ConfigId)))
        return dimSearch.dimActive();
    return false;
}