Job Receipt To Inventory /BPM / Method Directives

Hi . I am trying to archive so the Quantity received will not exceed the Production Quantity of that particular job with a hard stop , with the code below . But it always accepts more than 1 . Example : Production Quantity = 10 . Job receipt to inventory will allow 11 and after that the code kicks in with a hard stop . Code as below . Any help will be greatly appreciated

Method Directives > Pre-Processing > ReceiptsFromMfg.PreUpdate

Condition:
Number of rows in the “test” query is more then 1
Query
for each ttPartTran where (ttPartTran.RowMod = ‘A’ or ttPartTran.RowMod = ‘U’) , each JobProd where JobProd.Company = ttPartTran.Company and JobProd.JobNum = ttPartTran.JobNum and JobProd.ReceivedQty > JobProd.ProdQty no-lock

Action:
Synchronously execute ABL code records nothing
ABL CODE:
/* Over Receiving Quantity From Job */

For each ttPartTran where ttPartTran.RowMod = ‘A’ or ttPartTran.RowMod = ‘U’ no-lock.
Find first JobProd where JobProd.Company = ttPartTran.Company and JobProd.JobNum = ttPartTran.JobNum and JobProd.ReceivedQty > JobProd.ProdQty no-lock no-error.

If JobProd.ReceivedQty > JobProd.ProdQty Then Do:

{lib/PublishEx.i &ExMsg = "‘You are Over Receiving The Quantity’ + ’
Receiving Quantity = ’ + string(JobProd.ReceivedQty) + ’

Run Quantity = ’ + string(JobProd.ProdQty)+ ’

Please refer Job Order ’ + string(JobProd.JobNum) + ’
"}.

End.
End.


Goal : Quantity received can NOT exceed the production quantity of the Job with a hard stop

Thank you

Shouldn’t this be done in the .Update method with a “halt execution” (forget what is called in versions before E10) ?

Edit: “Raise an exception” is what I meant.

Hi Calvin . Thanks for the swift response . Yes i have tried with
Action:
Raise exception based on the “test” template

Gives a hard stop with a +1 Quantity . Example Production Quantity = 10 , it gives a hard stop after 11 . Need to get a hardstop on 11 not after 11

Hi, I am looking for exactly the same syntax for the method directive receiptfrommfg.

did you get a resolution to this?
Thanks.

this ABL did the trick on a method directive…/ReceiptsFromMfg.OnChangeActTranQty

I found this post really useful and just modified the ABL

FOR EACH ttPartTran WHERE (ttPartTran.RowMod = ‘A’ OR ttPartTran.RowMod = ‘U’) NO-LOCK.

DEFINE VARIABLE QtyReceived As INTEGER NO-UNDO INITIAL 0.
DEFINE VARIABLE TextMessage As CHARACTER NO-UNDO.
DEFINE VARIABLE QtyCompleted AS INTEGER NO-UNDO INITIAL 0.

FIND FIRST JobHead WHERE JobHead.Company = CUR-COMP AND JobHead.JobNum = ttPartTran.JobNum NO-LOCK.
ASSIGN QtyCompleted = JobHead.QtyCompleted.

FOR EACH PartTran WHERE PartTran.Company = CUR-COMP AND PartTran.JobNum = ttPartTran.JobNum AND PartTran.TranType = ‘MFG-STK’ NO-LOCK.
QtyReceived = QtyReceived + PartTran.TranQty.
END.

ASSIGN TextMessage = 'This additional receipt quantity will mean the total received quantity will exceed the jobs current completed quantity of ’ + STRING(QtyCompleted).

IF (QtyReceived + ttPartTran.ActTranQty) > QtyCompleted THEN DO:
{lib\PublishEx.i &exMsg = "TextMessage "}
{&THROW_PUBLIC}.
END.

END.

Hello!
Have anyone tested it in Kinetic Job Receipt to Inventory?
Transactions are being created every time when we press save button, and bpm code from some posts above actually works well. But…

If you once press save and transaction is created then you can put another quantity and press save again. This will add next transaction. It comes through bpm also but this time all quantities in ds.PartTran are 0.
I have tested it in

  1. Erp.BO.ReceiptsFromMfg.PreUpdate
  2. Erp.BO.ReceiptsFromMfg.ReceiveMfgPartToInventory
  3. Erp.BO.ReceiptsFromMfg.OnChangeActTranQty
PartTranRow tran = ds.PartTran.FirstOrDefault();

string message = String.Format(
    "PreUpdate\nActTranQty: {0}\nAfterQty: {1}\nBeginQty: {2}\nOnHandQty: {3}\nThisTranQty: {4}\nTranQty: {5}",
    tran.ActTranQty,
    tran.AfterQty,
    tran.BeginQty,
    tran.OnHandQty,
    tran.ThisTranQty,
    tran.TranQty
  );

  PublishInfoMessage(
    message, 
    Ice.Common.BusinessObjectMessageType.Information, 
    Ice.Bpm.InfoMessageDisplayMode.Individual, 
    "", 
    ""
  );

image

Any idea what is going on?

OK. I figured out the problem was with FirstOrDefault methhod call.
For the second time I am clicking save there are two rows in dataset. Below code is what I needed.

PartTranRow tran = ds.PartTran.Where(
    r => 
        (r.Company == Session.CompanyID && r.TranType == "MFG-STK") 
        && r.RowMod == "U" || r.RowMod == "A"
).FirstOrDefault();