Automate Receipt Entry using Dashboard via BPM

I am trying to automate the process to generate PO and receipt the PO via BPM.

I created a UD field called manufactured, when user tick it. It triggers BPM to create the PO and receipt the PO.

Erp.Tablesets.ReceiptTableset  receiptTableset = new Erp.Tablesets.ReceiptTableset();
        
        hReceipt.GetNewRcvHeadWithPONum(ref receiptTableset, vendorNum, purPoint, poNum);
                
        
        string cLCAmtMessage;         // Arg 7
        string opUpliftWarnMsg;       // Arg 8
        string opReceiptWarnMsg;      // Arg 9
        string opArriveWarnMsg;       // Arg 10
        string qMessageStr;           // Arg 12
        string sMessageStr;           // Arg 13
        string lcMessageStr;          // Arg 14
        string pcMessageStr;          // Arg 15
        string qDtlComplianceMsgStr;  // Arg 17
        bool lCompliant;              // Arg 19      
        bool lRequiresUserInput;      // Arg 21
        bool lUpdateWasRun;           // Arg 26

        receiptTableset.RcvHead[0].PONum = poNum;
        receiptTableset.RcvHead[0].PackSlip = poNum.ToString();
        receiptTableset.RcvHead[0].ReceiptDate = vendorJobs.First().ReqDueDate;
        receiptTableset.RcvHead[0].ArrivedDate = vendorJobs.First().ReqDueDate;
        
        hReceipt.UpdateMaster(true,  
                              true,
                              vendorNum,
                              purPoint,
                              poNum.ToString(),
                              0,
                              out cLCAmtMessage,
                              out opUpliftWarnMsg,
                              out opReceiptWarnMsg,
                              out opArriveWarnMsg,
                              false,
                              out qMessageStr,
                              out sMessageStr,
                              out lcMessageStr,
                              out pcMessageStr,
                              false,
                              out qDtlComplianceMsgStr,
                              false,
                              out lCompliant,
                              true,
                              out lRequiresUserInput,
                              false,
                              "","",true, out lUpdateWasRun, ref receiptTableset);

        

        string errorMsg;
        
        hReceipt.ValidateMRPONum(poNum, vendorNum, out errorMsg);
             
        
        hReceipt.CreateMassReceipts(vendorNum, purPoint, poNum.ToString(), 0, poNum, ref receiptTableset);  // Checked data - all good

        

         
        foreach(var rcvDtlTableRow in receiptTableset.RcvDtl)
        {
          rcvDtlTableRow.Selected = true;
        }   
        
        hReceipt.ReceiveAll(ref receiptTableset);  // Checked All Good
        

        
        bool RequiresUserInput = false;
        hReceipt.PreUpdate(ref receiptTableset, out RequiresUserInput);

        hReceipt.CommitRcvDtl(vendorNum,purPoint,poNum.ToString(),ref receiptTableset);
           

        
        
        foreach(var rcvDtlTableRow in receiptTableset.RcvDtl)
        {
          rcvDtlTableRow.RowMod = "U";
          
          rcvDtlTableRow.WareHouseCode = resourceWarehouseInfo.OutputWhse;
          rcvDtlTableRow.BinNum = resourceWarehouseInfo.OutputBinNum;
          
          hReceipt.SetPrimaryBin(vendorNum,purPoint,poNum.ToString(),rcvDtlTableRow.PackLine, ref receiptTableset);
          
                  
        
        
          hReceipt.OnChangeDtlReceived(vendorNum,purPoint,poNum.ToString(),rcvDtlTableRow.PackLine,true,ref receiptTableset);
          
          // Debugging
        Erp.Tablesets.RcvHeadTable dtRcvHead = receiptTableset.RcvHead;
        Erp.Tablesets.RcvDtlTable dtRcvDtl = receiptTableset.RcvDtl;
        
        var output = new System.Text.StringBuilder();
        var columnName = "";
                
        output.Append("<RcvHead>\n");
        for (int i = 0; i < dtRcvHead.Columns.Count; i++)
        {
            columnName = dtRcvHead.Columns[i].ColumnName;
            
            output.Append("<" + columnName + ">" + dtRcvHead[0][i] + "</" + columnName + ">" + "\n");
        }
        
        output.Append("</RcvHead>\n<RcvDtl>\n");
        for (int i = 0; i < dtRcvDtl.Columns.Count; i++)
        {
            columnName = dtRcvDtl.Columns[i].ColumnName;
            
            output.Append("<" + columnName + ">" + dtRcvDtl[0][i] + "</" + columnName + ">" + "\n");
        }
        output.Append("<RcvDtl>\n");
        
        this.PublishInfoMessage( output.ToString(), Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "","");
        
        // End Debugging
        
        
          hReceipt.UpdateMaster(true,  
                              true,
                              vendorNum,
                              purPoint,
                              poNum.ToString(),
                              rcvDtlTableRow.PackLine,
                              out cLCAmtMessage,
                              out opUpliftWarnMsg,
                              out opReceiptWarnMsg,
                              out opArriveWarnMsg,
                              true,
                              out qMessageStr,
                              out sMessageStr,
                              out lcMessageStr,
                              out pcMessageStr,
                              false,
                              out qDtlComplianceMsgStr,
                              false,
                              out lCompliant,
                              true,
                              out lRequiresUserInput,
                              false,
                              rcvDtlTableRow.PartNum,rcvDtlTableRow.LotNum,true, out lUpdateWasRun, ref receiptTableset);
          
         // string pcMsg;
          // hReceipt.DisplayWarnMsg("PUR-SUB",rcvDtlTableRow.LotNum,0,10, out pcMsg);
        }

The code run successfully without errors, but then when I look at the Packslip in the Receipt Entry, the Complete tick box is not ticked, the Arrived Qty and Received Qty stays at zero.

If anyone has used BPM to receipt PO, can you shed some light?

@TobyLai
You might want to check your configuration.

When I raise a PO and receipt it in Demo Epic06 The complete checkbox is already checked

I did taken a look at the company configuration and at a part, but can’t see any config value that may be relevant, but I might be wrong.

Looking at a trace I see that the ReceivedComplete flag is set to true in the GetDtlPOLineInfo method.

Take a look at the Return Details of RcvDtl part of the dataset. You can see it changes from false to true.

Forgot to mentioned that the code was done in the Data directive Custom code.

I have followed the trace from DMT or UI, it looks like the code do work in Method Directive BPM, but it doesn’t work in Data Directive. If I do the code in Data Directive, it gets to this funny state.

2 Likes