mercredi 20 juillet 2011

How to pass parameters from a temporary table to another table through a class

Hi 

here is a new example to pass a value from a temporary table TmpInventTransWMS to another table InventTrans passing through a class

In the clicked method of the button in your form InventTransRegister your have this code 

InventTransWMS_Register::updateInvent(element.args().record(), tmpInventTransWMS);

your have this method declared in  InventTransWMS_Register  class
server static public boolean updateInvent(
    Common                  _movementRecord,
    TmpInventTransWMS       _tmpInventTransWMS)
{
    InventMovement          movement    = InventTransWMS_Register::inventMovement(_movementRecord);

    return InventTransWMS_Register::updateInventFromMovement(movement, _tmpInventTransWMS);
}


which calls this method defined in the same class passing always  TmpInventTransWMS as parameter

server static public boolean updateInventFromMovement(
    InventMovement              _movement,
    TmpInventTransWMS           _tmpInventTransWMS) 

while select forupdate tmp
            order by InventQty
        {
            inventDim = InventDim::find(tmp.InventDimId);
            inventDimQuarantine.data(inventDim);

            if (movement.mustBeQuarantineControlled() && inventDim.inventLocation().InventLocationType == InventLocationType::Quarantine)
            {
                inventDim = InventQuarantineOrder::inventDimArriveOrRegistration(inventDim,movement.inventdim(),movement.itemId(),movement.dimGroupId());
            }

            inventDimParm.initPhysicalUpdate(movement.dimGroupId());

            setprefix(inventDim.preFix());

            registered = InventUpd_Registered::newParameters(movement,inventDim,inventDimParm,inventDim,inventDimParm,tmp.InventQty);

            if (movement.mustBeQuarantineControlled())
            {
                registered.parmInventDimQuarantine(inventDimQuarantine);
            }

            registered.parmPreferedInventTransRecId(tmp.RefRecId);
            //<iba>  
           registered.thy_TmpInventTransWMS(tmp.Thy_InventVendNum);
      
//</iba>

            registered.updateNow();
        }
In red, I added the new records to pass to InventTrans Table from TmpInventTransWMS
I created this method in InventUpdate , InventUpd_Registered extends from InventUpdate so it can call this method 


public class InventUpd_Registered extends InventUpdate
as follows 


// Changed on 19 Jui 2011 at 14:46:13 by iba 
void thy_TmpInventTransWMS (Thy_InventVendNum tmp)
{
    ;
    thy_InventVendNum = tmp;
}


Finally after passing the records through this method, I added a little code in the inventUpdate Class as follows 
if (_inventTrans.RecId)
    {
        //<iba>
       _inventTrans.Thy_InventVendNum = thy_InventVendNum;
       //</iba>
       _inventTrans.update();
    }
To take in consideration the new records 
I had also to pass these records to aonther table InventSerial so I added this code
in writeInventTransAutoDim method  of InventUpdate class.

if (!InventSerial::exist(movement.itemId(), inventDim.inventSerialId))
{
    inventSerial.InventSerialId          = inventDim.inventSerialId;                           inventSerial.initFromInventMovement(movement, _inventTrans);
     //<iba>
     inventSerial.Thy_InventVendNum      = thy_InventVendNum;
     //</iba>
     inventSerial.insert();
}

Aucun commentaire:

Enregistrer un commentaire