Monday, 26 April 2010

Display Inventory onhand in Sales order line


Rquirement: to display inventory on- hand in sales line.

Solution:
-Add a new method into SalesLine datasource:
//BP Deviation documented
display inventQty availPhysical(SalesLine _SalesLine)
{
InventOnhand InventOnhand;
InventDimParm inventDimParm;
;
if (inventDim.configId != '')
inventDimParm.ConfigIdFlag = NoYes::Yes;
if (inventDim.inventBatchId != '')
inventDimParm.InventBatchIdFlag = NoYes::Yes;
if (inventDim.InventColorId != '')
inventDimParm.InventColorIdFlag = NoYes::Yes;
if (inventDim.InventLocationId != '')
inventDimParm.InventLocationIdFlag = NoYes::Yes;
if (inventDim.inventSerialId != '')
inventDimParm.InventSerialIdFlag = NoYes::Yes;
if (inventDim.InventSiteId != '')
inventDimParm.InventSiteIdFlag = NoYes::Yes;
if (inventDim.InventSizeId != '')
inventDimParm.InventSizeIdFlag = NoYes::Yes;
if (inventDim.wMSLocationId != '')
inventDimParm.WMSLocationIdFlag = NoYes::Yes;
if (inventDim.wMSPalletId != '')
inventDimParm.WMSPalletIdFlag = NoYes::Yes;
InventOnhand =
InventOnhand::newParameters(_salesLine.ItemId,
_salesLine.inventDim(),
inventDimParm);
return inventOnHand.availPhysical();
}

-Customize modified method of inventdim's fields datasource :
public void modified()
{
SalesLine salesLineFind;
super();

salesLine.modifyItemDim(inventDim,fieldnum(InventDim,InventBatchId),InventTable::find(salesLine.ItemId).DimGroupId);

if (salesLine.DeliveryDateControlType)
SalesCalcAvailableDlvDates::modifiedField(salesLine,0,false,false,inventDim);

// finds the current selected sales line
salesLineFind = SalesLine::find(salesLine.SalesId, salesLine.LineNum);
// syncs sales table with db
salesLine_ds.research();
// updates table ui
salesLine_DS.reread();
// finds the current selected sales line
salesLine_ds.findRecord(salesLineFind);
}
-Add a Real field into SaleLine grid with display method is set to the method created in step 1.

Enjoy!