Skip to main content

Hello, i trying create a event, where after save new record in “Vendor Purchase Item” form, i want modify record based on Part number. But i get ERROR about mutating table. Is there any change i can solved this? 

Event settings: runnig only for “new created object” and run “after” and LJ is PurchasePartSupplier and table is PURCHASE_PART_SUPPLIER_TAB.

I read about solving by calling custom procedure and run it as a deferred call, but i dont beleave, that is only one solution. 

 

DECLARE 
--  pragma autonomous_transaction;
--info_ varchar2(32000);
 info_ VARCHAR2(32000) := NULL;
attr_ varchar2(32000);
PART_NO_ varchar2(32000) :='&NEW:PART_NO';
DES_ varchar2(32000);


BEGIN

  FOR rec_ IN (  select  pps.part_no, pps.objid, pps.objversion
  from PURCHASE_PART_SUPPLIER pps
  where pps.OBJKEY = '&NEW:ROWKEY') 

 LOOP
IF (REGEXP_LIKE(SUBSTR(PART_NO_ , 1, 1), 'E(:alpha:]]') AND NOT REGEXP_LIKE(PART_NO_, '-E'))
  THEN
       Client_Sys.Clear_Attr(attr_); 
       Client_Sys.Add_To_Attr('RECEIVE_CASE_DB', 'QAINV', attr_);       
       Client_Sys.Add_To_Attr('INSPECTION_CODE', 'A', attr_);    
       Client_Sys.Add_To_Attr('SAMPLE_PERCENT', '100', attr_);
       IFSAPP.PURCHASE_PART_SUPPLIER_API.Modify__(info_, rec_.objid, rec_.objversion, attr_, 'DO');     
  ELSE
         Client_Sys.Clear_Attr(attr_); 
         Client_Sys.Add_To_Attr('RECEIVE_CASE_DB', 'INVDIR', attr_);       
         Client_Sys.Add_To_Attr('INSPECTION_CODE', '', attr_);    
         Client_Sys.Add_To_Attr('SAMPLE_PERCENT', '0', attr_);               
         IFSAPP.PURCHASE_PART_SUPPLIER_API.Modify__(info_, rec_.objid, rec_.objversion, attr_, 'DO');

END IF;
END LOOP;
END; 

 

Thanks guys

Hi @jrubas 

I think the solution is here:

Error while creating PR | IFS_PURCHASE_REQ_LINE_TAB is mutating | IFS Community


I always use deferred calls for this error


I agree with @lglover241.

@jrubas is your IFS in the cloud or onprem?


Onprem

 

I have similiar problem, but another error message. I create event, where user create new purchase order. Ofcouse triggering on create and running after. LU: PurchaseOrder

 

And after saving order IFS show me error, that order_no doesnt exist, but in detail of message, he tells me number of order 

 

 

DECLARE
  info_ VARCHAR2(32000) := NULL;
  attr_ VARCHAR2(32000);
  p1_   VARCHAR2(32000) := '';
  p2_   VARCHAR2(32000) := '';
  ORDER_NO_ :='&NEW:ORDER_NO'; 
  COUNT_LINE_PART NUMBER;
  COUNT_LINE_PART_NOPART NUMBER;


BEGIN
SELECT COUNT(*) INTO COUNT_LINE_PART FROM PURCHASE_ORDER_LINE_PART a WHERE ORDER_NO= ORDER_NO_;
SELECT COUNT(*) INTO COUNT_LINE_PART_NOPART FROM PURCHASE_ORDER_LINE_NOPART a WHERE ORDER_NO= ORDER_NO_;


IF COUNT_LINE_PART >= 1 AND COUNT_LINE_PART_NOPART = 0 
 THEN

          Client_Sys.Clear_Attr(attr_); 
          Client_Sys.Add_To_Attr('ORDER_NO', ORDER_NO_,attr_); 
          Client_Sys.Add_To_Attr('CONTRACT', 'RETIA', attr_);
          Client_Sys.Add_To_Attr('CHARGE_TYPE', 'DOPR + BAL', attr_); 
          Client_Sys.Add_To_Attr('CHARGE_CURRENCY_CODE', 'CZK', attr_);
          Client_Sys.Add_To_Attr('DISTRIBUTE_ON_RECEIPT_DB', 'FALSE', attr_);
 
          IFSAPP.PURCHASE_ORDER_CHARGE_API.New__(info_, p1_, p2_, attr_, 'DO'); 
          
  ELSIF COUNT_LINE_PART_NOPART >= 1 AND COUNT_LINE_PART = 0 
    THEN
          
          Client_Sys.Clear_Attr(attr_); 
          Client_Sys.Add_To_Attr('ORDER_NO', ORDER_NO_, attr_); 
          Client_Sys.Add_To_Attr('CONTRACT', 'RETIA', attr_);
          Client_Sys.Add_To_Attr('CHARGE_TYPE', 'DOPR + BAL', attr_);
          Client_Sys.Add_To_Attr('CHARGE_CURRENCY_CODE', 'CZK', attr_);
          Client_Sys.Add_To_Attr('DISTRIBUTE_ON_RECEIPT_DB', 'FALSE', attr_);        
  
         IFSAPP.PURCHASE_ORDER_CHARGE_API.New__(info_, p1_, p2_, attr_, 'DO');
  ELSE 
          
          Client_Sys.Clear_Attr(attr_); 
          Client_Sys.Add_To_Attr('ORDER_NO', ORDER_NO_, attr_); 
          Client_Sys.Add_To_Attr('CONTRACT', 'RETIA', attr_);
          Client_Sys.Add_To_Attr('CHARGE_TYPE', 'DOPR + BAL', attr_);
          Client_Sys.Add_To_Attr('CHARGE_CURRENCY_CODE', 'CZK', attr_);
          Client_Sys.Add_To_Attr('DISTRIBUTE_ON_RECEIPT_DB', 'FALSE', attr_);         
  
          IFSAPP.PURCHASE_ORDER_CHARGE_API.New__(info_, p1_, p2_, attr_, 'DO'); 
     
          Client_Sys.Clear_Attr(attr_); 
          Client_Sys.Add_To_Attr('ORDER_NO', ORDER_NO_, attr_); 
          Client_Sys.Add_To_Attr('CONTRACT', 'RETIA', attr_);
          Client_Sys.Add_To_Attr('CHARGE_TYPE', 'DOPR + BAL', attr_);
          Client_Sys.Add_To_Attr('CHARGE_CURRENCY_CODE', 'CZK', attr_);
          Client_Sys.Add_To_Attr('DISTRIBUTE_ON_RECEIPT_DB', 'FALSE', attr_);

 
          IFSAPP.PURCHASE_ORDER_CHARGE_API.New__(info_, p1_, p2_, attr_, 'DO');

END IF;
END; 

 

 


onprem


Reply