Showing posts with label Segment. Show all posts
Showing posts with label Segment. Show all posts

Sunday, 5 June 2016

OAF - Account Generator Implementation (PAAPINVW examples)

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 - 


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

OAF - GL Diistribution DFF field on OAF page

This post will details the steps required for enabling the functionality of GL DFF as below - 



First step, create a field on OAF page with item type as 'Flex' in a table or region. Attributes of this Flex item needs to be set as below - 




Segment List property value need to setup as below - 



** Here ACCOUNTING_FLEXFIELD is the name of the accounting flexfield defined for GL and can be obtained using below query - 

select id_flex_structure_code, id_flex_code from fnd_id_flex_structures where id_flex_code = 'GL#';

Above field is created in a Advanced table. If you are using a normal OAF table then you will need to populate the VO Instance name of the flex item as well.


Second step, which needs to be performed is adding following code in the processRequest method of the Controller java file - 

OAApplicationModule am = pageContext.getApplicationModule(webBean);

OAKeyFlexBean kffId = (OAKeyFlexBean)webBean.findIndexedChildRecursive("AccountCol");

// Set the code combination lov
kffId.useCodeCombinationLOV(true);

// Set the structure code for the item key flex
kffId.setStructureCode("ACCOUNTING_FLEXFIELD");

// Set the attribute name to the item
kffId.setCCIDAttributeName("DistCodeCombinationId");

Performing the above mentioned steps will help meet the requirement of creating and displaying the GL DFF field on an OAF page.