Hi everyone,
I want to add a few lines to a method of a class and normally, this is simple enough and I know how to do it. But this one example I'm unsure how to correctly achieve what I want.
Let's say my class is named ClassA
The method in it I want to add to is
protected void updateStatus()
{
MapEnumerator me;
ReqTrans reqTransMark;
ReqPO reqPO;
this.mapReqTransMark();
if ( mapReqTransMark
&& mapReqTransMark.elements())
{
me = mapReqTransMark.getEnumerator();
while (me.moveNext())
{
reqTransMark = me.currentValue();
reqPO = reqTransMark.reqPo(true);
setPrefix(#prefixField(reqPo,refId));
if (!reqPO.RecId)
{
throw error(strFmt("@SYS24774",reqTransMark.RefId));
}
if (!ReqTrans::refTypeIsPlannedOrder(reqPO.RefType))
{
throw error("@SYS69936");
}
reqPO.ReqPOStatus = ReqPOStatus::Approved;
reqPO.update();
mapReqPoUpdated.insert(reqPO.RecId,reqPO);
}
}
}
I want to add 2 lines right after reqPO.ReqPOStatus = ReqPOStatus::Approved;
But if I create an extension class of this class, then call this method, whether I put code before or after the "next", I am not inside that while loop so it doesn't function correctly.
What is the best practice of achieving something like this?