1 PACKAGE BODY MRP_GET_ORDER AS
2 /* $Header: MRPXORDB.pls 115.1 99/07/16 12:43:40 porting ship $ */
3
4
5 FUNCTION supply_order (arg_order_type IN NUMBER,
6 arg_disp_id IN NUMBER,
7 arg_compile_desig IN VARCHAR2,
8 arg_org_id IN NUMBER,
9 arg_item_id IN NUMBER,
10 arg_by_prod_assy_id IN NUMBER DEFAULT NULL)
11 return varchar2
12 IS
13
14 order_num varchar2(240);
15 wip_ent_name varchar2(240);
16
17 cursor C1 is
18 select po_number
19 from mrp_item_purchase_orders
20 where transaction_id = arg_disp_id
21 and compile_designator = arg_compile_desig
22 and organization_id = arg_org_id
23 and inventory_item_id = arg_item_id;
24
25 cursor C2 is
26 select wip_entity_name
27 from mrp_item_wip_entities
28 where wip_entity_id = arg_disp_id
29 and compile_designator = arg_compile_desig
30 and organization_id = arg_org_id
31 and inventory_item_id = arg_item_id;
32
33 cursor C3 is
34 select wip_entity_name
35 from mrp_item_wip_entities
36 where wip_entity_id = arg_disp_id
37 and compile_designator = arg_compile_desig
38 and organization_id = arg_org_id
39 and inventory_item_id = arg_by_prod_assy_id;
40
41 BEGIN
42
43 if (arg_order_type is NULL) THEN
44 return NULL;
45 END IF;
46
47 if (arg_order_type in (1, 2, 8, 11, 12)) then
48
49 if (arg_disp_id is NULL) then
50 return NULL;
51 end if;
52
53
54 OPEN C1;
55 LOOP
56 FETCH C1 INTO order_num;
57 EXIT;
58 END LOOP;
59
60 return (order_num);
61
62 end if;
63
64 if (arg_order_type in (3, 7, 18)) then
65
66 if (arg_disp_id is NULL) then
67 return NULL;
68 end if;
69
70 OPEN C2;
71 LOOP
72 FETCH C2 into wip_ent_name;
73 EXIT;
74 END LOOP;
75
76 return (wip_ent_name);
77
78 end if;
79
80 if (arg_order_type in (14, 15)) then
81
82 if (arg_disp_id is NULL) then
83 return NULL;
84 end if;
85
86 OPEN C3;
87 LOOP
88 FETCH C3 into wip_ent_name;
89 EXIT;
90 END LOOP;
91
92 return (wip_ent_name);
93
94 end if;
95
96 return NULL;
97
98 END SUPPLY_ORDER;
99
100
101 FUNCTION sales_order (arg_demand_id IN NUMBER)
102 return varchar2
103 IS
104
105 order_number varchar2(240);
106
107 cursor C4 is
108 select so.segment1||':'||so.segment2||':'||so.segment3
109 from
110 mtl_sales_orders so, mrp_schedule_dates msd
111 where
112 msd.mps_transaction_id = arg_demand_id
113 and msd.schedule_level =3
114 and so.sales_order_id = msd.source_sales_order_id;
115 BEGIN
116 if arg_demand_id is null
117 then return null;
118 end if;
119 OPEN C4;
120 Loop
121 Fetch C4 into order_number;
122 Exit;
123 END Loop;
124 Close C4;
125 return(order_number);
126 END sales_order;
127
128 END MRP_GET_ORDER;