客户化开发WebADI,首先要建立好相应的数据库对象。然后再通过配置来创建需要使用的WebADI。
创建数据库对象时一定要注意Data object要生成在CUX schema中,code object创建在APPS schema中,CUX中的要在APPS中创建SYNONYM。
-- Create table
CREATE TABLE CUX.CUX_WEBADI_TEST01
( ADI_ID NUMBER,
ADI_CODE VARCHAR2(30),
ADI_DATE DATE,
ADI_USER_ID NUMBER,
ADI_USER_NAME VARCHAR2(30),
ADI_USER_DESC VARCHAR2(30),
ADI_ATTR01 VARCHAR2(240),
ADI_ATTR02 VARCHAR2(240),
ADI_ATTR03 VARCHAR2(240),
CREATED_BY NUMBER,
CREATION_DATE DATE,
LAST_UPDATED_BY NUMBER,
LAST_UPDATE_LOGIN NUMBER,
LAST_UPDATE_DATE DATE);
-- Create sequence & synonym
CREATE SEQUENCE CUX.CUX_WEBADI_TEST01_S;
CREATE SYNONYM APPS.CUX_WEBADI_TEST01 FOR CUX.CUX_WEBADI_TEST01;
CREATE SYNONYM APPS.CUX_WEBADI_TEST01_S FOR CUX.CUX_WEBADI_TEST01_S;
-- Create view
CREATE OR REPLACE VIEW CUX_WEBADI_TEST01_V AS
SELECT T.ADI_ID,T.ADI_CODE,T.ADI_DATE,T.ADI_USER_ID,T.ADI_USER_NAME,T.ADI_USER_DESC,
T.ADI_ATTR01,T.ADI_ATTR02,ADI_ATTR03 FROM CUX.CUX_WEBADI_TEST01 T;
-- Register table
BEGIN
AD_DD.REGISTER_TABLE('CUX','CUX_WEBADI_TEST01','T');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','ADI_ID',1,'NUMBER',38,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','ADI_CODE',2,'VARCHAR2',30,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','ADI_DATE',3,'DATE',9,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','ADI_USER_ID',4,'NUMBER',38,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','ADI_USER_NAME',5,'VARCHAR2',30,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','ADI_USER_DESC',6,'VARCHAR2',30,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','ADI_ATTR01',7,'VARCHAR2',240,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','ADI_ATTR02',8,'VARCHAR2',240,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','ADI_ATTR03',9,'VARCHAR2',240,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','created_by',10,'NUMBER',38,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','creation_date',11,'DATE',9,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','last_updated_by',12,'NUMBER',38,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','last_update_login',13,'NUMBER',38,'Y','N');
AD_DD.REGISTER_COLUMN('CUX','CUX_WEBADI_TEST01','last_update_date',14,'DATE',9,'Y','N');
COMMIT;
END;
-- Create package
CREATE OR REPLACE PACKAGE CUX_WBA_TEST01_PKG AS
g_user_id NUMBER := fnd_profile.value('user_id');
PROCEDURE import_rec(p_id IN NUMBER,
p_code IN VARCHAR2,
p_date IN DATE DEFAULT SYSDATE,
p_user_id IN NUMBER,
p_user_name IN VARCHAR2,
p_user_desc IN VARCHAR2,
p_attr01 IN VARCHAR2,
p_attr02 IN VARCHAR2,
p_attr03 IN VARCHAR2
);
END CUX_WBA_TEST01_PKG;
/
CREATE OR REPLACE PACKAGE BODY CUX_WBA_TEST01_PKG AS
PROCEDURE import_rec(p_id IN NUMBER,
p_code IN VARCHAR2,
p_date IN DATE DEFAULT SYSDATE,
p_user_id IN NUMBER,
p_user_name IN VARCHAR2,
p_user_desc IN VARCHAR2,
p_attr01 IN VARCHAR2,
p_attr02 IN VARCHAR2,
p_attr03 IN VARCHAR2) AS
BEGIN
--do any thing... ...
--通过p_id是否为0来区分insert、update,delete,方法很多。
IF nvl(p_id, 0) = 0 THEN
INSERT INTO cux_webadi_test01
SELECT cux_webadi_test01_s.nextval,
p_code,
p_date,
p_user_id,
p_user_name,
p_user_desc,
p_attr01,
p_attr02,
p_attr03,
g_user_id,
SYSDATE,
g_user_id,
-1,
SYSDATE
FROM dual;
ELSE
UPDATE cux_webadi_test01 t
SET t.adi_code = p_code,
t.adi_date = p_date,
t.last_updated_by = g_user_id,
t.last_update_date = SYSDATE
WHERE t.adi_id = p_id;
END IF;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001, 'WEBADI导入程序报错!');
END import_rec;
END CUX_WBA_TEST01_PKG;