create or replace
FUNCTION FN_ER6_ISS_RECEIPT       ---CREATED  BY ANAND DESAI ON 23/10/2012 FOR ER6 REPORT
(FN_ITEM_CODE   IN   BOMDET.ITEM_CODE%TYPE,
 from_date      in   date,
 to_date        in   date,
 ls_var_name    in   disparm.var_name%type 
 )
RETURN NUMBER
IS
QTY    NUMBER(20,3);
LS_VAR_VALUE   VARCHAR2(1200);
begin
    select    var_value  into  ls_var_value
       from   disparm
       where  var_name = ls_var_name;
       
       select abs(sum(eff_qty)) into qty    
       from   invtrace,workorder     
       where  INVTRACE.ORDER_ID =WORKORDER.WORK_ORDER
       AND    invtrace.item_code = fn_item_code
       and    tran_date between from_date and to_date
        and    instr(','||ls_var_value||',',','||trim(ref_ser)||',') >0;
     
     RETURN (QTY);
END;