To begin with, Account Generator Workflow needs to be customized as per the business requirement. Below is an example of PAAPINVW workflow customization -
Once Workflow is customized, below PLSQL Code is required initiate the Customized PAAPINVW Workflow and update the generated account back in database -
Pass the above retrieved variables into the below initialize procedure -
v_seq_num := FND_FLEX_WORKFLOW.INITIALIZE(v_application_short_name, v_id_flex_code, v_id_flex_num, 'PAAPINVW');
Above process internally calls 'wf_engine.CreateProcess' process as well.
Next steps, involves initializing the variables to be passed to workflow -
wf_engine.setitemattrtext (
itemtype => 'PAAPINVW' ,
itemkey => v_seq_num ,
Aname => 'PROJECT_ID' ,
avalue => v_project_id);
wf_engine.setitemattrtext (
itemtype => 'PAAPINVW' ,
itemkey => v_seq_num ,
Aname => 'TASK_ID' ,
avalue => v_task_id);
wf_engine.setitemattrtext (
itemtype => 'PAAPINVW' ,
itemkey => v_seq_num ,
Aname => 'AWARD_ID' ,
avalue => v_award_id);
wf_engine.setitemattrtext (
itemtype => 'PAAPINVW' ,
itemkey => v_seq_num ,
Aname => 'EXPENDITURE_TYPE',
avalue => v_expenditure_type);
After initializing the variables to be passed to the Workdlow, StartProcess is called to initiate the process -
wf_engine.StartProcess('PAAPINVW', v_seq_num );
Once the process is completed, account generation status and generated account is retrieved using below commands -
v_account_status := wf_engine.getitemattrtext ('PAAPINVW', x_seq_num, 'FND_FLEX_STATUS');
v_account_ccid := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_CCID');
v_account_segment := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_SEGMENTS');
v_account_data := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_DATA');
v_account_desc := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_DESCRIPTIONS');
Below SQL statement can be used to update the generated account -
UPDATE Ap_Invoice_Distributions_All
SET Dist_Code_Combination_Id = V_Account_Ccid
WHERE Invoice_Id = V_Invoice_Id
AND invoice_line_number = v_inv_line_num
AND distribution_line_number = v_distribution_line_number;
Below is the link to the details document on Account Generator.
Reference Document for Account Generator Implementation
Once Workflow is customized, below PLSQL Code is required initiate the Customized PAAPINVW Workflow and update the generated account back in database -
SELECT fa.application_short_name,
fifs.id_flex_code,
fifs.id_flex_num
INTO v_application_short_name,
v_id_flex_code,
v_id_flex_num
FROM fnd_id_flex_segments fifs,
fnd_application fa
WHERE fifs.application_id = 101
AND fifs.application_id = fa.application_id
AND id_flex_code = 'GL#'
AND enabled_flag = 'Y';
Pass the above retrieved variables into the below initialize procedure -
v_seq_num := FND_FLEX_WORKFLOW.INITIALIZE(v_application_short_name, v_id_flex_code, v_id_flex_num, 'PAAPINVW');
Above process internally calls 'wf_engine.CreateProcess' process as well.
Next steps, involves initializing the variables to be passed to workflow -
wf_engine.setitemattrtext (
itemtype => 'PAAPINVW' ,
itemkey => v_seq_num ,
Aname => 'PROJECT_ID' ,
avalue => v_project_id);
wf_engine.setitemattrtext (
itemtype => 'PAAPINVW' ,
itemkey => v_seq_num ,
Aname => 'TASK_ID' ,
avalue => v_task_id);
wf_engine.setitemattrtext (
itemtype => 'PAAPINVW' ,
itemkey => v_seq_num ,
Aname => 'AWARD_ID' ,
avalue => v_award_id);
wf_engine.setitemattrtext (
itemtype => 'PAAPINVW' ,
itemkey => v_seq_num ,
Aname => 'EXPENDITURE_TYPE',
avalue => v_expenditure_type);
After initializing the variables to be passed to the Workdlow, StartProcess is called to initiate the process -
wf_engine.StartProcess('PAAPINVW', v_seq_num );
Once the process is completed, account generation status and generated account is retrieved using below commands -
v_account_status := wf_engine.getitemattrtext ('PAAPINVW', x_seq_num, 'FND_FLEX_STATUS');
v_account_ccid := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_CCID');
v_account_segment := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_SEGMENTS');
v_account_data := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_DATA');
v_account_desc := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_DESCRIPTIONS');
Below SQL statement can be used to update the generated account -
UPDATE Ap_Invoice_Distributions_All
SET Dist_Code_Combination_Id = V_Account_Ccid
WHERE Invoice_Id = V_Invoice_Id
AND invoice_line_number = v_inv_line_num
AND distribution_line_number = v_distribution_line_number;
Below is the link to the details document on Account Generator.
Reference Document for Account Generator Implementation
No comments:
Post a Comment