Script to Approve PO Requisition

Script to Approve PO Requisition, www.askhareesh.com

DECLARE
v_itemkey VARCHAR2 (200);
v_po_id NUMBER := :PO_HEADER_ID;
v_po_number VARCHAR2 (200) := :REQUISITION_NUMBER;
BEGIN
        SELECT v_po_id || '-' || TO_CHAR (po_wf_itemkey_s.NEXTVAL)
        INTO v_itemkey
        FROM DUAL;

        wf_engine.createprocess ('REQAPPRV',
        v_itemkey,
        'MAIN_REQAPPRV_PROCESS',
        NULL,
        :USER_NAME
        );
        
        wf_engine.setitemattrnumber (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'RESPONSIBILITY_ID',
        avalue => :RESPONSIBILITY_ID
        );
        
        wf_engine.setitemattrnumber (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'APPLICATION_ID',
        avalue => :APPLICATION_ID
        );
        
        wf_engine.setitemattrnumber (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'USER_ID',
        avalue => :USER_ID
        );
        
        wf_engine.setitemattrnumber (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'SUBMITTER_ID',
        avalue => :BUYER_ID
        );
        
        wf_engine.setitemattrnumber (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'DOCUMENT_ID',
        avalue => v_po_id
        );
        
        wf_engine.setitemattrtext (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'DOCUMENT_NUMBER',
        avalue => v_po_number
        );
        
        wf_engine.setitemattrnumber (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'ORG_ID',
        avalue => :ORG_ID
        );
        
        wf_engine.setitemattrtext (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'DOCUMENT_SUBTYPE',
        avalue => 'PURCHASE'
        );
        
        wf_engine.setitemattrtext (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'DOCUMENT_TYPE',
        avalue => 'REQUISITION'
        );
        
        wf_engine.setitemattrtext (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'DOCUMENT_TYPE_DISP',
        avalue => 'Purchase Requisition'
        );
        
        wf_engine.setitemattrtext (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'AUTHORIZATION_STATUS',
        avalue => 'APPROVED'
        );
        
        wf_engine.setitemattrtext (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'AUTHORIZATION_STATUS_DISP',
        avalue => 'Approved'
        );
        
        wf_engine.setitemattrtext (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'SEND_CREATEPO_TO_BACKGROUND',
        avalue => 'Y'
        );
        
        wf_engine.setitemattrtext (itemtype => 'REQAPPRV',
        itemkey => v_itemkey,
        aname => 'INTERFACE_SOURCE_CODE',
        avalue => 'PO_FORM'
        );

        DBMS_OUTPUT.put_line (v_itemkey);
        wf_engine.startprocess ('REQAPPRV', v_itemkey);
        COMMIT;
END;




*/