Apps Initialization using API
CREATE OR REPLACE PROCEDURE apps_initialize
IS
v_responsibility_name VARCHAR2 (100) := 'Payables';
v_user_name VARCHAR2 (100) := 'Oracle';
v_application_id NUMBER := 0;
v_responsibility_id NUMBER := 0;
v_user_id NUMBER := 0;
v_flag NUMBER := 0;
BEGIN
--Getting Responsbility and Application Id
BEGIN
SELECT responsibility_id,
application_id
INTO v_responsibility_id,
v_application_id
FROM fnd_responsibility_tl
WHERE responsibility_name = v_responsibility_name
AND LANGUAGE = USERENV ('LANG');
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line
( 'Error in getting Responsibility information and error is '
|| SUBSTR (SQLERRM, 1, 200)
);
v_flag := 1;
END;
----Getting User Id
BEGIN
SELECT user_id
INTO v_user_id
FROM fnd_user
WHERE user_name = v_user_name;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line
( 'Error in getting User information and error is '
|| SUBSTR (SQLERRM, 1, 200)
);
v_flag := 1;
END;
IF v_flag = 0
THEN
fnd_global.apps_initialize (v_user_id,
v_responsibility_id,
v_application_id
);
END IF;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line
( 'Error in procedure apps initialize and error is '
|| SUBSTR (SQLERRM, 1, 200)
);
END;
/
IS
v_responsibility_name VARCHAR2 (100) := 'Payables';
v_user_name VARCHAR2 (100) := 'Oracle';
v_application_id NUMBER := 0;
v_responsibility_id NUMBER := 0;
v_user_id NUMBER := 0;
v_flag NUMBER := 0;
BEGIN
--Getting Responsbility and Application Id
BEGIN
SELECT responsibility_id,
application_id
INTO v_responsibility_id,
v_application_id
FROM fnd_responsibility_tl
WHERE responsibility_name = v_responsibility_name
AND LANGUAGE = USERENV ('LANG');
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line
( 'Error in getting Responsibility information and error is '
|| SUBSTR (SQLERRM, 1, 200)
);
v_flag := 1;
END;
----Getting User Id
BEGIN
SELECT user_id
INTO v_user_id
FROM fnd_user
WHERE user_name = v_user_name;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line
( 'Error in getting User information and error is '
|| SUBSTR (SQLERRM, 1, 200)
);
v_flag := 1;
END;
IF v_flag = 0
THEN
fnd_global.apps_initialize (v_user_id,
v_responsibility_id,
v_application_id
);
END IF;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line
( 'Error in procedure apps initialize and error is '
|| SUBSTR (SQLERRM, 1, 200)
);
END;
/
===========================================================
Item Import Program Using API in 11i
Item Import Program Using API in 11i
We can use the below code to Submit the Item Import Program using API.
Code is tested in 11i.
CREATE OR REPLACE PROCEDURE Item_import
IS
v_phase VARCHAR2(240);
v_status VARCHAR2(240);
v_request_phase VARCHAR2(240);
v_request_status VARCHAR2(240);
v_finished BOOLEAN;
v_message VARCHAR2(240);
l_request_id NUMBER;
BEGIN
l_request_id := Fnd_Request.submit_request (
application => 'INV',
program => 'INCOIN',
description => NULL,
start_time => SYSDATE,
sub_request => FALSE,
argument1 => 1, --Mode to run this request(Insert new cost information only)
argument2 => 1, --Group ID option (All)
argument3 => 1, -- Group ID Dummy
argument4 => 1,
argument5 => 1,
argument6 => <Group ID>, -- Group ID passed in Interface table
argument7 => <1 or 2> -- 1 for Create and 2 for Update
);
COMMIT;
IF ( l_request_id = 0 ) THEN
dbms_output.put_line( 'Submission of Import failed ');
END IF;
-- Wait for request to run the import Program to Finish
v_finished := fnd_concurrent.wait_for_request (request_id => l_request_id,
interval => 60,
max_wait => 0,
phase => v_phase,
status => v_status,
dev_phase => v_request_phase,
dev_status => v_request_status,
message => v_message);
dbms_output.put_line('Request Phase : '|| v_request_phase );
dbms_output.put_line('Request Status : ' || v_request_status );
--Testing end status
IF ( UPPER(v_request_status) = 'NORMAL') THEN
dbms_output.put_line( 'Submission of Item Import is Success ');
ELSE
dbms_output.put_line( 'Submission of Item Import failed ');
END IF;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line( 'Submission of Import failed ');
END ;
/
We can use the below code to Submit the Item Import Program using API.
Code is tested in 11i.
CREATE OR REPLACE PROCEDURE Item_import
IS
v_phase VARCHAR2(240);
v_status VARCHAR2(240);
v_request_phase VARCHAR2(240);
v_request_status VARCHAR2(240);
v_finished BOOLEAN;
v_message VARCHAR2(240);
l_request_id NUMBER;
BEGIN
--We need to apps initialize before calling the import program
--Apps Initialize is explained in another section. Check below link to know in detail
Apps Initialize;l_request_id := Fnd_Request.submit_request (
application => 'INV',
program => 'INCOIN',
description => NULL,
start_time => SYSDATE,
sub_request => FALSE,
argument1 => 1, --Mode to run this request(Insert new cost information only)
argument2 => 1, --Group ID option (All)
argument3 => 1, -- Group ID Dummy
argument4 => 1,
argument5 => 1,
argument6 => <Group ID>, -- Group ID passed in Interface table
argument7 => <1 or 2> -- 1 for Create and 2 for Update
);
COMMIT;
IF ( l_request_id = 0 ) THEN
dbms_output.put_line( 'Submission of Import failed ');
END IF;
-- Wait for request to run the import Program to Finish
v_finished := fnd_concurrent.wait_for_request (request_id => l_request_id,
interval => 60,
max_wait => 0,
phase => v_phase,
status => v_status,
dev_phase => v_request_phase,
dev_status => v_request_status,
message => v_message);
dbms_output.put_line('Request Phase : '|| v_request_phase );
dbms_output.put_line('Request Status : ' || v_request_status );
--Testing end status
IF ( UPPER(v_request_status) = 'NORMAL') THEN
dbms_output.put_line( 'Submission of Item Import is Success ');
ELSE
dbms_output.put_line( 'Submission of Item Import failed ');
END IF;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line( 'Submission of Import failed ');
END ;
/
No comments:
Post a Comment