DECLARE
l_new_menu_id NUMBER;
l_last_menu_id NUMBER;
l_row_id VARCHAR2(100);
l_descr VARCHAR2(400);
l_flag_exist_menu NUMBER := 0;
lc_status VARCHAR2(1);
v_menu_id NUMBER;
v_function_id NUMBER;
v_sub_menu_id NUMBER;
CURSOR C1
IS
SELECT A.*
FROM XX_FND_MENU_ENTRIES A,
FND_MENUS B
WHERE A.MENU_NAME=B.MENU_NAME
AND (MENU_ID,ENTRY_SEQUENCE) NOT IN (SELECT MENU_ID,ENTRY_SEQUENCE FROM FND_MENU_ENTRIES_VL);
BEGIN
FOR CREC IN C1
LOOP
lc_status := 'Y';
-- get the menu_id
--
BEGIN
select menu_id
into v_menu_id
from fnd_menus
where menu_name = CREC.MENU_NAME;
Exception
When others then
dbms_output.put_line('Invalid Menu' ||CREC.MENU_NAME);
lc_status := 'E';
END;
-- get the menu_id
--
IF CREC.function_name IS NOT NULL
THEN
BEGIN
select function_id
into v_function_id
from fnd_form_functions
where function_name = CREC.function_name;
Exception
When others then
dbms_output.put_line('Invalid function_name' || CREC.function_name);
lc_status := 'E';
END;
END IF;
-- get the Sub menu_id
--
IF CREC.SUB_MENU_NAME IS NOT NULL
THEN
BEGIN
select menu_id
into v_sub_menu_id
from fnd_menus
where menu_name =CREC.SUB_MENU_NAME;
Exception
When others then
dbms_output.put_line('Invalid Sub Menu' || CREC.SUB_MENU_NAME);
lc_status := 'E';
END;
END IF;
IF lc_status <> 'E' THEN
select nvl(max(1),0) into l_flag_exist_menu
from fnd_menu_entries t
where t.menu_id = v_menu_id
and ( (v_function_id is null and t.sub_menu_id is null)
or t.sub_menu_id = v_sub_menu_id)
and ( (v_function_id is null and t.function_id is null)
or t.function_id = v_function_id)
and 1=1;
dbms_output.put_line('l_flag_exist_menu '||l_flag_exist_menu);
if (l_flag_exist_menu = 0) then
FND_MENU_ENTRIES_PKG.INSERT_ROW
(X_ROWID => l_row_id,
X_MENU_ID => v_menu_id,
X_ENTRY_SEQUENCE => crec.entry_sequence,
X_SUB_MENU_ID => v_sub_menu_id,
X_FUNCTION_ID => v_function_id,
X_GRANT_FLAG => crec.grant_flag,
X_PROMPT => crec.prompt,
X_DESCRIPTION => crec.description,
X_CREATION_DATE => sysdate,
X_CREATED_BY => fnd_global.user_id,
X_LAST_UPDATE_DATE => sysdate,
X_LAST_UPDATED_BY => fnd_global.user_id,
X_LAST_UPDATE_LOGIN => fnd_global.login_id);
dbms_output.put_line('Prompt '||CREC.prompt);
END IF;
END IF;
END LOOP;
commit;
end;
l_new_menu_id NUMBER;
l_last_menu_id NUMBER;
l_row_id VARCHAR2(100);
l_descr VARCHAR2(400);
l_flag_exist_menu NUMBER := 0;
lc_status VARCHAR2(1);
v_menu_id NUMBER;
v_function_id NUMBER;
v_sub_menu_id NUMBER;
CURSOR C1
IS
SELECT A.*
FROM XX_FND_MENU_ENTRIES A,
FND_MENUS B
WHERE A.MENU_NAME=B.MENU_NAME
AND (MENU_ID,ENTRY_SEQUENCE) NOT IN (SELECT MENU_ID,ENTRY_SEQUENCE FROM FND_MENU_ENTRIES_VL);
BEGIN
FOR CREC IN C1
LOOP
lc_status := 'Y';
-- get the menu_id
--
BEGIN
select menu_id
into v_menu_id
from fnd_menus
where menu_name = CREC.MENU_NAME;
Exception
When others then
dbms_output.put_line('Invalid Menu' ||CREC.MENU_NAME);
lc_status := 'E';
END;
-- get the menu_id
--
IF CREC.function_name IS NOT NULL
THEN
BEGIN
select function_id
into v_function_id
from fnd_form_functions
where function_name = CREC.function_name;
Exception
When others then
dbms_output.put_line('Invalid function_name' || CREC.function_name);
lc_status := 'E';
END;
END IF;
-- get the Sub menu_id
--
IF CREC.SUB_MENU_NAME IS NOT NULL
THEN
BEGIN
select menu_id
into v_sub_menu_id
from fnd_menus
where menu_name =CREC.SUB_MENU_NAME;
Exception
When others then
dbms_output.put_line('Invalid Sub Menu' || CREC.SUB_MENU_NAME);
lc_status := 'E';
END;
END IF;
IF lc_status <> 'E' THEN
select nvl(max(1),0) into l_flag_exist_menu
from fnd_menu_entries t
where t.menu_id = v_menu_id
and ( (v_function_id is null and t.sub_menu_id is null)
or t.sub_menu_id = v_sub_menu_id)
and ( (v_function_id is null and t.function_id is null)
or t.function_id = v_function_id)
and 1=1;
dbms_output.put_line('l_flag_exist_menu '||l_flag_exist_menu);
if (l_flag_exist_menu = 0) then
FND_MENU_ENTRIES_PKG.INSERT_ROW
(X_ROWID => l_row_id,
X_MENU_ID => v_menu_id,
X_ENTRY_SEQUENCE => crec.entry_sequence,
X_SUB_MENU_ID => v_sub_menu_id,
X_FUNCTION_ID => v_function_id,
X_GRANT_FLAG => crec.grant_flag,
X_PROMPT => crec.prompt,
X_DESCRIPTION => crec.description,
X_CREATION_DATE => sysdate,
X_CREATED_BY => fnd_global.user_id,
X_LAST_UPDATE_DATE => sysdate,
X_LAST_UPDATED_BY => fnd_global.user_id,
X_LAST_UPDATE_LOGIN => fnd_global.login_id);
dbms_output.put_line('Prompt '||CREC.prompt);
END IF;
END IF;
END LOOP;
commit;
end;
Thanks Abbas
ReplyDeleteThanks for u Anil can you please provide the temp table XX_FND_MENU_ENTRIES create SQL
ReplyDeleteand how you extracted it
iam facing some problem in inserting data
Sorry abbas i don't have it, Its a jsut custom table.
ReplyDeletePlease let me know what is the error you are getting..
Actually i have created a table contain all cursor data
Deletebut it given error during insertion here is the table select
create table XX_FND_MENU_ENTRIES as (
select t.menu_name,
ff.function_name,
s.l,
s.menu_id,
s.entry_sequence,
s.sub_menu_id,
s.function_id,
decode(s.function_id, null, 'MENU', 'FUNCTION') type,
substr(' ', 1, s.l * 5) || p.prompt prompt,
p.description,
S.GRANT_FLAG
from fnd_menus t,
fnd_form_functions ff,
Fnd_Menu_Entries_tl p,
(select men.menu_id,
men.entry_sequence,
men.sub_menu_id,
men.function_id,
MEN.GRANT_FLAG ,
level l
from Fnd_Menu_Entries men
where 1 = 1
start with men.menu_id in
(SELECT menu_id
FROM fnd_menus
where menu_name like 'MANU NAME')
connect by prior men.sub_menu_id = men.menu_id) s
where s.sub_menu_id = t.menu_id(+)
and s.function_id = ff.function_id(+)
and s.menu_id = p.menu_id(+)
and s.entry_sequence = p.entry_sequence(+)
and p.prompt is not null
)
I am able to create table with the same script with out any error :).
ReplyDeleteCan you send me the error please.
Good
ReplyDelete