Sunday, December 8, 2013

How to get all the planned orders for a particular demand. in Ax2012

When we create a sales order in Ax. Basically we are creating demand in system and when we run scheduling in system it generates the planned production or purchase orders.


Following is the step by step process.

·         Create sales order. And check the explosion from salesline->Product and supply. Initially there are no planned orders. So there is no record in explosion.



·         Check the explosion from salesline

·         Now run the planning from Master planning ->Periodic->Master scheduling

·         Check the explosion from sales line

·         If we want to get all the planned production orders detail we can get it through following x++ code. We can get top level planned order from REqPo table where on the basis of pegging reference of sales order we can find top level planned production order. We can use that planned order as a parameter in a method and retrieve all the lower level orders.

private void doUpdateReferences(reqPo   _reqPo)
{
    ReqTransExplode         reqTransExplode;
    Map                     mapReqTransLocal;
    MapEnumerator           enumerator;
    container               conMapReqTrans;
    Map                     mapReqTrans;
    reqTrans                reqTrans;
    ReqPO                   reqPo = _reqPo;
    Map                     plannedOrderMap = new Map(Types::Int64, Types::Record);
   
    ;

    while (reqPo)
    {
        if (!plannedOrderMap.exists(reqPo.RecId) )
        {

           reqTransExplode = reqTransExplode::newReqTrans(reqPo.reqTrans(),ReqExplodeType::Down,true);
           reqTransExplode.run();

            conMapReqTrans = reqTransExplode.packMapReqTrans();

mapReqTransLocal    = (conMapReqTrans)  ? Map::create(conMapReqTrans) : new    Map(typeName2Type(extendedtypestr(recId)), Types::Record);

            mapReqTrans = new Map(typeName2Type(extendedtypestr(recId)), Types::Record);
            enumerator = mapReqTransLocal.getEnumerator();
            while(enumerator.moveNext())
            {
                reqTrans = reqTrans::findRecIdCrossCompany(enumerator.currentKey());
                if (reqTrans.RefType == ReqRefType::BOMPlannedOrder)
                {
                    Info(reqtrans.reqpo().refid);
                }
            }
        }

        next reqPo;
    }

}













Monday, February 20, 2012

RPC Server Is Unavailable.



Yesterday I was working on Ax reports. And suddenly a message occured .
RPC server is unavailable when I was trying to open report even AOT.

Then I found "Print Spooler" service was stoped. So I started that service and My ax application was working fine.

Thursday, December 8, 2011

By in group by is optional

public static void GroupBy(Args _args)
{
InventTable inventTable;
while select inventTable
group by itemGroupid
{
info(inventtTable.itemGroupId);
}
while select inventTable
group itemGroupId
{
info(inventTable.itemGroupId);
}

}

Here both will give same output. Really funny.

Saturday, May 7, 2011

Thursday, March 10, 2011

How to identify unused labels in application

We often creates labels in our development environment and we not use the labels.Following is a job to identify unused labels in application .

Here my label file is IFC

static void I4C_UnusedLabels(Args _args)
{
str 50 labelId;
int i;
int maxLabel = 2000;
xRefNames names;
XRefReferences ref;

str info = "LabelId#LabelStr\n"
;

while (i <= maxLabel) {
labelId = "@IFC" + int2str(i);
// The particular label file.
select recid from names
where names.Name == labelid
exists join ref
where names.RecId == ref.xRefNameRecId;

if (! names.RecId)
{
info += strfmt("%1#%2\n", labelId,
SysLabel::labelId2String(labelId));
}

i++;
}

}