Monday, July 29, 2013

pack and unpack

The pack method must be able to read the state of the object and return it in a container. Reading
the state of the object involves reading the values of the variables needed to pack and unpack the
object. Variables used at execution time that are declared as member variables don’t have to be
included in the pack method. The first entry in the container must be a version number that identifies
the version of the saved structure.
container pack()
{
return [#CurrentVersion, #CurrentList];
}
Where #CurrentList is defined as:
#LOCALMACRO.CurrentList
TransDate,
Specification,
ProdJournal,
UpdateLedger,
#ENDMACRO

To run the business operation job on the server and push the dialog box to the client. When the job is initiated, it starts on the server, and the RunBase framework packs the internal member variables and creates a new instance on the client, which then unpacks the internal member variables and runs the dialog box.

On the client side, When the user clicks OK in the dialog box, RunBase packs the internal member variables of the client instance and unpacks them again in the server instance.

Friday, July 19, 2013

Client and Server Side Report

The MorphX framework is a proprietary client-side solution that is fully integrated
into the Microsoft Dynamics AX integrated development environment (IDE). In this model,
reports contain references to data sources that are bound to local Microsoft Dynamics AX tables and
views. They also define the business logic.

SSRS for Microsoft Dynamics AX, is a server-side reporting solution.
This framework takes advantage of an industry solution that offers comprehensive reporting
functionality for a variety of data sources. This platform includes a complete set of tools that you can
use to create, manage, and deliver reports. With SSRS, you can create interactive, tabular, graphical,
or free-form reports from relational, multidimensional, or XML-based data sources.

Thursday, July 18, 2013

Debug C# from code editor

1. Create a Class library project,
2. Add to AOT
3. Deploy to AOS
4. Create a client class

http://msdn.microsoft.com/en-us/library/hh129886.aspx

Update to Scheduling and Resource Assignment

           ttsBegin;
            psaActivitySetup = PSAActivitySetup::findActivityNumber(myActivityNumber);
            while select forUpdate psaActivitySetup
                    where PSAActivitySetup.ActivityNumber == myActivityNumber
            {
                psaActivitySetup.PSASchedStart = _startDate;
                psaActivitySetup.PSASchedEnd = dateMthFwd(_startDate, 1);
                psaActivitySetup.update();  
            }
            ttsCommit;

Wednesday, July 17, 2013

DateTime

    UTCdatetime startDate;
   
    startDate= DateTimeUtil::newDateTime(systemDateGet()+1,timenow());
    info(strFmt("%1", startDate));

   UTCdatetime datetimeTo;   
   datetimeTo = DateTimeUtil::addDays(_startDate,1);

    activities.ActivityNumber = smmParameters::getNumber(smmNumbSeqUsed::Activity);
                activities.Purpose =  _activityNum;
                activities.ResponsibleWorker = _worker;
                activities.StartDateTime = _startDate;
                activities.EndDateTime = datetimeTo;
                activities.insert();

Thursday, July 11, 2013

(Sub)Project

static void SR_CreateProjects_subProjects(Args _args)
{
ProjInvoiceTable projInvoiceTable;
ProjTableType projTableType;
NumberSeq projNumberSeq;
ProjId projIdLastSon, projectId;
ProjTable projTable;
ProjId projMask;
Integer sonNum;
ProjType _projType = ProjType::TimeMaterial;
ProjGroupId _projGroupId = ‘TM1′;
ProjName _projName = “Construction – Prj”;
ProjInvoiceProjId _projInvoiceProjId = ’100104′;
ProjParentId _projParentId = ’121′; // define parent project here
NumberSequenceFormat _numberSequenceMask;
ProjLinePropertyId _projInvoiceStatusId;
;
if (_projParentId)
{
projTable.type().initFromParent(_projParentId);
projIdLastSon = ProjTable::projIdLastSon(projTable.ParentId);
if (projIdLastSon)
{
projMask = substr(projIdLastSon, strlen(projTable.ParentId) + 1, (strlen(projIdLastSon) – strlen(projTable.ParentId) + 1));
sonNum = ProjTable::numRemTemplate(projMask, ProjTable::find(projTable.ParentId).Format);
}
projTable.ProjId = projTable.ParentId + NumberSeq::numInsertFormat(sonNum + 1, ProjTable::find(projTable.ParentId).Format);
}
else
{
projNumberSeq = NumberSeq::newGetNum(ProjParameters::numRefProjId(), true);
if (projNumberSeq)
{
projTable.ProjId = projNumberSeq.num();
}
}
projectId = projTable.ProjId;
projTable.Type = _projType;
projTable.ProjGroupId = _projGroupId;
projTable.Name = _projName;
projTableType = projTable.type();
projTableType.initProjTable();
projTable.ProjInvoiceProjId = _projInvoiceProjId;
projInvoiceTable = ProjInvoiceTable::find(_projInvoiceProjId);
projTable.CustAccount = projInvoiceTable.InvoiceAccount;
projTable.initFromInvoice(projInvoiceTable);
projTable.Format = _numberSequenceMask;
projTable.CheckBudget = ProjGroup::find(_projGroupId).CheckBudget;
if (_projInvoiceStatusId)
{
ProjLinePropertySetup::updateLinePropertyProj(projTable.ProjId, _projInvoiceStatusId, TableGroupAll::Table, true);
}
projTable.initFromCustTable(CustTable::find(projTable.CustAccount));
if (ProjTable::exist(projTable.ProjId))
{
// Project already exists.
throw error(“@SYS56494″);
}
if (!projTableType.validateWrite())
throw error (“Validations failed”);
projTable.insert();
if (projNumberSeq)
{
projNumberSeq.used();
}
else
{
projTable.clear();
if (projNumberSeq)
{
projNumberSeq.abort();
}
}
info (strfmt(‘Project %1 successfully created ‘, projectId));
}

Tuesday, July 9, 2013

Calculate Code Execution Time

static void GetExecutionTime(Args _args)
{
    int start;
    int end;
    int i;
    start = WinAPI::getTickCount();
    for (i = i; i <= 1; i++)
    {
        sleep(1000); // pause for 1000 milliseconds
    }
    end = WinAPI::getTickCount();
    info(strFmt("%1", end - start));
}

Saturday, July 6, 2013

Store Dimension Attribute Value

static void XXXX(Args _args)
{
    DimensionAttribute dimAttr;
    DimensionAttributeValue dimAttrValue;
    Name dimName;
    Name dimValue;
    Common                          common;
    DictTable                       dictTable;
    Map dimSpec;
    dimName = "Department";
    dimValue = "025";
   
     dimSpec =
        DimensionDefaultingEngine::createEmptyDimensionSpecifiers();
   
    dimAttr = DimensionAttribute::findByName(dimName);
   
    dictTable = new DictTable(dimAttr.BackingEntityType);
    common = dictTable.makeRecord();
  
    select firstonly common where common.(dimAttr.ValueAttribute) == dimValue;
    if (common)
    {
        dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndEntityInst(
            dimAttr.RecId, common.(dimAttr.KeyAttribute),
            false, false);
       
        info(strFmt("%1", common.(dimAttr.ValueAttribute)));
    }
   
}

Find or Create Attribute Value
    select firstonly
            dimensionAttributeValue
        where
            dimensionAttributeValue.DimensionAttribute == _dimensionAttribute
            && dimensionAttributeValue.EntityInstance == _entityInstance
            && dimensionAttributeValue.IsDeleted == false;
    // Create value if specified and not currently existing
    if (!dimensionAttributeValue && _createIfNecessary)
    {
        ttsbegin;
        dimensionAttributeValue.DimensionAttribute = _dimensionAttribute;
        dimensionAttributeValue.EntityInstance = _entityInstance;
        dimensionAttributeValue.insert();
        dimensionAttributeValue.selectForUpdate(_forUpdate);
        ttscommit;
    }

Wednesday, July 3, 2013

Periodic Journal

Create a Journal name, with journal type as "Periodic", such as RentExp. optional with an offset account.

From General Ledger, Periodic, Journals, Periodic Journals, create a new periodic journal.
during creation, select journal name: RentExp created on step1.
From "Lines", enter line info.

From General Ledger, Journals, General Journals, create a new GJ. Pick up name as: GerJrn, go to "Lines", From Periodic Journal, Retrieve Journal. Then "Post".