March 12, 2012

Logic to find out items soldy qty

In inventory if u need to find the aging details of sales report u need to refer to cutomer tables

i.e:
 ra_customer_trx_lines_all and ra_customer_trx_all

conditions to filter will be inventory_item_id,organization_id

e.g query:

select
        sum(nvl(quantity_invoiced,0))  + sum(nvl(quantity_Credited,0))  Qty,to_number(ltrim(rtrim(cta.interface_header_attribute10)))
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 = 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;

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;

Unix Cmds

If u have developed and saved a report in custom folder and when u r running it in application u need to make it avilable to applmgr too,so that it will reference and pick the rdf.

Cmds:

Login in putty to appluser or root:

Go the path e.g: $ cd /t01/applmgr/apps/apps_st/appl/xcust/12.0.0/reports/US

Give ownership: E,g
$chown -h applmgr  Report_name.rdf

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...