在做AP发票审批驳回时,客户要求必须强制输入拒绝原因,代码如下:

PROCEDURE Validate_Response
(
Itemtype IN VARCHAR2,
Itemkey IN VARCHAR2,
Actid IN NUMBER,
Funcmode IN VARCHAR2,
Resultout IN OUT VARCHAR2
) IS l_Nid NUMBER;
l_Approval_Comments VARCHAR2(2000);
l_Next_Appr_Level NUMBER;
l_Activity_Result_Code VARCHAR2(200);
l_Activity_Result VARCHAR2(200);
l_Activity VARCHAR2(100);
v_Response_Reason VARCHAR2(50);
l_Display_Name VARCHAR2(100);
l_Role VARCHAR2(100); BEGIN l_Activity := Wf_Engine.Getactivitylabel(Actid => Actid); IF (Funcmode IN ('RESPOND')) THEN l_Nid := Wf_Engine.Context_Nid;
l_Activity_Result_Code := Wf_Notification.Getattrtext(l_Nid, 'RESULT');
v_Response_Reason := Wf_Notification.Getattrtext(l_Nid, 'WF_NOTE'); IF l_Activity_Result_Code = 'REJECTED' AND v_Response_Reason IS NULL THEN
Resultout := 'ERROR: You must enter a rejection note.';
Raise_Application_Error(-20000, 'ERROR: You must enter a rejection note.');
--RETURN;
ELSIF l_Activity_Result_Code = 'REJECTED' AND v_Response_Reason IS NOT NULL THEN
--Do something if the notification is rejected and the rejection reason is entered by the approver
NULL;
END IF; Wf_Engine.Setitemattrtext(Itemtype => Itemtype,
Itemkey => Itemkey,
Aname => 'APPROVAL_RESULT',
Avalue => l_Activity_Result_Code);
Wf_Engine.Setitemattrtext(Itemtype => Itemtype,
Itemkey => Itemkey,
Aname => 'APPROVAL_COMMENTS',
Avalue => v_Response_Reason);
Resultout := 'COMPLETE:Reject';
ELSE
NULL;
END IF; EXCEPTION
WHEN OTHERS THEN
Resultout := SQLERRM; END Validate_Response;
04-15 08:48