|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
源代码,
往红色字符后输入.时会报如上错误,请高手帮忙分析下
create or replace package body yt_inv_item_quantity_date_rep is
PROCEDURE print(content VARCHAR2) is
BEGIN
fnd_file.PUT_LINE(fnd_file.output,content);
END print;
procedure do(errbuf OUT VARCHAR2,
retcod OUT NUMBER,
orgid number,
cst_type varchar2,
p_date varchar2
) is
CURSOR cursor_user_role is
select decode(bsc.organization_id,83,'英唐智控',85,'英唐数码',87,'英唐电气') org_name,
-- bsc.organization_id org_name,
bsc.subinv ,
bsc.inv_name ,
bsc.mtl_num ,
bsc.mtl_name ,
bsc.uom ,
st.t_qty ,
round(cic.item_cost,5) item_cost ,
round(nvl(st.t_qty,0)*nvl(cic.item_cost,0),2) amount,
td1.t_date in_date ,
td2.t_date out_date,
months_between(to_date(nvl(p_date,sysdate),'YYYY-MM'),trunc(greatest(nvl(td2.t_date,td1.t_date),td1.t_date),'MM')) m_date
from yt_inv_item_qty_basic_v bsc,
cst_item_costs cic,
cst_cost_types cct,
(select t.organization_id organization_id,
t.inventory_item_id inv_item,
t.subinventory_code subinv,
sum(t.transaction_quantity) t_qty
from inv.mtl_material_transactions t
where t.transaction_type_id <> 26
and t.transaction_type_id <> 10008
and trunc(t.transaction_date,'MM') <= to_date(nvl(p_date,'2222-12'),'YYYY-MM')
group by t.organization_id,t.inventory_item_id,t.subinventory_code
) st,
(select td.organization_id,td.inv_item,td.subinv,td.in_out,td.t_date,td.a
from
(select t.organization_id,
t.inventory_item_id inv_item,
t.subinventory_code subinv,
sign(t.transaction_quantity) in_out,
t.transaction_date t_date,
rank() over(partition by t.organization_id,t.inventory_item_id,t.subinventory_code,sign(t.transaction_quantity)
order by t.transaction_date desc) a
from inv.mtl_material_transactions t
where trunc(t.transaction_date,'MM') <= to_date(nvl(p_date,'2222-12'),'YYYY-MM')
) td
where td.a = 1 and td.in_out = 1
) td1,
(select td.organization_id,td.inv_item,td.subinv,td.in_out,td.t_date,td.a
from
(select t.organization_id,
t.inventory_item_id inv_item,
t.subinventory_code subinv,
sign(t.transaction_quantity) in_out,
t.transaction_date t_date,
rank() over(partition by t.organization_id,t.inventory_item_id,t.subinventory_code,sign(t.transaction_quantity)
order by t.transaction_date desc) a
from inv.mtl_material_transactions t
where trunc(t.transaction_date,'MM') <= to_date(nvl(p_date,'2222-12'),'YYYY-MM')
) td
where td.a = 1 and td.in_out = -1
) td2
where bsc.organization_id = cic.organization_id(+)
and bsc.inv_item = cic.inventory_item_id(+)
and bsc.organization_id = st.organization_id(+)
and bsc.inv_item = st.inv_item(+)
and bsc.subinv = st.subinv(+)
and bsc.organization_id = td1.organization_id(+)
and bsc.inv_item = td1.inv_item(+)
and bsc.subinv = td1.subinv(+)
and bsc.organization_id = td2.organization_id(+)
and bsc.inv_item = td2.inv_item(+)
and bsc.subinv = td2.subinv(+)
and cic.cost_type_id = cct.cost_type_id(+)
and bsc.org_id like '%'|| orgid ||'%'
and cct.cost_type = nvl(cst_type,
(select t.cost_type
from (select cct.organization_id ,cct.cost_type_id,cct.cost_type,
rank() over(partition by cct.organization_id order by cct.cost_type_id desc) a
from cst_cost_types cct
where cct.organization_id is not null) t
where t.organization_id = bsc.organization_id
and t.a = 1));
p_row_cursor_user_role cursor_user_role%rowtype;
BEGIN
open cursor_user_role;
--格式控制部分
print('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:339px;
height:152px;
z-index:1;
left: 10px;
top: 12px;
}
.STYLE4 {font-size: 24px}
-->
</style>
</head>
<body>
<table width="975" border="1" bordercolor="#666666">
<tr>
<th colspan="100" scope="col">YT库存分析表</th>
</tr>
<tr>
<td width="314" bgcolor="#999999"><span class="STYLE4">组织</span></td>
<td width="180" bgcolor="#999999"><span class="STYLE4">仓库</span></td>
<td width="358" bgcolor="#999999"><span class="STYLE4">仓库名称</span></td>
<td width="358" bgcolor="#999999"><span class="STYLE4">品号</span></td>
<td width="358" bgcolor="#999999"><span class="STYLE4">品名</span></td>
<td width="358" bgcolor="#999999"><span class="STYLE4">单位</span></td>
<td width="358" bgcolor="#999999"><span class="STYLE4">数量</span></td>
<td width="358" bgcolor="#999999"><span class="STYLE4">单位成本</span></td>
<td width="358" bgcolor="#999999"><span class="STYLE4">金额</span></td>
<td width="358" bgcolor="#999999"><span class="STYLE4">上次入库</span></td>
<td width="358" bgcolor="#999999"><span class="STYLE4">上次出库</span></td>
<td width="358" bgcolor="#999999"><span class="STYLE4">呆滞月数</span></td>
</tr>');
/*loop --循环
fetch cursor_user_role
into p_row_cursor_user_role;
EXIT WHEN cursor_user_role%NOTFOUND OR
cursor_user_role%NOTFOUND IS NULL;*/
for p_row_cursor_user_role in cursor_user_role
loop
print('<tr><td>' || p_row_cursor_user_role.org_name ||
'</td>'||'<td>' ||
replace(p_row_cursor_user_role.subinv,',','' )||
'</td>'||'<td>' ||p_row_cursor_user_role.inv_name ||
'</td>'||'<td>' ||p_row_cursor_user_role.mtl_num ||
'</td>'||'<td>' ||p_row_cursor_user_role.mtl_name ||
'</td>'||'<td>' ||p_row_cursor_user_role.uom ||
'</td>'||'<td>' ||p_row_cursor_user_role.t_qty ||
'</td>'||'<td>' ||p_row_cursor_user_role.item_cost ||
'</td>'||'<td>' ||p_row_cursor_user_role.amount ||
'</td>'||'<td>' ||p_row_cursor_user_role.in_date ||
'</td>'||'<td>' ||p_row_cursor_user_role.out_date ||
'</td>'||'<td>' ||p_row_cursor_user_role.m_date ||
'</td> </tr>');
--输出部分--End--
END loop;
--格式控制部分
print('</table>
</body>
</html>');
--格式控制部分
-- close cursor_user_role;
END do;
end yt_inv_item_quantity_date_rep;
|
|