Tuesday 21 August 2012

Implement Catch Weight


Implement Catch Weight in New Form 


Before Starting Implementation , Let us have a Quick Look on this functionlaity 
You often use catch weight products in industries where products can vary slightly by weight or size, or both, such as the food industry. Catch weight products use two units of measure – an inventory unit and a catch weight unit. The inventory unit is the unit of measure in which the product is weighed and invoiced. The catch weight unit is the unit in which the inventory transactions are performed, such as sold, received, transferred, picked, and shipped. The nominal quantity represents the conversion between the catch weight unit and the inventory unit. Minimum and maximum quantities represent the allowed interval in which the inventory quantity can vary.

Now go for Implementation :

1 . Create a new class Extend with PdsCWFormCtrl_Std
            Override the method as required.
2. In table create two fields : Qty and PdsCWQty
3. Add display method to table :
public display PdsCWUnitId pdsCWUnitId()
{
    return PdsCatchWeight::cwUnitId(this.ItemId);
}


4.In Classdeclaration of Form   add below line :
PdsCWFormCtrl                       cwFormCtrl;
 5.In init method of Form :
        if (#PdsCatchWeightEnabled)
        {
            cwFormCtrl = yourclass::newFromForm(element);
            cwFormCtrl.initPre();
        }
       
        super();
    if (cwFormCtrl)
    {
        cwFormCtrl.parmBuffer(YourTable);
        cwFormCtrl.initPost();
    }
    6.In init method of Datasource add :

public void init()
{
    super();
    if (cwFormCtrl)
    {
        cwFormCtrl.dataSourceInitPost(YourTable);
    }
   
}
\
7.Override the Validatewrite of DS :
public boolean validateWrite()
{
    boolean ret;

    ret = super();

    if (cwFormCtrl)
    {
        ret = cwFormCtrl.dataSourceValidateWrite() && ret;
    }
   
    return ret;
}
8.Override the Active method of DS
if (cwFormCtrl)
    {
        cwFormCtrl.dataSourceActivePost();
    }

9.Override the modified of ItemId and QTY as
           
  if (cwFormCtrl)
    {
        cwFormCtrl.fieldModified(fieldnum(WO_line, ItemId));
    }

No comments:

Post a Comment