How to Skip COC original code
How to Skip COC original code or Run it in condition
·
Original
method:
This is the original method which set inventDim based
on inventJournalTrans
public
void fieldModifiedInventDimFieldsPost(
InventDim _inventDim,
FieldId _dimFieldId)
{
if
(inventDimReceipt_ds)
{
inventDimReceipt.data(InventDim::find(inventJournalTrans.ToInventDimId));
inventDimReceipt_ds.setCurrent();
}
}
· Extension Method:
On the extension of this method, I want to
change the inventDim buffer according to my need
public void fieldModifiedInventDimFieldsPost(
InventDim _inventDim,
FieldId _dimFieldId)
{
next
fieldModifiedInventDimFieldsPost(_inventDim,_dimFieldId);
if
(inventJournalTrans.JournalType == InventJournalType::OwnershipChange)
{
InventDim
inventDim = inventDimReceipt_ds.cursor();
inventDim.InventSiteId = '';
inventDim.InventLocationId = '';
inventDim.wmsLocationId = '';
}
}
·
Skip
original code:
But in my case, I no longer need the original
code, so I need to skip the next call so that the original code won't run.
For doing so I write my next call in a while query and the condition of the
query will always be false so that it will never going to run the code inside
the while query.
public void fieldModifiedInventDimFieldsPost(
InventDim _inventDim,
FieldId _dimFieldId)
{
custTable custtable;
while select recid from
Custtable where custtable.recid == -1
{
next
fieldModifiedInventDimFieldsPost(_inventDim,_dimFieldId);
}
if (inventJournalTrans.JournalType ==
InventJournalType::OwnershipChange)
{
InventDim inventDim =
inventDimReceipt_ds.cursor();
inventDim.InventSiteId = '';
inventDim.InventLocationId = '';
inventDim.wmsLocationId = '';
}
}
· Run next in condition:
I need the original code to run in those cases
where my condition is not fulfilled. First, stop the original code from running
then put my condition and write specific code inside, and in else case copy the
original code so that it runs otherwise.
public void fieldModifiedInventDimFieldsPost(
InventDim _inventDim,
FieldId _dimFieldId)
{
custTable custtable;
// skip the next call
while select recid from
Custtable where custtable.recid == -1
{
next
fieldModifiedInventDimFieldsPost(_inventDim,_dimFieldId);
}
//if the condition meets run our case
if (inventJournalTrans.JournalType ==
InventJournalType::OwnershipChange)
{
//our code
InventDim inventDim = inventDimReceipt_ds.cursor();
inventDim.InventSiteId = '';
inventDim.InventLocationId = '';
inventDim.wmsLocationId = '' ;
}
//otherwise run the original code
else
{
{
inventDimReceipt.data(InventDim::find(inventJournalTrans.ToInventDimId));
inventDimReceipt_ds.setCurrent();
}
}
Comments
Post a Comment