If any one want to use Flexfield in report, there is minimum steps you have to follow to make things Functional. These are the standard steps as per AOL guide.
Step 1 Define your Before Report Trigger
Here you suppose to call FND SRWINIT from the Before Report Trigger like :
This user exit sets up information for use by flexfields, user profiles, the concurrent manager, and other Oracle Applications features as discussed in one of previous post.
Step 2 Define your After Report Trigger
Next, is you need to call FND SRWEXIT from the After Report Trigger like :
Step 3 Define your required parameters
In this step you need to define the parameters your report needs by using the Data Model Painter. You use these parameters in the user exit calls and SQL statements.
You must always create the P_CONC_REQUEST_ID lexical parameter. "FND SRWINIT" uses this parameter to retrieve information about the concurrent request that started this report.
The P_FLEXDATA parameter holds the SELECT fragment of the SQL query. The initial value is used to check the validity of a query containing this parameter and to determine the width of the column as specified by the column alias. Its initial value is some string that contains columns with a cumulative width more than the expected width required to hold the data. Make sure the width of this column is sufficient. If there are total 30 segments in the table then the safest initial value will be:
(SEGMENT1||'\n'||SEGMENT2||'\n'||SEGMENT3 ... SEGMENT30)
You determine the width by determining the length of that string. That length is roughly the number of characters in the table alias plus the length of the column name, times the number of segments your code combinations table contains, times the number of structures you expect, plus more for delimiter characters as shown in the string above.
Step 4 Define your rest other parameters
You define the rest of the parameters your report needs by using the Data Model Painter. You use these parameters in the user exit calls and SQL statements.
Step 5 Call FND FLEXSQL from your Before Report Trigger to populate P_FLEXDATA
Next, given that you want to display flexfield information like concatenated values and descriptions, and arrange them in order, you make one call to FND FLEXSQL from the Before Report Trigger specifying the lexical parameters. This call changes the value of the lexical parameter P_FLEXDATA at runtime to the SQL fragment that selects all flexfields value data. For example, the parameter changes to (SEGMENT1||'\n'||SEGMENT2||'\n'||SEGMENT3||'\n'||SEGMENT4).
When you incorporate this lexical parameter into the SELECT clause of a query, it enables the query to return the concatenated segment values that are needed as input to other AOL user exits. These exits then retrieve the actual flexfield information for display purposes.
Here is an example FND FLEXSQL call. Notice that the arguments are very similar to other flexfield routine calls; CODE= and NUM= designate the key flexfield and its structure, respectively. For a report on a different key flexfield (such as the System Items flexfield), you would use a different CODE and NUM.
You should always reference any source column/parameter that is used as a source for data retrieval in the user exit. This guarantees that this column/parameter will contain the latest value and is achieved by "SRW.REFERENCE" call as shown above.
Step 6 Call FND FLEXSQL from your Before Report Trigger to populate other parameters
What you suppose ti do here is just need to call FND FLEXSQL once for every lexical parameter.
Step 7 Define your report query or queries
Define your report query Q_1:
SELECT &P_FLEXDATA C_FLEXDATA
The query fetches the data required to be used as input for the FLEXIDVAL user exit later.
When the report runs, the call to FND FLEXSQL fills in the lexical parameters. As a result the second query would look something like:
WHERE CODE_COMBINATIONS_TABLE.STRUCTURE_DEFINING_COLUMN = 101< /FONT >
Step 8 Create formula columns
Now create columns C_FLEXFIELD and C_DESC_ALL (and any others your report uses) corresponding to the values and descriptions displayed in the report. They all are in group G_1.
Step 9 Populate segment values formula column
Now you need to retrieve the concatenated flexfield segment values and description which you incorporate the flexfields user exits in these columns. In the column definition of C_FLEXFIELD, you incorporate the FND FLEXIDVAL user exit call in the formula field. You pass the concatenated segments along with other information to the user exit, and the user exit populates the concatenated values in this column as specified by the VALUE token. A typical call to populate segment values in this column looks as follows:
Step 10 Populate segment descriptions< /STRONG>
To populate the segment description use DESCRIPTION="C_DESC_ALL" instead of VALUE="C_FLEXFIELD" as in the previous call. The user exit call becomes:
You have created parameters and columns that are containers of all the values to be displayed. Now, in the following steps, you create the layout to display these values on the report.
Step 11 Create your default report layout
First choose Default Layout to generate the default layout. Deselect C_FLEXDATA. Specify a "Label" and a reasonable "Width" for the columns you want to display.
Step 12 Finish your report By adjusting report layout.