How To Integrating Workflow and OAF
It is very simple to invoke Workflow using OAF. There are two options first using Java wrappers and second through calling PL/SQL procedures but the later approach can be used where all the code for Workflow is already ready and tested. If if it is new workflow then always better to use Java wrappers:
Following piece of code invokes the Workflow from OAF:
import oracle.apps.fnd.framework.webui.OANavigation;
public void launchWorkFlowFromOAF(OAPageContext pageContext)
{
String wfItemType = “‘XXSR'”;
String wfProcess = “‘SR_MAIN_PROCESS'”;
OADBTransaction transaction = getOADBTransaction();
String Sr_No ;
String wfItemKey = ” “;
Sr_No = pageContext.getParameter(“sr_no”);
wfItemKey = Sr_No+ transaction.getSequenceValue(“xxsr_key_s.NEXTVAL”).toString();
OANavigation wfClass = new OANavigation();
// Create Workflow Process
wfClass.createProcess(pageContext, wfItemType, wfProcess, wfItemKey);
// Set Number Attribute: SR_NO
wfClass.setItemAttrNumber( pageContext,
wfItemType,
wfItemKey,
“SR_NO”,
Sr_No );
// Start Workflow Process
wfClass.startProcess(pageContext, wfItemType, wfProcess, wfItemKey);
}
If you want to invoke this workflow using callable statement then you have to write code like this:
OAF code:
if(pageContext.getParameter(“btnSubmit”)!=null)
{ String sql = "BEGIN xx_sr_notf_pkg.invoke_wf (:1); END;"; String status = null; OracleCallableStatement cs = (OracleCallableStatement) am.getOADBTransaction().createCallableStatement(sql,1); try { cs.setString(1,srNo); cs.execute(); cs.close(); } catch (Exception ex) { throw new OAException(ex.getMessage().toString(), OAException.ERROR); } throw new OAException("SR "+srNo+" has been submitted", OAException.CONFIRMATION); } PL/SQL Code to Invoke Workflow: PROCEDURE invoke_wf (p_sr_doc_number IN VARCHAR2) IS l_item_key VARCHAR2 (50); BEGIN SELECT p_sr_doc_number || xxegasr_key_s.NEXTVAL INTO l_item_key FROM DUAL; wf_engine.createprocess ('XXSR', l_item_key, 'SR_MAIN_PROCESS'); wf_engine.setitemattrnumber(itemtype => 'XXSR', itemkey => l_item_key, aname => 'P_SR_DOC_NO', avalue => p_sr_doc_number ); wf_engine.startprocess ('XXSR', l_item_key); COMMIT; END invoke_wf;
COMMENTS