@romsar if you have shipments where you deliver multiple CO Lines from different Customer Orders this is what I would do:
- create a CF in Shipment header → to sum up the amount of the shipment lines → look for unit price in CO Line and multiply by qty
- create event on Inventory Transactions History where transaction_code = ‘OESHIP’
- create custom attribute to get the total amount value from shipment header CF so that you can compare it in your event action with your threshold amount (minimum amount)
The disadvantage with this approach is that if you deliver a Shipment with 10 lines, there will be 10 inventory transactions of type OESHIP. Performance wise I don’t think this could be a problem.
Hi Romsar,
Try see which table gets updated when the "Deliver" process is executed. Identify the triggered table using debug console or Database Triggers that has this total amount that you are referring to (ex: like SHIPMENT_ORDER_LINE_TAB)
Create a New Custom Event:
- Table Name: The table that triggers the event
- Condition: Define the condition to check the total amount.for example
- NEW.TOTAL_AMOUNT < :Your_Minimum_Amount
- (Replace TOTAL_AMOUNT with the actual column name storing the total shipment amount.)
Add an Event Action:
- Choose the Action Type as PL/SQL Block(Execute Online SQL).
- Write the logic to validate the amount and prevent delivery like this in the Action Details.
BEGIN
IF :NEW.TOTAL_AMOUNT < 100 THEN
-- Raise an error to block delivery
raise_application_error(-20000, 'Delivery cannot proceed: Total amount is below the minimum limit.');
END IF;
END;
/Oshada
Hello.
With a workmate, we proceeded this way :
- Table triggered : SHIPMENT_TAB
- Fires on the ROWSTATE update
About the event action :
- condition : OLD:ROWSTATE = Completed, NEW:ROSTATE = Closed
About calculating the total amount of the shipment, the calculous isn’t confirmed yet but I made this :
select round(sum(SHIPMENT_LINE.QTY_SHIPPED*CUSTOMER_ORDER_LINE.BASE_SALE_UNIT_PRICE), 2) INTO v_total_amount
from SHIPMENT_LINE
INNER JOIN CUSTOMER_ORDER_LINE on SHIPMENT_LINE.SOURCE_REF1=CUSTOMER_ORDER_LINE.ORDER_NO
AND SHIPMENT_LINE.SOURCE_REF2=CUSTOMER_ORDER_LINE.LINE_NO
AND SHIPMENT_LINE.SOURCE_REF3=CUSTOMER_ORDER_LINE.REL_NO
where SHIPMENT_ID='&NEW:SHIPMENT_ID'
AND CUSTOMER_ORDER_LINE.OBJSTATE!='Cancelled';
Does that sound fine?
Hello @Marcel.Ausan
Why an event on inventory_transaction_hist_tab ?
The event that I’m trying to work on is not about the total amont for each delivery, but about the shipment total value.
Moreover, I can’t imagine to define an event on this table a same customer order line can be used on more than 1 shipment, so from a transaction, I can’t know the shipment origin.