6 Mayıs 2016 Cuma

AXAPTA - Sign function doesn't work correctly

Sign function doesn't work correctly in AX 2009 and 2012. It should returns -1 for negative numbers, 0 for zero and +1 for positive numbers. But  it gives -1 for negative and +1 for others.

Sign at Global:

static real sign(real num)
{
    return num >= 0 ? 1 : -1;
}


My correction:

static int sign(real num)
{

   if (num < 0)
    return -1;
   else
    return num > 0 ? 1 : 0;
}

5 Mayıs 2016 Perşembe

AXAPTA - Creating picking list

I created a class for me from found solution from a forum page :

class KRC_WMSOrder
{
    WMSShipment         wmsShipment;
    SalesTable          salesTable;
    WMSPickingRoute     wmsPickingRoute;
    WMSPickingRouteLink wmsPickingRouteLink;
    salesLine           salesLine;
}


void createOrderLine(Qty _qty = salesLine.RemainSalesPhysical)
{

    InventMovement                  inventMovement;
    WMSOrder                        wmsOrder;
    WMSOrderCreate                  orderCreate;
    WMSOrderTrans                   wmsOrderTrans;
    ;
    inventMovement = InventMovement::construct(salesLine);
    orderCreate = WMSOrderCreate::newMovement(inventMovement,_qty);
    orderCreate.parmMustBeWMSOrderControlled(true);
    orderCreate.parmQty(_qty);
    orderCreate.parmMaxQty(_qty);
    orderCreate.run();
    wmsOrder = orderCreate.parmWMSOrder();
    wmsOrder.updateShipment(wmsShipment,_qty, wmsPickingRoute.PickingRouteID);
}


void createWmsPickingRoute()
{
    ;
    wmsPickingRoute.clear();
    wmsPickingRoute.initTypeOrderPick(wmsShipment, WMSExpeditionStatus::Activated,
        WMSPickRequestTable::construct(salesTable),"", true);
    wmsPickingRoute.ActivationDateTime = DateTimeUtil::utcNow();
    wmsPickingRoute.insert();
}


void createWmsPickingRouteLink()
{
    ;
    wmsPickingRouteLink.clear();
    wmsPickingRouteLink.initFromSalesTable(salesTable);
    wmsPickingRouteLink.initFromWMSPickingRoute(wmsPickingRoute);
    wmsPickingRouteLink.insert();
}


void createWmsShipment()
{
    ;
    wmsShipment.clear();
    wmsShipment.initTypeOrderPick();
    wmsShipment.insert();
}


SalesLine  parmSalesLine(SalesLine _salesLine = salesLine)
{
    ;
    salesLine = _salesLine;
    return salesLine;
}


SalesTable  parmSalesTable(SalesTable _salesTable = salesTable)
{
    ;
    salesTable = _salesTable;
    return salesTable;
}


void reserveItem(Qty _qty = salesLine.RemainSalesPhysical)
{
    InventUpd_Reservation   invUpdReservation;
    ;
    invUpdReservation = InventUpd_Reservation::newInventDim(InventMovement::construct(salesLine,InventMovSubType::None),
        salesLine.inventDim(),_qty,false);
    invUpdReservation.updateNow();
}


Sample usage:

KRC_WMSOrder            kWMS = new krc_wmsorder();
kWMS.createWmsShipment();
;
ttsbegin;
kWMS.parmSalesTable(salesTable);
kWMS.createWmsPickingRoute();
kWMS.createWmsPickingRouteLink();
kWMS.parmSalesLine(salesLine);
kWMS.reserveItem();
kWMS.createOrderLine();

ttscommit;

AXAPTA - How to disable auto filter in a form came with args parameter

I found the solution from a forum page :


KRC_PlanWaves_DS.query().dataSourceNo(1).clearDynalinks();