Wednesday, December 2, 2009

Oracle Reports-Frequently Use SRW Functions

SRW Package is a collection of PL/SQL constructs that provide developers with a suite of built-in functions, procedures, and exceptions that can be used in any of your libraries or reports. The following lists several of these constructs, and briefly describes how Applications uses them in reports.

SRW.DO_SQL and SRW.DO_SQL_FAILURE
When it is necessary to perform data definition statements (DDL), the SRW.DO_SQL packaged procedure must be used. You cannot perform DDL statements in PL/SQL. In conjunction with this, we use the SRW.DO_SQL_FAILURE
exception which raises an error if the statement should fail.

Example
BEGIN
SRW.DO_SQL('Create table Test...');
EXCEPTION 
  when SRW.DO_SQL_FAILURE then
  .....
END;

SRW.MESSAGE
This procedure allows developers to create their own messages and return them at runtime. It takes two arguments, a message number and message text. It can be used for error handling or debugging. Applications uses this feature to standardize and share messages across reports.

Example
SRW.MESSAGE('500','First debug point');

SRW.USER_EXIT and SRW.REFERENCE
Because Applications reports commonly call user exits it is critical that Oracle Reports support such calls. To facilitate this requirement the Package offers  SRW.USER_EXIT and SRW.REFERENCE. User exits may be called from any PL/SQL interface within a report, but it must be called with SRW.USER_EXIT. Furthermore, to ensure that the value of an object passed to the user exit contains the most recently computed or fetched value, SRW.REFERENCE will add the object to the user exit dependency list.

Example
BEGIN
SRW.REFERENCE(:Currency_code);
SRW.REFERENCE(:Currency_value);
SRW.USER_EXIT('FND FORMAT CURRENCY CODE=":Currency_code"                         
               AMOUNT=":Currency_value"                        
               DISPLAY=":Currency_formatted"');
RETURN(:Currency_formatted);
EXCEPTION WHEN
SRW.USER_EXIT_FAILURE THEN
RETURN('FORMAT ERROR');
END:
Related Posts Plugin for WordPress, Blogger...