PROCEDURE Submit_po_appr_proc1(p_po_header_id NUMBER,
po_release_id NUMBER)
AS
v_item_key VARCHAR2(100);
v_resp_id NUMBER;
v_resp_appl_id NUMBER;
v_po_release_id NUMBER := po_release_id;
po_status VARCHAR2(100);
po_msg VARCHAR2(2000);
ln_request_id NUMBER;
CURSOR c_po_details IS
SELECT DISTINCT PHA.org_id,
pdt.document_subtype,
pdt.document_type_code,
PHA.created_by,
pha.authorization_status,
pha.agent_id,
pha.segment1,
pha.po_header_id
FROM apps.po_headers_all PHA,
apps.po_releases_all PRA,
apps.po_document_types_all PDT
WHERE 1 = 1
AND CASE
WHEN PHA.type_lookup_code = 'PLANNED'
AND v_po_release_id IS NOT NULL THEN 'SCHEDULED'
ELSE PHA.type_lookup_code
END = pdt.document_subtype
AND PHA.org_id = PDT.org_id
AND PHA.po_header_id = PRA.po_header_id(+)
AND PDT.document_type_code = CASE WHEN pha.type_lookup_code = 'PLANNED' AND v_po_release_id IS NULL THEN 'PO'
WHEN PHA.type_lookup_code = 'PLANNED' AND v_po_release_id IS NOT NULL THEN 'RELEASE'
WHEN PHA.type_lookup_code = 'STANDARD' THEN 'PO'
WHEN PHA.type_lookup_code = 'BLANKET' AND v_po_release_id IS NOT NULL THEN 'RELEASE'
WHEN PHA.type_lookup_code = 'BLANKET' AND v_po_release_id IS NULL THEN 'PA'
END
AND PHA.po_header_id = p_po_header_id
AND ( PRA.po_release_id = v_po_release_id OR v_po_release_id IS NULL );
BEGIN
FOR p_rec IN c_po_details LOOP
SELECT fresp.responsibility_id,
fresp.application_id
INTO v_resp_id, v_resp_appl_id
FROM fnd_responsibility_tl fresp
WHERE fresp.responsibility_name LIKE '<RESPONSIBILITY_NAME>'
AND LANGUAGE = Userenv('LANG');
apps.mo_global.Init ('PO');
fnd_global.Apps_initialize (user_id => p_rec.created_by, resp_id => v_resp_id, resp_appl_id => v_resp_appl_id);
mo_global.Set_policy_context ('S', p_rec.org_id);
SELECT p_rec.po_header_id
||'-'
||To_char(po_wf_itemkey_s.NEXTVAL)
INTO v_item_key
FROM dual;
dbms_output.Put_line ( ' Calling po_reqapproval_init1.start_wf_process for po_id=>' || p_rec.segment1);
po_reqapproval_init1.Start_wf_process(
itemtype => 'POAPPRV',
itemkey => v_item_key,
workflowprocess => 'POAPPRV_TOP',
actionoriginatedfrom => 'PO_FORM',
documentid => Nvl(v_po_release_id, p_po_header_id),
documentnumber => p_rec.segment1, -- Purchase Order Number
preparerid => p_rec.agent_id, -- Buyer/Preparer_id
documenttypecode => p_rec.document_type_code,--'PO'
documentsubtype => p_rec.document_subtype, --'STANDARD'
submitteraction => 'APPROVE',
forwardtoid => NULL,
forwardfromid => NULL,
defaultapprovalpathid => NULL,
note => NULL,
printflag => 'N',
faxflag => 'N',
faxnumber => NULL,
emailflag => 'N',
emailaddress => NULL,
createsourcingrule => 'N',
releasegenmethod => 'N',
updatesourcingrule => 'N',
massupdatereleases => 'N',
retroactivepricechange => 'N',
orgassignchange => 'N',
communicatepricechange => 'N',
p_background_flag => 'N',
p_initiator => NULL,
p_xml_flag => NULL,
fpdsngflag => 'N',
p_source_type_code => NULL);
COMMIT;
dbms_output.Put_line ('The PO which is Approved Now =>' || p_rec.segment1);
END LOOP;
fnd_file.Put_line(fnd_file.log, 'Status:' ||po_status);
fnd_file.Put_line(fnd_file.log, 'Message:' ||po_msg);
EXCEPTION
WHEN OTHERS THEN
po_status := 'E';
po_msg := 'Error' ||' '|| SQLERRM;
fnd_file.Put_line(fnd_file.log, 'Status:' ||po_status);
fnd_file.Put_line(fnd_file.log, 'Message:' ||po_msg);
END submit_po_appr_proc;
I am hoping to check out the same high-grade content by you later on as well. In truth, your creative writing abilities has inspired me to get my own, personal blog now..
ReplyDeleteProcurement Management Software
Purchase Management Software
e Procurement Management Software
Procurement Tracking Software