Uploaded by Mohammed Shoukat Ali

db trigger 11-12-2021

advertisement
CREATE OR REPLACE TRIGGER ADS_RA_INTERFACE_TRG1 AFTER INSERT ON "AR"."RA_INTERFACE_LINES_ALL" FOR EACH ROW
--when (NEW.BATCH_SOURCE_NAME IN ('Qassim Cash'))
-----------Modified by shoukat on 11-12-2021-------------------------------------------------------------------
when (NEW.BATCH_SOURCE_NAME IN ('ATC TYRES (T07) Cash Sales','Yokohama TSC Cash','Qassim Cash'))
--when (NEW.set_of_books_id IN (2))
--------------Ended on 11-12-2021-------------------------------------------------------------------------------
DECLARE
----------------------------------------------------------------------------
--- Filename : ads_ra_interface_trg1.sql
---
--- Description: This script creates database trigger ADS_RA_INTERFACE_TRG1.
--- When a record is entered into the RA_INTERFACE_LINES_ALL
--- table, this trigger will kick off the Autoinvoice Master
--- process.
-----------------------------------------------------------------------------
conc_id NUMBER := 0;
e_conc_req EXCEPTION;
my_batch_source_id VARCHAR2(7);
retval BOOLEAN;
my_operating_unit NUMBER:=0;
my_batch_source_name VARCHAR2(1000);
BEGIN
/* All requests have to run synchronously -
next starts when previous is complete */
fnd_profile.put('CONC_SINGLE_THREAD','Y');
/* check set of books id to determine source_id */
BEGIN
-----------Added T07 BATCH SOURCE ID : 13459--- T05 Cash Batch Source id:1069-----------
IF :NEW.BATCH_SOURCE_NAME = 'ATC TYRES (T07) Cash Sales' --:new.set_of_books_id = 2 /* Vision Operations */
-- THEN my_batch_source_id := '13459'; --ATC TYRES (T07) Cash Sales
THEN my_batch_source_name := 'ATC TYRES (T07) Cash Sales'; ELSIF :NEW.BATCH_SOURCE_NAME = 'Yokohama TSC Cash' /* Vision Operations */
-- THEN my_batch_source_id := '1069'; --ATC TYRES (T05) Cash Sales
THEN my_batch_source_name := 'Yokohama TSC Cash'; -- ELSIF :new.set_of_books_id = 2 /* Vision Operations */
-- THEN my_batch_source_id := '1052'; --ATC TYRES (T01) Cash Sales
ELSIF :NEW.BATCH_SOURCE_NAME = 'Qassim Cash' -- :new.set_of_books_id = 2 /* Vision Operations */
-- THEN my_batch_source_id := '1063'; --- ATC TYRES (T03) Cash Sales
THEN my_batch_source_name := 'Qassim Cash'; -------------Modified by shoukat on 25-11-2021----------------------
/* ELSIF :new.set_of_books_id = 165 \* Process Operations *\
THEN my_batch_source_id := '1550';
ELSIF :new.set_of_books_id = 289 \* UK Public Sector*\
THEN my_batch_source_id := '2025';
ELSIF :new.set_of_books_id = 186 \* Belgium *\
THEN my_batch_source_id := '1903';
ELSIF :new.set_of_books_id = 126 \* Germany *\
THEN my_batch_source_id := '1488';
ELSIF :new.set_of_books_id = 124 \* France *\
THEN my_batch_source_id := '1509';
ELSIF :new.set_of_books_id = 122 \* Sweden *\
THEN my_batch_source_id := '1508';
ELSIF :new.set_of_books_id = 187 \* Italy *\
THEN my_batch_source_id := '1613';
ELSIF :new.set_of_books_id = 123 \* Holland *\
THEN my_batch_source_id := '1633';
ELSIF :new.set_of_books_id = 290 \* Vision Communications *\
THEN my_batch_source_id := '1612';
ELSIF :new.set_of_books_id = 103 \* Vision Project Mfg (EUR)*\
THEN my_batch_source_id := '1045';*/
-----------------------Ended on 25-11-2021--------------------------------------
ELSE
-- my_batch_source_id := Null; --' '; -- By Mohd Ali To Fix trigger error on 10-12-2021 ----
my_batch_source_name := Null; --' '; -- By Mohd Ali To Fix trigger error on 10-12-2021 ----
END IF;
/* submit Autoinvoice Master Program */
IF my_batch_source_id is not null THEN --> > ' ' SELECT operating_unit
INTO my_operating_unit
FROM ORG_ORGANIZATION_DEFINITIONS ood
WHERE ood.organization_id = :new.org_id;
FND_REQUEST.set_org_id(my_operating_unit);
retval := fnd_request.set_mode(db_trigger=>TRUE);
conc_id := fnd_request.submit_request(
application => 'AR',
program => 'RAXMTR',
description => 'ADS,',
start_time => NULL,
sub_request => FALSE,
argument1 => '1',
argument2 => my_operating_unit,
argument3 => Null, --my_batch_source_id, -- Modified By Mohd Ali on 10-12-2021 argument4 => my_batch_source_name,--- 'ATC TYRES (T07) Cash Sales', --'ORDER ENTRY', ---
argument5 => to_char(sysdate, 'YYYY/MM/DD'),
argument6 => NULL,
argument7 => NULL,
argument8 => NULL,
argument9 => NULL,
argument10 => NULL,
argument11 => NULL,
argument12 => NULL,
argument13 => NULL,
argument14 => NULL,
argument15 => NULL,
argument16 => NULL,
argument17 => NULL,
argument18 => :new.sales_order,
argument19 => :new.sales_order,
argument20 => NULL,
argument21 => NULL,
argument22 => NULL,
argument23 => NULL,
argument24 => NULL,
argument25 => NULL,
argument26 => 'Y',
argument27 => NULL );
IF (conc_id = 0) THEN
raise e_conc_req;
END IF;
END IF;
EXCEPTION
WHEN e_conc_req THEN
arp_util.debug('ads_ra_interface_trg1','C');
WHEN others THEN
arp_util.debug('ads_ra_interface_trg1','O');
END;
/* Reset synchronous processing. */
fnd_profile.put('CONC_SINGLE_THREAD','N');
END;
Download