会有po通信输出
DECLARE
l_return NUMBER := NULL;
l_p_api_version_number NUMBER := '1';
x_api_errors po_api_errors_rec_type;
j NUMBER;
v_item_key VARCHAR2(100);
l_user_id NUMBER;
l_resp_id NUMBER;
l_app_id NUMBER;
stat BOOLEAN;
cursor c1 is
select distinct pha.segment1,pha.agent_id,pha.po_header_id,pha.authorization_status
from po_headers_all pha,
po_lines_all pla/*,
cux.cux_po_hy_20201001_t t*/
where pha.po_header_id = pla.po_header_id
and pha.currency_code <> 'USD'
and pha.org_id = 625
--and pla.po_line_id = t.po_line_id
-- and pha.creation_date < to_date('20201001', 'yyyymmdd')
-- and pha.authorization_status <> 'APPROVED'
-- and t.unit_price is not null
BEGIN
/* SELECT user_id INTO l_user_id FROM fnd_user WHERE user_name = 'E3509465';
SELECT application_id, responsibility_id
INTO l_app_id, l_resp_id
FROM fnd_responsibility
WHERE responsibility_key = 'XX_EEAE_FZE_PO_BUYER';*/
--setting context ZNPOWX2000000622
fnd_global.apps_initialize(1462, 52360, 201);
Mo_Global.Init('PO');
mo_global.set_policy_context('S', 625);
for v1 in c1 loop
SELECT 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 => v1.po_header_id,
documentnumber => v1.segment1,
preparerid => v1.agent_id,
documenttypecode => 'PO', --PO or PA
documentsubtype => 'STANDARD', --STANDARD or BLANKET
submitteraction => 'APPROVE',
forwardtoid => NULL,
forwardfromid => NULL,
defaultapprovalpathid => 10,
note => 'for_update_hy_unit_price',
printflag => 'N',
faxflag => NULL,
faxnumber => NULL);
COMMIT;
end loop;
END;