Oracle Cloud offers a broad portfolio of software as a service applications, platform as a service, and social capabilities, all on a subscription basis. Oracle Cloud delivers instant value and productivity for end users, administrators, and developers alike through functionally rich, integrated, secure, enterprise cloud services.
 Get a Free Magzine ...Profit:The Executive's Guide to Oracle Applications

Subscribe to the OracleAppsHub to receive notifications when there are new posts:

 get RSS feed
 Oracle Fusion Applications (OFA) is a portfolio of next generation suite of software applications from Oracle Corporation. It is distributed across various product families; including financial management, human capital management, customer relationship management, supply chain management, procurement, governance, and project portfolio management
 Get a Free Magzine ...Profit:The Executive's Guide to Oracle Applications

12 Steps for Enabling Flexfields in Oracle Report

Posted on August 24th, 2007 by Sanjit Anand |Print This Post Print This Post |Email This Post Email This Post

Have you tried OracleappsHub in ipad/iphone/smart Phone? Don't wait. try it today

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 :

SRW.USER_EXIT('FND SRWINIT');

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 :

SRW.USER_EXIT('FND SRWEXIT');

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.

Lexical Parameters

  • P_CONC_REQUEST_ID
  • P_FLEXDATA

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.

SRW.REFERENCE(:P_STRUCT_NUM);
SRW.USER_EXIT('FND FLEXSQL
CODE="GL#"
NUM=":P_STRUCT_NUM"
APPL_SHORT_NAME="SQLGL"
OUTPUT=":P_FLEXDATA"
MODE="SELECT"
DISPLAY="ALL"');

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
FROM CODE_COMBINATIONS_TABLE
WHERE CODE_COMBINATIONS_TABLE.STRUCTURE_DEFINING_COLUMN
= &P_STRUCT_NUM

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:

SELECT (SEGMENT1||'-'||SEGMENT2||'-'||SEGMENT3||'-'||
SEGMENT4) C_FLEXDATA
FROM CODE_COMBINATIONS_TABLE
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:

SRW.REFERENCE(:P_STRUCT_NUM);
SRW.REFERENCE(:C_FLEXDATA);
SRW.USER_EXIT('FND FLEXIDVAL
CODE="GL#"
NUM=":P_STRUCT_NUM"
APPL_SHORT_NAME="SQLGL"
DATA=":C_FLEXDATA"
VALUE=":C_FLEXFIELD"
DISPLAY="ALL"');
RETURN(:C_FLEXFIELD);

Refer this how to enable user exits in reports.

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:

SRW.REFERENCE(:P_STRUCT_NUM);
SRW.REFERENCE(:C_FLEXDATA);
SRW.USER_EXIT('FND FLEXIDVAL
CODE="GL#"
NUM=":P_STRUCT_NUM"
APPL_SHORT_NAME="SQLGL"
DATA=":C_FLEXDATA"
DESCRIPTION=":C_DESC_ALL"
DISPLAY="ALL"');
RETURN(:C_DESC_ALL);

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.

Related Posts

Posted in AOL, Technical | 7 Comments »Email This Post Email This Post | Print This Post Print This Post

Have you tried OracleappsHub in ipad/iphone/smart Phone? Don't wait. try it today
7 Responses
  1. Gareth Roberts Says:

    Nice post!

  2. Dheeraj Says:

    Hi ,
    I Have a problem which i am unable to solve.
    My standard report has Account (segment5) of Code combination.Now in Addition to this i have to dispaly subaccount(segment6) which is dependent on account.
    How can i use srw.user_exit for solving this.
    Is there any name like ‘GL_ACCOUNT’ for subaccount to get this value or any other process to retrive

  3. Tapan Pati Says:

    Its somewhat descriptive and will help beginers a lot.

    But still if everything has to explain in a single sentence then?
    I mean what SRW.REFERENCE package does?

  4. Sharmila Says:

    Very well written. Great work,,, thanks

  5. srinu Says:

    Hi,
    i have red that before report trigger fires ,before the report is executed but after queries are parsed and data is fetched i.e data is already fetched ,before,before report trigger fires then what is use of user_exits(generally we write user_exit in before report trigger),when user_exit work whether after data fetched?.please refer a book for reports and forms.
    thanks&regards
    sreenu

  6. Venkat Says:

    Hi Anand,

    Its very useful article..

    Thanks and Regards,
    venkat

  7. Venkat Says:

    Hi Anand,

    Good Article…

    Regards,
    venkat

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.