Você está na página 1de 2

CREATE OR REPLACE procedure JOURNAL_WF_APPROVAL_STRUCK

( p_errbuf OUT NOCOPY VARCHAR2 ,p_retcode OUT NOCOPY


NUMBER ,p_restart In VARCHAR2 ,p_je_batch_id NUMBER)
IS
v_je_batch_id GL_JE_BATCHES.JE_BATCH_ID%type;
v_prev_je_batch_id GL_JE_BATCHES.JE_BATCH_ID%type:=0;
v_batch_name GL_JE_BATCHES.NAME%type;
v_period_name GL_JE_BATCHES.DEFAULT_PERIOD_NAME%type;
v_msg varchar2(200);
v_item_key WF_ITEMS.ITEM_KEY%type;
v_item_type WF_ITEMS.ITEM_TYPE%type;
v_cnt NUMBER(10):=0;
CURSOR ERROR_JE_APPRV IS
select b.je_batch_id,b.name,b.DEFAULT_PERIOD_NAME,
substr(A.context,instr(A.context,':',1)+1,instr(A.context,':',1,2)-
instr(A.context,':',1)-1) item_key,A.message_type
from wf_notifications A,
GL_JE_BATCHES B
where A.message_type='GLBATCH'
and A.STATUS='OPEN'
and A.message_name in
('GL_NO_EMPLOYEE',
'NOTIFY_PREPARER_NO_APPROVER',
'NOTIFY_PREPARER_OF_INVALID_JE',
'NO_APPROVER',
'NO_APPROVER_MANAGER',
'NOTIFY_PREPARER_OF_REJECTION')
and B.approval_status_code='I'
and
B.JE_BATCH_ID=substr(A.context,instr(A.context,':',1)+1,instr(A.context,'*',1)-
instr(A.context,':',1)-1)
and B.JE_BATCH_ID=nvl(p_je_batch_id,B.JE_BATCH_ID)
ORDER BY 1,4 desc;
BEGIN
v_msg:=('Journal Batch Name
'||'Period Name ');
If p_restart ='Y' then
fnd_file.put_line(FND_FILE.Output,'Wokflow has been restarted for following
journal batches');
else
fnd_file.put_line(FND_FILE.Output,'Approval status Has been reset to required
for following journal batches');
end if;
fnd_file.put_line(FND_FILE.Output,null);
fnd_file.put_line(FND_FILE.Output,v_msg);
fnd_file.put_line(FND_FILE.Output,'=================
'||'=========== ');
FOR C1 IN ERROR_JE_APPRV LOOP
v_je_batch_id:=C1.je_batch_id;
v_batch_name:=C1.name;
v_item_type:=C1.message_type;
v_item_key:=C1.item_key;
v_period_name:=C1.default_period_name;
v_cnt:=v_cnt+1;
IF v_prev_je_batch_id<>v_je_batch_id then
If p_restart ='Y' then
wf_engine.startprocess(v_item_type,v_item_key);
commit;
fnd_file.put_line(FND_FILE.Log,'Work flow has been started Successfully');
else
fnd_file.put_line(FND_FILE.Output,'Approval status Has been reset to required
for following journal batches');
update GL_JE_BATCHES
set approval_status_code='R'
where je_batch_id=v_je_batch_id;
commit;
fnd_file.put_line(FND_FILE.Log,'Batch status has been updated Successfully');
end if;
fnd_file.put_line(FND_FILE.Output,v_batch_name||'
'||v_period_name||' ');
end if;
v_prev_je_batch_id:=v_je_batch_id;

END LOOP;
if v_cnt=0 then
fnd_file.put_line(FND_FILE.Log,'There are no errorneous journals');
fnd_file.put_line(FND_FILE.Output,'There are no errorneous journals');
end if;
p_retcode:=0;
EXCEPTION
when others then
p_errbuf:=sqlerrm;
fnd_file.put_line(FND_FILE.Log,'Job Ended in error'||SQLERRM);
p_retcode:=1;
END;
/

Você também pode gostar