[Home] [Help]
PACKAGE BODY: APPS.PO_POXRCPPV_XMLP_PKG
Source
4 function BeforeReport return boolean is
1 PACKAGE BODY PO_POXRCPPV_XMLP_PKG AS
2 /* $Header: POXRCPPVB.pls 120.4 2011/07/21 00:32:01 fayang ship $ */
3
5 l_org org_organization_definitions.organization_name%type;
6 l_sort po_lookup_codes.displayed_field%type ;
7 l_cr_installed boolean;
8 begin
9
10
11 if P_org_id is not null then
12
13 select organization_name
14 into l_org
15 from org_organization_definitions
16 where organization_id = P_org_id ;
17
18 P_org_displayed := l_org;
19
20 else
21
22 P_org_displayed := '' ;
23
24 end if;
25
26 if P_Trans_Date_to is not null then
27 SELECT trunc(P_Trans_Date_to) +1 - .00001
28 INTO P_Trans_Date_to
29 FROM DUAL;
30 end if;
31 return (TRUE);
32 exception
33 when others then
34 return(FALSE);
35 end;
36
37 function from_std_unitcost return character is
38 wip_status VARCHAR2(1);
39 begin
40 if P_wip_status = 'I' then
41 return (', wip_transactions wt');
42 end if;
43
44 RETURN ' ';
45 end;
46
47 function where_std_unit_cost return character is
48 wip_status VARCHAR2(1);
49 begin
50 if P_wip_status = 'I' then
51 return('AND rct.transaction_id=wt.rcv_transaction_id AND wt.standard_rate_flag=1 '||
52 'AND wt.transaction_type = 3 AND exists (select 1 from wip_transaction_accounts wta '||
53 'where wta.transaction_id = wt.transaction_id and wta.accounting_line_type = 6)' );
54
55 end if;
56
57 RETURN ' ';
58 end;
59
60 function get_std_unit_cost return character is
61 wip_status VARCHAR2(1);
62 begin
63 if P_wip_status = 'I' then
64 return(
65 'wt.standard_resource_rate * decode(msi.outside_operation_uom_type,'||'''ASSEMBLY'''||', decode(wt.usage_rate_or_amount,0,1,wt.usage_rate_or_amount), 1)');
66 end if;
67
68 RETURN null;
69 end;
70
71 function c_price_varianceformula(PO_Functional_Price in number, STD_UNIT_COST in number, moh_absorbed_per_unit in number, Quantity_received in number, c_precision in number) return number is
72 begin
73 return ( round(( PO_Functional_Price - STD_UNIT_COST + moh_absorbed_per_unit ) * Quantity_received,c_precision));
74 end;
75
76 /* Support for landed cost management */
77 function c_price_varianceformula_lcm(functional_landed_cost in number, prior_landed_cost in number, quantity_received in number, c_precision in number) return number is
78 begin
79 return ( round(( functional_landed_cost - prior_landed_cost) * Quantity_received,c_precision));
80 end;
81
82
83 function orderby_clauseFormula return VARCHAR2 is
84 begin
85
86 if P_ORDERBY = 'CATEGORY' then
87 return(P_ORDERBY_CAT);
88 elsif P_ORDERBY = 'ITEM' then
89 return(P_ORDERBY_ITEM);
90 elsif P_ORDERBY = 'VENDOR' then
91 return('pov.vendor_name');
92 elsif P_ORDERBY = 'BUYER' then
93 return('papf.full_name');
94 end if;
95 RETURN NULL; end;
96
97 procedure get_precision is
98 begin
99 /*srw.attr.mask := SRW.FORMATMASK_ATTR;*/null;
100
101 if P_qty_precision = 0 then /*srw.attr.formatmask := '-NNN,NNN,NNN,NN0';*/null;
102
103 else
104 if P_qty_precision = 1 then /*srw.attr.formatmask := '-NNN,NNN,NNN,NN0.0';*/null;
105
106 else
107 if P_qty_precision = 3 then /*srw.attr.formatmask := '-NN,NNN,NNN,NN0.000';*/null;
108
109 else
113 if P_qty_precision = 5 then /*srw.attr.formatmask := '-NNN,NNN,NN0.00000';*/null;
110 if P_qty_precision = 4 then /*srw.attr.formatmask := '-N,NNN,NNN,NN0.0000';*/null;
111
112 else
114
115 else
116 if P_qty_precision = 6 then /*srw.attr.formatmask := '-NN,NNN,NN0.000000';*/null;
117
118 else /*srw.attr.formatmask := '-NNN,NNN,NNN,NN0.00';*/null;
119
120 end if; end if; end if; end if; end if; end if;
121 /*srw.set_attr(0,srw.attr);*/null;
122
123 end;
124
125 function c_price_variance1formula(PO_Functional_Price1 in number, STD_UNIT_COST1 in number, moh_absorbed_per_unit1 in number, Quantity_received1 in number, c_precision in number) return number is
126 begin
127 return ( round(( PO_Functional_Price1 - STD_UNIT_COST1 + moh_absorbed_per_unit1 ) * Quantity_received1,c_precision));
128 end;
129
130 function AfterPForm return boolean is
131 begin
132
133 if (P_TRANS_DATE_FROM is null and P_TRANS_DATE_TO is null) then
134 P_TX_DATE_WHERE := 'AND 1=1';
135 P_MTL_TX_DATE_WHERE := 'AND 1=1';
136
137 elsif (P_TRANS_DATE_FROM is not null and P_TRANS_DATE_TO is null) then
138 P_TX_DATE_WHERE := 'AND rct.transaction_date >= :P_TRANS_DATE_FROM';
139 P_MTL_TX_DATE_WHERE := 'AND mmt.transaction_date >= :P_TRANS_DATE_FROM';
140
141 elsif (P_TRANS_DATE_FROM is null and P_TRANS_DATE_TO is not null) then
142 P_TX_DATE_WHERE := 'AND rct.transaction_date <= :P_TRANS_DATE_TO ';
143 P_MTL_TX_DATE_WHERE := 'AND mmt.transaction_date <= :P_TRANS_DATE_TO';
144
145 elsif(P_TRANS_DATE_FROM is not null and P_TRANS_DATE_TO is not null) then
146 P_TX_DATE_WHERE := 'AND rct.transaction_date between :P_TRANS_DATE_FROM and :P_TRANS_DATE_TO';
147 P_MTL_TX_DATE_WHERE := 'AND mmt.transaction_date between :P_TRANS_DATE_FROM and :P_TRANS_DATE_TO';
148 end if;
149
150 If (P_VENDOR_FROM is null and P_VENDOR_TO is null) then
151 P_VENDOR_NAME_WHERE := 'AND 1=1';
152 elsif (P_VENDOR_FROM is not null and P_VENDOR_TO is null) then
153 P_VENDOR_NAME_WHERE := 'AND pov.vendor_name >= :P_VENDOR_FROM';
154 elsif (P_VENDOR_FROM is null and P_VENDOR_TO is not null) then
155 P_VENDOR_NAME_WHERE := 'AND pov.vendor_name <= :P_VENDOR_TO';
156 elsif (P_VENDOR_FROM is not null and P_VENDOR_TO is not null) then
157 P_VENDOR_NAME_WHERE := 'AND pov.vendor_name between :P_VENDOR_FROM and :P_VENDOR_TO';
158 end if;
159
160 begin
161 select status
162 into P_wip_status
163 from fnd_product_installations
164 where application_id = 706;
165
166 P_select_wip := get_std_unit_cost;
167 P_from_wip := from_std_unitcost;
168 P_where_wip := where_std_unit_cost;
169 exception
170 when no_data_found then
171 P_wip_status := '';
172 P_select_wip := null;
173 P_from_wip := ' ';
174 P_where_wip := ' ';
175
176 end;
177 return (TRUE);
178 end;
179
180 function std_unit_cost_fformula(inventory_item_id in number, organization_id in varchar2, receipt_date in date, process_enabled_flag in varchar2, std_unit_cost in number, c_ext_precision in number) return number is
181 l_result_code VARCHAR2(30);
182 l_return_status VARCHAR2(30);
183 l_msg_count NUMBER;
184 l_msg_data VARCHAR2(2000);
185 l_inventory_item_id NUMBER := inventory_item_id;
186 l_organization_id NUMBER := organization_id;
187 l_transaction_date DATE := receipt_date;
188 l_cost_mthd VARCHAR2(15);
189 l_cmpntcls NUMBER;
190 l_analysis_code VARCHAR2(15);
191 l_item_cost NUMBER;
192 l_no_of_rows NUMBER;
193 begin
194 IF process_enabled_flag = 'Y' THEN
195 l_result_code := GMF_CMCOMMON.Get_Process_Item_Cost
196 ( p_api_version => 1
197 , p_init_msg_list => 'F'
198 , x_return_status => l_return_status
199 , x_msg_count => l_msg_count
200 , x_msg_data => l_msg_data
201 , p_inventory_item_id => l_inventory_item_id
202 , p_organization_id => l_organization_id
203 , p_transaction_date => l_transaction_date
204 , p_detail_flag => 1
205 , p_cost_method => l_cost_mthd
206 , p_cost_component_class_id => l_cmpntcls
207 , p_cost_analysis_code => l_analysis_code
208 , x_total_cost => l_item_cost
209 , x_no_of_rows => l_no_of_rows
210 );
211
212 IF l_result_code <> 1 THEN
213 l_item_cost := 0;
214 END IF;
215 ELSE
216 l_item_cost := std_unit_cost;
217 END IF;
218
219 return round(l_item_cost, c_ext_precision);
220 end;
221
222 function AfterReport return boolean is
223 begin
224
225 return (TRUE);
226 end;
227
228
229 END PO_POXRCPPV_XMLP_PKG ;
230