Working with Key Flex Fields in OAF

Posted by PRajkumar on Oracle Blogs See other posts from Oracle Blogs or by PRajkumar
Published on Sat, 30 Jun 2012 09:14:53 +0000 Indexed on 2012/06/30 15:21 UTC
Read the original article Hit count: 383

Filed under:

1. Create a New Workspace and Project

Right click Workspaces and click create New OA Workspace and name it as PRajkumarKFFDemo. Automatically a new OA Project will also be created. Name the project as KFFDemo and package as prajkumar.oracle.apps.fnd.kffdemo

 

2. Create a New Application Module (AM)

Right Click on KFFDemo > New > ADF Business Components > Application Module

Name -- KFFAM

Package -- prajkumar.oracle.apps.fnd.kffdemo.server

 

Check Application Module Class: KFFAMImpl Generate JavaFile(s)

 

3. Create a New View Object (VO)

Right click on KFFDemo > New > ADF Business Components > View Object

Name -- KFFVO

Package -- prajkumar.oracle.apps.fnd.kffdemo.server

 

Note - The VO is not based on any EO so click next and go to the query section and paste the query

 

SELECT  code_combination_id
FROM    gl_code_combinations_kfv

 

In Step8 Check Object Class: KFFVOImpl -> Generate Java File -> Bind Variable Accessors

 

4. Add View Object to Root UI Application Module

Right Click on KFFAM > Edit KFFAM > Data Model and shuttle KFFVO from Available View Objects to Data Model

 

5. Create a New Page

Right click on KFFDemo > New > Web Tier > OA Components > Page

Name -- KFFPG

Package -- prajkumar.oracle.apps.fnd.kffdemo.webui

 

6. Select the KFFPG and go to the strcuture pane where a default region has been created

 

7. Select region1 and set the following properties:

 

Attribute

Property

ID

PageLayoutRN

AM Definition

prajkumar.oracle.apps.fnd.kffdemo.server.KFFAM

Window Title

Key Flex Field Demo Window

Title

Key Flex Field Demo

 

 

8. Create Stack Layout Region Under Page Layout Region

Right click PageLayoutRN > New > Region

 

Attribute

Property

ID

MainRN

AM Definition

stackLayout

 


9. Create a New Item of type Flex under the Stack Layout Region

Right click on MainRN > New > Item

Set Following Properties for New Item --

 

Attribute

Property

ID

KeyFlexItem

Item Style

Flex

Prompt

Accounting Key Flex Field

Appl Short Name

SQLGL

Name

GL#

Type

Key

View Instance

KFFVO1

 

 

10. Create Controller for page KFFPG

Right Click on PageLayoutRN > Set New Controller

Package Name: prajkumar.oracle.apps.fnd.kffdemo.webui

Class Name: KFFCO

 

Write Following Code in KFFCO processRequest

 

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
 super.processRequest(pageContext, webBean);
 
 OAKeyFlexBean kffId = (OAKeyFlexBean)webBean.findIndexedChildRecursive("KeyFlexItem");
 
 // Set the code combination lov
  kffId.useCodeCombinationLOV(true);

  //set the structure code for the item key flex
   kffId.setStructureCode("FED_AFF");

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

 //Execute the Query
  KFFAMImpl am = (KFFAMImpl)pageContext.getApplicationModule(webBean);
  KFFVOImpl vo = (KFFVOImpl)am.findViewObject("KFFVO1");
     
   if(!vo.isPreparedForExecution())
  {
         vo.executeQuery();
  }
}

 

Note -- If you do not want to see the key flex field is merging one then change the code in the controller class as below

 

kffId.useCodeCombinationLOV(false);

 

11. Use the below Query to find the Structure Code

 

SELECT  fif.application_id, 
                fif.id_flex_code, 
                fif.id_flex_name, 
                fif.application_table_name,  
                fif.description, 
                fifs.id_flex_num, 
                fifs.id_flex_structure_code, 
                fifse.segment_name, 
                fifse.segment_num, 
                fifse.flex_value_set_id 
FROM     fnd_id_flexs                    fif, 
                fnd_id_flex_structures   fifs,  
                fnd_id_flex_segments    fifse 
WHERE  fif.application_id      = fifs.application_id 
AND       fif.id_flex_code         = fifs.id_flex_code 
AND       fifse.application_id   = fif.application_id 
AND       fifse.id_flex_code      = fif.id_flex_code 
AND       fifse.id_flex_num      = fifs.id_flex_num 
AND       fif.id_flex_code         LIKE 'GL#'
AND       fif.id_flex_name       LIKE 'Accounting Flexfield';

 

12. Congratulation you have successfully finished. Run Your page and Test Your Work

 

 

 

 

© Oracle Blogs or respective owner

Related posts about /Oracle