Supply Chain Management in Dynamics AX

This blog contains information and feedback on the Supply Chain Management area in Microsoft Dynamics AX

Picking update via .Net Business Connector

Picking update via .Net Business Connector

  • Comments 1

We have received extensive feedback on previous blog postings about the outbound processes within Inventory management in Microsoft Dynamics AX. Many readers have requested information on how to interact with Microsoft Dynamics AX via .NET Business Connector to create picking operations.

With this technical posting we will try to demonstrate how easy it is to code a terminal solution in C# .NET and call simple picking update methods in Microsoft Dynamics AX.

The solution is coded by using Microsoft.Dynamics.BusinessConnectorNet;

You will need a reference in the project to run the example code.

HINT: Get more information about the .NET Business Connector at MSDN (Microsoft Dynamics AX Developer Center) http://msdn.microsoft.com/en-us/library/aa659581.aspx

This small Microsoft Visual Studio project includes information about:

How to log on to an AX installation

// company name, language, object server, configuration            
// this uses Windows Authentication            
 ax.Logon(CompanyId, null, null, null);

How to read data from AX and insert the data in a grid on a Windows form

clip_image002[9]

View picking routes in the upper pane and picking lines in the lower pane.

How to prepare data and call picking update functions from the .NET C# code

Picking in AX: In AX you can pick multiple lines by calling the WMSOrderTrans::finishPickingLinesMulti method. This method takes a packed AX Map where the key is the recId of the wmsOrdertrans to be picked and the value is an AX container with the OrderId and recVersion.

The example shows how to prepare the map and call the method to do the pick.

        
private AxaptaObject BuildAxaptaMapForWMSPickingLines()
{
//build a map of the following structure
//key is <c>WMSOrderTrans.recId</c> and whose value 
//is [WMSOrderTrans.OrderId,WMSOrderTrans.recVersion].
AxaptaObject axMap = ax.CreateAxaptaObject("Map", (int)Types.Int64,(int)Types.Container);

foreach (DataGridViewRow dgvRow in wmsOrderTransGrid.SelectedRows)
{
    AxaptaContainer axContainerWMSPair = ax.CreateAxaptaContainer();
    DataRow row = null;
    DataRowView drv = (DataRowView)dgvRow.DataBoundItem;
    row = drv.Row;

    axContainerWMSPair.Add(row.Field<string>(1)); //orderid
    axContainerWMSPair.Add(row.Field<Int32>(7)); //recversion 

    //add to axapta map
    axMap.Call("Insert", 
       row.Field<Int64>(6), axContainerWMSPair);
}
    return axMap;
}
        
private void PickSelectedLinesFromMap(AxaptaObject axaptaObjectMap)
{
    // call below takes a packed map whose key is 
    // <c>WMSOrderTrans.recId</c> and whose value is
    // <c>WMSOrderTrans.OrderId,WMSOrderTrans.recVersion</c>.

    ax.CallStaticClassMethod("WMSOrderTransType", 
        "finishPickingLinesMulti", 
        axaptaObjectMap.Call("pack"));
}

Apart from the method to multi-update picking lines the project also includes a method to pick-update multiple picking routes by calling WMSPickingRoute::finishMulti.

private void PickSelectedRoutesFromList(AxaptaObject axList)
{
    ax.CallStaticRecordMethod("WMSPickingRoute",
        "finishMulti",
        axList.Call("pack"));
}

Have fun trying this yourself!

Bibi Christensen, Alexander Malafeev, Per Lykke Lynnerup & Lennart Conrad

Attachment: CSharpToAxPicking.zip
  • Hi Ievgenii, good article. Do you know how to undo the picking (registerred) by code?

Page 1 of 1 (1 items)
Leave a Comment
  • Please add 8 and 5 and type the answer here:
  • Post