Monday 18 April 2016

Formula columns in oracle reports

Formula Column:
  
       We use formula column to calculate some information dynamically using information based on the columns of the data model or from the concurrent program parameters. It is basically used to apply some custom logic on input data and return some value.

Ø Performs a user-defined computation
Ø Executes a PL/SQL function
Ø Must return a value
Ø Can be a Character, Number, Date
Ø Returned value must match datatype

Let us make total salary(sal + comm)


In the Data Model view that displays, click the formula column tool in the tool palette then click inside of group and view to display the formula column as shown below


Double click on formula column you can find the properties and give below details Compile the code and close as below

Name                 : CF_TOTAL_SAL
PL/SQL Formula :
FUNCTION cf_total_salformula
   RETURN NUMBER
IS
BEGIN
   RETURN (:sal + NVL (:comm, 0));
END;


Go to Layout Model add Text main frame level and field in repeating frame as shown below


Select F_7 field and right click go to Property Inspector set below properties as shown below

            Name  :CF_TOTAL_SAL
            Source :CF_TOTAL_SAL


Now development part completed you can run the report

Goto >Programs > Run paper Layout (you can find as below report output)




No comments:

Post a Comment