Question

EVENT ACTION

  • 28 March 2024
  • 2 replies
  • 51 views

Badge +5
  • Do Gooder (Customer)
  • 13 replies

dear all, 

We want to create an event if the quantities of materials in the purchase order exceed the quantities specified in the order during the delivery process

The code snippet for the event is provided below, but we're not receiving any emails from the event. Does anyone have any comments on this?

 

 

BEGIN
  DECLARE
    v_emails VARCHAR2(200);
    v_subject VARCHAR2(100);
    v_message VARCHAR2(4000);
    v_buy_qty_due NUMBER;
    v_total_qty_arrived NUMBER;
  BEGIN
    SELECT pola.BUY_QTY_DUE,
           SUM(ria.SOURCE_QTY_TO_RECEIVE) 
    INTO v_buy_qty_due, v_total_qty_arrived
    FROM PURCHASE_ORDER_LINE_ALL pola
    LEFT JOIN RECEIPT_INFO_ALT ria ON ria.SOURCE_REF1 = pola.ORDER_NO
                                     AND pola.LINE_NO = ria.SOURCE_REF2
                                     AND pola.RELEASE_NO = ria.SOURCE_REF3
                                     AND pola.PART_NO = ria.PART_NO
                                     AND pola.CONTRACT = ria.CONTRACT;

 

    IF v_total_qty_arrived > v_buy_qty_due THEN
      v_subject := 'Teslim Alınan Miktar SAS Miktarından Fazla!';
      v_message := TO_CHAR(SYSDATE, 'DD.MM.YYYY') || ' tarihinde, siparişe teslim alınan miktar SAS miktarından fazla olmuştur.

 

Aşağıdaki linke tıklayarak ilgili sayfaya gidebilirsiniz.

 

';
      BEGIN
        SELECT LISTAGG(DEFAULT_EMAIL, ', ') WITHIN GROUP (ORDER BY DEFAULT_EMAIL) 
        INTO v_emails
        FROM PERSON_PUBLIC_HR_INFO
        WHERE POS_CODE = '318_100_40';
      EXCEPTION
        WHEN OTHERS THEN
          v_emails := NULL;
      END;

 

      IF v_emails IS NOT NULL THEN
        command_sys.mail(
          sender_      => 'IFSAPP',
          from_        => 'ifs@kontekenerji.com.tr',
          to_list_     => v_emails,
          cc_list_     => '',
          bcc_list_    => '',
          subject_     => v_subject,
          text_        => v_message,
          attach_      => '',
          rowkey_      => '',
          mail_sender_ => 'MAIL_SENDER1'
        );
      END IF;
    END IF;
  EXCEPTION
    WHEN OTHERS THEN
      NULL;
  END;
END;

 

 

additionally we run this event action lu:PurchaseOrder  table -->PURCHASE_ORDER_TAB


2 replies

Userlevel 3
Badge +5

Hi @sevo 

I believe this code need to restructure. Basically when during delivery process if it is required to shoot an email you need to send this job into background process using Transaction_SYS.Deferred_Call else there’s a possibility of getting mutating error also I don’t see any attribute using in the code to specify the exact order such as &NEW:ORDER_NO, &NEW:LINE_NO, &NEW:RELEASE_NO etc… I’m bit worried about the LU specified and the trigger attached table. May I know the condition you use to fire the event? is it the rowstate change..

Thanks, and Best Regards,
Shehan

Userlevel 7
Badge +19

Change view from PURCHASE_ORDER_LINE_ALL to PURCHASE_ORDER_LINE.
PURCHASE_ORDER_LINE_ALL is a join with PURCHASE_ORDER_TAB which you have triggered on and as Shehan says that will cause an error.

Reply