Bpm for requisition

Hi All,

Can anyone help me to set a BPM for Auto approve if cost is less then $2000.

I am new with this and not able to do It.
I write a code in method directive as follow: (BUT THIS CODE TAKE TOO LONG TIME AND I am getting error ) I am using EPICOR KINITIC CLOUD

in ERP.BO.Req.Update:

// Threshold per line
decimal lineApprovalLimit = 100m;

// Get ReqSvc service
var reqSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.ReqSvcContract>(Db);

// Loop through all requisition headers in the BPM tableset
foreach (var head in Db.ReqHead)
{
    int reqNum = head.ReqNum;

    // Get all detail lines for this requisition
    var lines = Db.ReqDetail.Where(d => d.ReqNum == reqNum).ToList();

    bool allLinesBelowLimit = true;

    // Check each line total
    foreach (var line in lines)
    {
        decimal lineTotal = line.XOrderQty * line.DocUnitCost;
        if (lineTotal > lineApprovalLimit)
        {
            allLinesBelowLimit = false;
            break;
        }
    }

    // Skip if any line exceeds limit
    if (!allLinesBelowLimit)
        continue;

    // Load full tableset from service
    var ts = reqSvc.GetByID(reqNum);

    // Approve the header
    ts.ReqHead[0].StatusType = "A";

    string reqNumStr = reqNum.ToString();   // Convert int to string
    bool includeSendToPMCond = true;

    // Build Req Actions List
    var actions = reqSvc.BuildReqActionsList(reqNumStr, includeSendToPMCond);

    // Prepare ReqActionID
    string reqActionID = "APPROVE";

    // Declare out variable before calling method (C# 6 compatible)
    string currDispatcherID;

    // Execute action
    reqSvc.BuildNextDispatcher(reqNumStr, out reqActionID, out currDispatcherID);


    // 3. Save changes
    reqSvc.Update(ref ts);

}