In this Article, we will see how to display Key Flex Fields in OAF Pages.
Lets assume that the requirement is to display the Accounting Flex Field in an OAF Page.
OAF provides some inbuilt APIs to display the KFF as a concatenated segments or as individual segments.
Approach 1: KFF Field as concatenated segments
In this approach,the KFF will be shown as concatenated segment. See the image below
Approach 2: KFF Field as distinct segments
In this approach,the KFF will be shown as individual segments. See the image below ... kindly ignore the warning message in the image.
Steps to Create a OAF page with KFF
Step 1:
Create VO from GL_CODE_COMBINATIONS table with the following:
VO Name: GLCodeCombinationsVO
Query: select code_combination_id from gl_code_combinations_kfv
Attribute Name: CodeCombinationId
Step 2:
Create an AM and attach GLCodeCombinationsVO to it.
Step 3:
Create a OA Page with two items pointing to same VO attribute. The item will be of type "flex" and there will not be any difference between the 2 items in XML. All the properties will be set in the Controller code.The XML will look something like:
<ui:contents>
<oa:header id="HeaderRN" text="CCID LOV Enabled" rendered="true">
<ui:contents>
<oa:flex id="item3" viewName="GLCodeCombinationsVO1" flexFieldAppShortName="SQLGL" flexName="GL#" flexStyle="key"/>
</ui:contents>
</oa:header>
<oa:defaultSingleColumn id="SingleColRN" rendered="true" text="CCID LOV Disabled">
<ui:contents>
<oa:flex id="item2" viewName="GLCodeCombinationsVO1" flexFieldAppShortName="SQLGL" flexName="GL#" flexStyle="key"/>
</ui:contents>
</oa:defaultSingleColumn>
</ui:contents>
Step 4:
Generate a Controller for the OA Page and set the FlexField Properties for the items in the Process Request as follows:
public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
super.processRequest(pageContext, webBean);
//Get the handle to the first item
OAKeyFlexBean CCIDlovEnabledKFF = (OAKeyFlexBean)webBean.findIndexedChildRecursive("item3");
//Set the KFF item property to have a concatenated segment display.
CCIDlovEnabledKFF.useCodeCombinationLOV(true);
//Set the KFF Name
CCIDlovEnabledKFF.setAttributeValue(FLEXFIELD_NAME, "GL#");
//Set the KFF Structure
CCIDlovEnabledKFF.setStructureCode("XXX_ACCOUNTING_FLEXFIELD");
//Set the VO attribute name to the item
CCIDlovEnabledKFF.setCCIDAttributeName("CodeCombinationId");
CCIDlovEnabledKFF.mergeSegmentsWithParent(pageContext);
OAKeyFlexBean CCIDlovDisabledKFF =
(OAKeyFlexBean)webBean.findIndexedChildRecursive("item2");
//Set the KFF item property to have a distinct segment display
CCIDlovDisabledKFF.useCodeCombinationLOV(false);
CCIDlovDisabledKFF.setAttributeValue(FLEXFIELD_NAME, "GL#");
CCIDlovDisabledKFF.setStructureCode("XXX_ACCOUNTING_FLEXFIELD");
CCIDlovDisabledKFF.setCCIDAttributeName("CodeCombinationId");
CCIDlovDisabledKFF.mergeSegmentsWithParent(pageContext);
//Execute the Query so that we will have some data in VO while we run the page.
OAApplicationModule am = pageContext.getApplicationModule(webBean);
OAViewObject sampleViewObject =
(OAViewObject)am.findViewObject("GLCodeCombinationsVO1");
sampleViewObject.executeQuery();
}
Step 5:
Run the page and you will have the output as:
when you click the LOV next to the concatenated display of the KFF item, you will get a popup window which will be like image below. You have an option to create a new record as well.
When you click on the LOV next to distinct segments (Company for example) it will behave like a normal LOV and it will bring all Valid values for that Segment from the corresponding Flex field Value set.
Please feel free to post your comments.
Comments
Hope you remember me, I am from KCT (mechatronics). Thats a nice article, please mail me I would like to have soem doubts clarified on OAF front.
Bye.
TC
Very useful article. I have one doubt in Key Flexfield. I have KFF displayed as individual segment in my page. I want to make one of the segment readonly with some default value. How can I immplement this?..
Eg: In the following KFF, I want to make Account segment readonly with the value 6700.
Company-
Department-
Acc ount- 6700
Sub-Accoun t-
Product
Ple ase mail me the code if possible.
Than ks
Gomathi
You can set the Default value using the following API oracle.apps.fnd .flexj.Segment. setDisplay() / setValue()
But I dont think that you cannot make a particular segment to ReadOnly. You can give a try by changing the "Displayed" flag in AOL Forms.
Also You can make entire KFF readonly in OAF pages using oracle.apps.fnd .flexj.KeyFlexf ield.setDynamic Insertion()
Ho pe this helps.
Thanks and Regards,
Senthi l
Your example talks about KFF display, how do we do the same for Descriptive flex fields please?
Can you elaborate the steps?
Thanks
Sheena
I am planning to write an article on DFF sooner.
Thanks and Regards,
Senthi l
Is there a way using which I can make 1 segment of KFF mandatory in OA Fwk?
Regards
J ujaar
There is a property called "Segment List" for FlexField Bean
You can add the read-only token ($RO$) after any of the segments in the list. For example, the ($RO$) designator below sets Segment1 in structure code 1 to be read-only:
Str ucture code1|Segment1( $RO$)|Segment2. ..
Thanks and Regards,
Senthi l
Sorry I misread as "Readonly" instead of "Mandatory"
Th e "Mandatory" property is derived from the Metadata of the KFF. I am afraid that the UI has no control over the mandatory feature.
Thank s and Regards,
Senthi l
Thank s for updates !!!
Yes,I thought so that u have mis read it .
Even I looked at all the methods of OAKeyFlexBean and culdnt find anything relevant.
Than ks anyways.
But did u try $RO$.I tried it once...Dint work..
Cheers
Jujaar
Thanks for your response. My only issue is that the DFF does not display on the page and there is an error but no description on what the error is!
The page is fine as long as the flex item type is not created on the page. The minute I add it, the other items show on the page and there is an 'Error' on the top of the page and the DFF does not show. I followed the steps as per the the OA Developers Guide.
I am trying to display the organization DFF from HR and using Jeveloper 9i. Any insight will be appreciated!
T hanks
Sheena
Can you please paste your code for CO and the declaration on PG.xml file?
Thanks and Regards,
Senthi l
Here is the code from the PG.xml file:
************** ******
-
-
-
-
-
-
-
-
-
-
-
************** **
The code from CO's process request method:
************** ******
public void processRequest( OAPageContext pageContext, OAWebBean webBean)
{
super.processRe quest(pageConte xt, webBean);
System.out.prin tln("in process request1");
String org = pageContext.get Parameter("orgN ame");
OAApplicationMo dule am = pageContext.get ApplicationModu le(webBean);
System.out.prin tln("in process request1");
am.invokeMethod ("initDetails") ;
System.out.prin tln("in process req"+org);
}
************* *************** ***
Once I migrated the code to apps, the page works fine, within jdeveloper it did not.
Thanks !
Sheena
I am facing an issue regarding keyflexfield , i want to set values for key flex segments upon a lov select event. I have tried almost every relavant method in flexj.keyflexfi eld.
Interesting fact is if i use setCCId(int), the description shows up but the segment value doesn't appear. I even tried setStorage,setV alue,setDisplay for segment, but no help
please suggest/advice. ur help will be highly appreciated.
T hanks,
Imran
i'm a new user of ur site
can u help me on that topic
i want record in GL
'''''' undefined accounting periods in the current accounting calendar '''''''''''
help me
thanks
Hope u r fine. I followed the Steps to Create a OAF page with KFF as said by u. I am getting the following errror :
java.lang.Nul lPointerExcepti on
at oracle.apps.ak. sampleworks.web ui.SampleWorkPG CO.processReque st(SampleWorkPG CO.java:37)
T he code in line 37 as per the error is
CCIDlovEnable dKFF.useCodeCom binationLOV(tru e);
Please help me to solve the error.
I guess, your program was not able to get handle to the KFF "CCIDlovEnabled KFF". Can you please check if the KFF name is correct?
Thank s and Regards,
Senthi l
Kindly refer to the folloeing Code Snippet in my article.
" //Set the KFF Name
CCIDlovEnabledK FF.setAttribute Value(FLEXFIELD _NAME, "GL#");
//Set the KFF Structure
CCIDlovEnabledK FF.setStructure Code("XXX_ACCOU NTING_FLEXFIELD ");
"
Hope this helps.
Thanks and Regards,
Senthi l
In the query to handle to the first item the query u gave is
OAKeyFlexBean CCIDlovEnabledK FF = (OAKeyFlexBean) webBean.findInd exedChildRecurs ive("item3");
My item name is item1. So i changed as
OAKeyFlexBean CCIDlovEnabledK FF = (OAKeyFlexBean) webBean.findInd exedChildRecurs ive("item1");
Now i am getting the following error :
java.lang.Cl assCastExceptio n: oracle.apps.fnd .framework.webu i.beans.OADescr iptiveFlexBean
at oracle.apps.ak. sampleworks.web ui.SampleWorkPG CO.processReque st(SampleWorkPG CO.java:35)
Pl ease help me.
This article speaks about KeyFF and I guess you are trying out with DFF.
You can use our forum
http://apps2fusion.com/forums/viewforum.php?f=3&sid=53013814bdf2d70265a2a7c3dc50a6fe
to upload your code. we will have a look at get back to you. It will reach wider audience as well.
Thanks for your cooperation and understanding.
Regards,
Senth il
After the page gets opened the following error occurs :
Error
Flexfield routine KeyFlexfieldDef initionFactory. createDefinitio n cannot find flexfield definition for application , and code .
Flexfield routine KeyFlexfieldDef initionFactory. createDefinitio n cannot find flexfield definition for application , and code GL#.
I would like to have a look on your code.
Also plese gie the details of FF which you are trying to add in th page.
Thanks and Regards,
Senthi l
I have set the View Instance property as GLCodeCombinati onsVO1.
My code is :
/*========== =============== =============== =============== =============== =====+
| Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA |
| All rights reserved. |
+============== =============== =============== =============== =============== =+
| HISTORY |
+============== =============== =============== =============== =============== =*/
package oracle.apps.ak. sampleworks.web ui;
import oracle.apps.fnd .common.Version Info;
import oracle.apps.fnd .framework.OAAp plicationModule ;
import oracle.apps.fnd .framework.OAVi ewObject;
impor t oracle.apps.fnd .framework.webu i.OAControllerI mpl;
import oracle.apps.fnd .framework.webu i.OAPageContext ;
import oracle.apps.fnd .framework.webu i.beans.OAKeyFl exBean;
import oracle.apps.fnd .framework.webu i.beans.OAWebBe an;
/**
* Controller for ...
*/
public class SampleWorkPGCO extends OAControllerImp l
{
public static final String RCS_ID="$Header $";
public static final boolean RCS_ID_RECORDED =
VersionInfo.rec ordClassVersion (RCS_ID, "pa;ckagenam e%");
/**
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processRequest( OAPageContext pageContext, OAWebBean webBean)
{
super.processRe quest(pageConte xt, webBean);
//Get the handle to the first item
OAKeyFlexBean CCIDlovEnabledK FF = (OAKeyFlexBean) webBean.findInd exedChildRecurs ive("item1");
//Set the KFF item property to have a concatenated segment display.
CCIDlovEnabledK FF.useCodeCombinationLOV(true);
//Set the KFF Name
CCIDlovEnabledK FF.setAttributeValue(FLEXFIELD_NAME, "GL#");
//Set the KFF Structure
CCIDlovEnabledK FF.setStructureCode("XXX_ACCOUNTING_FLEXFIELD");
//Set the VO attribute name to the item
CCIDlovEnabledK FF.setCCIDAttributeName("CodeCombinationId");
CCIDlovEnabledK FF.mergeSegmentsWithParent(pageContext);
OAKeyFlexBean CCIDlovDisabled KFF =
(OAKeyFlexBean) webBean.findInd exedChildRecurs ive("item2");
//Set the KFF item property to have a distinct segment display
CCIDlovDisabled KFF.useCodeCombinationLOV(false);
CCIDlovDisabled KFF.setAttributeValue(FLEXFIELD_NAME, "GL#");
CCIDlovDisabled KFF.setStructureCode("XXX_ACCOUNTING_FLEXFIELD");
CCIDlovDisabled KFF.setCCIDAttributeName("CodeCombinationId");
CCIDlovDisabled KFF.mergeSegmentsWithParent(pageContext);
//Execute the Query so that we will have some data in VO while we run the page.
OAApplicationMo dule am = pageContext.get ApplicationModu le(webBean);
OAViewObject sampleViewObjec t =
(OAViewObject)a m.findViewObjec t("GLCodeCombin ationsVO1");
sampleViewObjec t.executeQuery();
}
/**
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processFormRequ est(OAPageConte xt pageContext, OAWebBean webBean)
{
super.processFo rmRequest(pageC ontext, webBean);
}
}
Can you please confirm that you have a KFF named "GL#" and KFF Structure named "XXX_ACCOUNTING _FLEXFIELD"?
T hanks and Regards,
Senthi l
i was getting a similar error. However when you define item1 and item2 and change the 'item style' to 'flex', the default value for 'type' in section 'Flexfields' of properties is set to 'descriptive'. you need to change this value to 'key'.
senthil - however when i do the above, the page renders, but i get the error message:
Error
Flex VO () of flex bean (item2) is null.
Flex VO () of flex bean (item1) is null.
could you please help me out.
thanks
sa chin
Have you attached the FlexVO to the AM?
Can you check whether you are able to get the handle to FlexVO in the controller code?
Thanks and Regards,
Senthi l
Yes ... the FlexVO is attached to the AM.
yes am able to get the handle to FlexVO in the controller code.
Regards
sachin
Can you please upload your source code (AM, VO,PG,CO). I would like to have a look.
You can use our forum to uplaod the files.
http://apps2fusion.com/forums/viewforum.php?f=3
Thanks and Regards,
Senthi l
I have a varchar2 column in a VO. This field will store the credit limit of a customer. I want to display this column in a formatted manner.
like if the column value is 10000 , i want to dispaly it as 10,0000 . I have seen few threads it seems it is not possible to formatte a varchar2 column.
Can u suggest me to overcome this issue
you can try this for formatting
OAMessageStyled TextBean styledText =
(OAMessageStyled TextBean)webBean.findChildRecursive("Amt");
if (styledText != null)
{
styledText.setA ttributeValue(O AWebBeanConstan ts.CURRENCY_COD E,"USD");
}
I have tried the above befor. the above is right aliging the attribute, but not displaying in the requried format.
will really hit a performance in a prod env since you are not using any CHART_OF_ACCOUN TS_ID filter here.
Plus try to replace the SQL with - select 1 from dual and try, your KFF will still work.
Thanks for pointing that out ... can you please post the SQL?
Thanks and Regards,
Senthi l
We have extended a VO on the view invoices page in iSupplier to add the flexfield related fields, i.e. attribute_categ ory and atrribute1-15. A flex item is created on the page.But the flefield details are not displayed when the invoice is searched.after the invoice serach if I navigate to the personalization page , using the personalize page link and return to the page without doing anything, the DFFs are displayed. Can you olease suggest what could be the problem.
Thank s
Kashyap
I hope you still remember me....
Anyways just replace the KFF VO query with -> "SELECT 1 FROM DUAL" and keep rest all coding as it is and try.
Cheers,
K amleshwar Chopra
Of course I remember you Mr.GL Expert
Cheers,
Senthil
you said to Gomathi,
//Hi Gomathy,
You can set the Default value using the following API oracle.apps.fnd .flexj.Segment. setDisplay() / setValue()
//
But, how can i use it in forms request.... my requirement is, I want to set the default value to the KFF segment1 from other field.... Is it possible ??
My page is classic table based (row by row)
Please advise... It would be great if you can send any piece of code.
You can acheive it using Partial Page Rendering or by passing the other fields value and redirecting to same page so that you can catch it in the Process Request.
Hope this helps.
Thanks and Regards,
Senthi l
I have requirement where I need to add DFF to delivered Oracle application.
Bu t the issue I am facing is when I add this DFF it is left aligned. Is there a any way I can arrange the field in central?
Thank s in advance
I reckon you might have added DFF using personalization .
In that case, you can add a stack layout region and then inside that region try adding the new DFF and let us know whether it worked
Thanks and Regards,
Senthi l
Hi,
I am new to OAF development. I am developing new OAF page and my requirement is to add Item Category KFF to OAF page. Can you help on this?
Thanks in Advance.
Raju
I am writing code to display key flex field, I have done the part as per you screenshot 1 but I am stuck on how to display Flex for individual segment(in my case Cost Center).
I search and found that we need to define property in particular format. like SturctureCode|C ost Center in our Item properties.
It is so, how do I need to derive cost center using some pre defined flex methods or only change in Property will work.
Thanks
Ankur
How to make a KFF segment in SIT readonly from form level. Please help me out, if you have a solution.
Hi,
There is a property called "Segment List" for FlexField Bean
You can add the read-only token ($RO$) after any of the segments in the list. For example, the ($RO$) designator below sets Segment1 in structure code 1 to be read-only:
Structure code1|Segment1( $RO$)|Segment2. ..
Thanks and Regards,
Senthil
hot to override segements values in key flex fields.
i am using the following code
for(int l = 0; l < keyflexfield.ge tSegmentCount() ; l++)
{
keyflexfield.se tDynamicInserti on(true);
Segment segment = keyflexfield.ge tSegment(l);
if(oapagecontex t.isLoggingEnab led(1))
{
oapagecontext.w riteDiagnostics (this, "####### segment.getInpu tValue()-->" + segment.getInpu tValue(), 1);
oapagecontext.w riteDiagnostics (this, "####### segment.getInpu tValue()-->" + segment.getValu e(), 1);
}
try
{
segment.setDisp layed(true);
segment.setValu e("00");
segment.setDisp lay("00");
segment.setStor age("00");
continue;
}
catch(Exception e)
{
if(oapagecontex t.isLoggingEnab led(1))
{
oapagecontext.w riteDiagnostics (this, "####### exception)--> ;" + e, 1);
}
}
}
colud you please give the solution.
Step 3 in my article http://apps2fusion.com/at/ss/453-oaf-extension-case-study has a sample code for your requirement.
H ope this helps.
Thanks and Regards,
Senthi l
how can we implement same on a standard self-serice page. I mean i have a requirment like need to invoke the key flexfield from a segment of DFF.
how to do this. I have added the DFF already to OAF page. but no idea how to attach key flex field to segment of that DFF. Any help is highly appreciated.
I’ve set the properties like as below:
Item Style: Flex
Applicatio n Short Name: SQLGL
Name: GL#
Type: Key
VO created:
Name: GLCodeCombinati onsVO
Query: SELECT CODE_COMBINATIO N_ID FROM GL_CODE_COMBINA TIONS_KFV
Code Added in CO Process Request:
OAKeyFlexBean KFFBean = (OAKeyFlexBean) webBean.findInd exedChildRecurs ive("mbcDefDist r");
KFFBean.useCode CombinationLOV( true);
KFFBean.setAttr ibuteValue(FLEX FIELD_NAME, "GL#");
KFFBean.setStru ctureCode("XX_M BC");
KFFBean.setCCID AttributeName(" CodeCombination Id");
KFFBean.mergeSe gmentsWithParen t(pageContext);
OAViewObject sampleViewObjec t = (OAViewObject)am.findViewObject("GLCodeCombinati onsVO1");
sampleViewObjec t.executeQuery();
but when this page is loading, following error is coming, I looked for the same in google and metalink, but the suggestions mentioned over there are not working, can you please give any suggestion on this:
The data that defines the flexfield on this field may be inconsistent. Inform your system administrator that the function: KeyFlexfieldDef initionFactory. getStructureNum ber could not find the structure definition for the flexfield specified by Application = SQLGL, Code = GL# and Structure number =
I'm trying to hide the numSupp field on Suppliers OAF Page, because I have a custom controller that take the vat_registratio n_num and put in numSupp(segment 1 in ap_suppliers table).
I getting the error: Invalid value: SEGMENT1 is null.
Please, I need some suggestion!
Reg ards and thanks!
i worked in KFF in create page it working fine but i update page how to get the same flex value.guide for update the flex
I am new to OAF. I have an requirement as below.
There is one KFF field present in my custom OAF page. When I select the value for the KFF field, one fireAction/part ialFireAction will be fired.
So kindly suggest me how could I be able to achieve the same.
Thanks,
Ruparanjan
RSS feed for comments to this post