24 Haziran 2016 Cuma

AXAPTA - Clear left open QTY's at a transfer order

If a transfer order haven't got completed and that left QTY's related with an output order and reserved, Functions->Deliver remainder->Cancel quantity button will not work. It'll get an error about "there's not enough QTY with ordered" and quit. It's about that QTY reserved with output order and can't unreserve (At least I couldn't a way) direct with one line code. If you even unreserve from menu, relation will still stay and you'll get that error again. In first tie with output order should be break. I couldn't a way break relation with standart code and found this way, it seem works:

    InventTransferTable header;
    InventTransferLine  line;
    WMSOrderTrans       orderTrans;
    InventTrans         inventTrans;
    ;
    while select header
            where header.TransferId == myTransferId
        join forupdate line
            where line.TransferId == header.TransferId &&
                  (line.QtyRemainReceive > 0 || line.QtyRemainShip>0) 

    {
        ttsbegin;
        while select orderTrans
            where orderTrans.inventTransId == line.InventTransId &&
                  orderTrans.expeditionStatus != WMSExpeditionStatus::Complete &&
                  orderTrans.expeditionStatus != WMSExpeditionStatus::Cancelled &&
                  orderTrans.expeditionStatus != WMSExpeditionStatus::CancelledSW
        {
            WmsPickingLineCancel::newWMSPickingLineCancel(orderTrans).run();
        }
        while select forupdate inventTrans
            where (inventTrans.StatusIssue == StatusIssue::ReservPhysical ||
                   (inventTrans.TransChildRefId != "" &&
                    inventTrans.TransChildType == InventTransChildType::WMSOrder) ) &&
                  inventTrans.InventTransId == line.InventTransId
        {
            inventTrans.TransChildRefId = "";
            inventTrans.TransChildType = InventTransChildType::None;
            inventTrans.update();
            InventUpd_Reservation::newInventDim(InventMovement::construct(inventTrans,InventMovSubType::None),
                inventtrans.inventDim(),2,false).updateNow();
        }
        line.QtyRemainReceive = 0;
        line.QtyRemainShip    = 0;
        line.AutoReservation = NoYes::No;
        line.update();
        ttscommit;
    }

8 Haziran 2016 Çarşamba

AXAPTA - Cancel a WMS picking list or cancel line of picking list

Cancel whole list:
 
WMSPickingRouteCancel::newWMSPickingRoute(wMSPickingRoute).run(); 

Cancel a line:

WMSPickingLineCancel::newWMSPickingLineCancel(wMSOrderTrans).run(); 

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();

24 Mart 2016 Perşembe

AXAPTA - Solve of turkish letter problem when send mail with sysmailer class

I found this solution from a blog which I cannot remember. Turkish letters (or another special letters with some languages) will not shown when send mail with sysMailer class if you won't add this red line:


   SysEmailParameters  parameters;
    SysMailer           mailer;
    ;
    new InteropPermission(InteropKind::ComInterop).assert();
        parameters = SysEmailParameters::find();

        mailer = new SysMailer();
        if (parameters.SMTPRelayServerName)
        {
            mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
                               parameters.SMTPPortNumber,
                               parameters.SMTPUserName,
                               SysEmailParameters::password(),
                               parameters.NTLM);
        }
        else
        {
            mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
                               parameters.SMTPPortNumber,
                               parameters.SMTPUserName,
                               SysEmailParameters::password(),
                               parameters.NTLM);
        }
        mailer.fromAddress(fromAddr);
        mailer.tos().appendAddress(toAddr);
        mailer.subject(subject);
        //solution for turkish letter problem (ÖöÇçĞğÜüŞşİı):
        mailer.bodyCharSet("Windows-1254");
        if(FileName)
            mailer.attachments().add(FileName);
        mailer.ccs().appendAddress(ccAddr);
        mailer.bccs().appendAddress(bccAddr);
        mailer.htmlBody(body);
        mailer.sendMail();
    }
    CodeAccessPermission::revertAssert();

2 Mart 2016 Çarşamba

AXAPTA - Find a table fields label value

There are two ways to find a table field's label value:

If fields label value derived from directly fields extended data type:
 
    if (curext()=="krc" && this.RBOInventItemGroupId == "")
        ret = checkfailed(strfmt("'%1' field cannot be empty!..",
            new SysDictType(extendedTypeNum(RBORetailGroupId)).label()));

If there is a special label value dedicated at table level:

    if (curext()=="krc" && this.RBOInventItemGroupId == "")
        ret = checkfailed(strfmt("'%1'
field cannot be empty!..",
            new SysDictField(tablenum(WholeSalesCampaignGroup),
fieldnum(WholeSalesCampaignGroup,RBOInventItemGroupId)).label()));