Saturday, September 6, 2014

Technical Trick: How to add (GL Accounting Flexfield Range) to a customized request on R12 step by step

In this article, we will learn how to add (GL Accounting Flexfield Range) to a customized request on R12 step by step, to filter the data according to the chossen range of the segments.
See our target in the below snapshot.


Steps:
  1. Open the RDF file with the Report builder.
  2. Add the following user parameters in the RDF file:
    • P_CONC_REQUEST_ID and make its type (Number 15)
    • P_LEDGER_ID and make its type (Number 15)
    • P_MAX_FLEX and make its type (Character 200)
    • P_MIN_FLEX and make its type (Character 200)
    • P_USER_ID and make its type (Number 15)
    • STRUCT_NUM and make its type (Number 15)
    • WHERE_FLEX and make its type (Character 200)
  3. Modify your main query of the RDF file like the following:
    • Make sure that the GL_CODE_COMBINATIONS table is in your query and has an alias
    • After the last condition in your query add this &WHERE_FLEX
  4. Add the following code to the (BEFORE REPORT) Trigger in the RDF file:
    • FND_PROFILE.GET('CONC_REQUEST_ID',:P_CONC_REQUEST_ID);
      FND_PROFILE.GET('GL_SET_OF_BKS_ID',:P_LEDGER_ID);
      FND_PROFILE.GET('USER_ID',:P_USER_ID);
    • srw.reference(:STRUCT_NUM);
    • SRW.User_Exit('FND SRWINIT');
    • srw.user_exit('FND FLEXSQL CODE="GL#" NUM=":STRUCT_NUM" APPL_SHORT_NAME="SQLGL"
      OUTPUT=":WHERE_FLEX" TABLEALIAS="glc" 
    •  --"glc" in the above line is the GL_CODE_COMBINATIONS alias in the main query
      MODE="WHERE" DISPLAY="ALL"
      OPERATOR="BETWEEN"
      OPERAND1=":P_MIN_FLEX"
      OPERAND2=":P_MAX_FLEX"');
    • :WHERE_FLEX := ' AND ' ||  :WHERE_FLEX;
  5. Add the following code to the (AFTER REPORT) Trigger in the RDF file:
    • SRW.USER_EXIT('FND SRWEXIT');
  6. Save the RDF file and FTP it to the server.
  7. Go to the applications and login with any user has a System Administrator responsibility.
  8. Query on your concurrent request and add to it the following three parameters:
    1. Chart of Accounts ID
      • Value Set: GL_SRS_COA_UNVALIDATED
      • Default Type: SQL Statement
      • Default Value: SELECT chart_of_accounts_id FROM gl_access_sets WHERE access_set_id = :$PROFILES$.GL_ACCESS_SET_ID
      • Required: No
      • Displayed: No
      • Prompt: Chart of Accounts ID
      • Token: STRUCT_NUM
    2. Account Flexfield From
      • Value Set: GL_SRS_LEDGER_FLEXFIELD
      • Required: No
      • Displayed: Yes
      • Prompt: Account Flexfield From
      • Token: P_MIN_FLEX
    3. Account Flexfield To
      • Value Set: GL_SRS_LEDGER_FLEXFIELD
      • Required: No
      • Displayed: Yes
      • Prompt: Account Flexfield From
      • Token: P_MAX_FLEX

Now save your work and run the report, you will find two parameters have been added to your concurrent program as a LOV range of the GL Accounting Flex field.
And of course it will filter your data according to your range entered.