March 12, 2012

Using placeholder Column

Placeholder column can be used to reference more then one outputs:

Eg:-create a placeholder column,Define a function in it.Can have multiple outputs and referenced to different place holders in the report;

E.g Query in placeholder column

function CF_CalcFormula return Number is

--*************************** Getting Sales Info from Oracle **********
cursor Ora_Sales(it_id number, o_id number,TDays number) is
select
        sum(nvl(quantity_invoiced,0))  + sum(nvl(quantity_Credited,0))  Qty
from
        ra_customer_trx_lines_all ctla ,ra_customer_trx_all cta
where
        cta.customer_trx_id =  ctla.customer_trx_id
        and inventory_item_id = it_id --86343
        and to_number(ltrim(rtrim(cta.interface_header_attribute10))) = o_id
        and cta.trx_date >= sysdate - TDays
group by
        ltrim(rtrim(cta.interface_header_attribute10)),
        inventory_item_id;  

    AMD12 number; AMD1 number; Order_Qty number;
    Safety_qty number; min_qty number; max_qty number; 

L1Y := 0; L6M := 0; L3M := 0; L1M := 0;

begin

 :CP_IY := L1Y;        --placeholder in report
     open Ora_Sales(:inventory_item_id,:organization_id,183);
                  fetch Ora_Sales into L6M;
   close ora_sales;
   :CP_6M := L6M;        --placeholder in report
   open Ora_Sales(:inventory_item_id,:organization_id,91);
                  fetch Ora_Sales into L3M;
   close ora_sales;
   :CP_3M := L3M;        --placeholder in report
     open Ora_Sales(:inventory_item_id,:organization_id,30);
                  fetch Ora_Sales into L1M;


amd1 := ((LI6M + L6M)/6  + (LI3M + L3M)/3 + (LI1M + L1M) )/3;
    amd12 := (LI1Y + L1Y)/12;
    :CP_AMD1 := round(NVL(amd1,0),2);    --placeholder in report

:cp_LeadTime := :p_lead_time ; --placeholder in report
:cp_buf_stk := :p_buf_stk; --placeholder in report
:cp_agency := :p_segment1; --placeholder in report

return 0;
end;

No comments:

Post a Comment

Thanks for your comments submitted.,will review and Post soon! by admin.

COALESCE-SQL

Coalesce- return the null values from the expression. It works similar to a case statement where if expression 1 is false then goes to expr...