码迷,mamicode.com
首页 > 其他好文 > 详细

INV(库存管理)

时间:2016-09-24 11:56:44      阅读:292      评论:0      收藏:0      [点我收藏+]

标签:

物料

技术分享
  1 PROCEDURE update_item(p_init_msg_list IN VARCHAR2 DEFAULT fnd_api.g_false,
  2                         x_return_status OUT NOCOPY VARCHAR2,
  3                         x_msg_count     OUT NOCOPY NUMBER,
  4                         x_msg_data      OUT NOCOPY VARCHAR2) IS
  5   
  6     l_api_name CONSTANT VARCHAR2(30) := UPDATE_ITEM;
  7     l_savepoint_name VARCHAR2(30) := UPDATE_ITEM;
  8     l_item_rec1      inv_item_grp.item_rec_type;
  9     x_item_rec1      inv_item_grp.item_rec_type;
 10     l_item_rec       inv_item_grp.item_rec_type;
 11     x_item_rec       inv_item_grp.item_rec_type;
 12     x_error_tbl      inv_item_grp.error_tbl_type;
 13     -- x_return_status     VARCHAR2(10);
 14     l_user_id           NUMBER := 0; --User ID, Sysadmin here
 15     l_message           VARCHAR2(500);
 16     x_message           VARCHAR2(500);
 17     l_buyer_id          NUMBER;
 18     l_old_category_id   NUMBER;
 19     l_category_id       NUMBER;
 20     l_category_set_id   NUMBER;
 21     l_category_set_name VARCHAR2(240) := 库存;
 22     --l_item_id           NUMBER;
 23     --l_organization_id   NUMBER;
 24     l_errorcode    VARCHAR2(100);
 25     l_msg_count    NUMBER;
 26     l_structure_id NUMBER;
 27   
 28     l_chart_of_account_id NUMBER;
 29     l_ccid1               NUMBER;
 30     l_ccid2               NUMBER;
 31     l_ccid3               NUMBER;
 32     l_ccid4               NUMBER;
 33     l_default_org         NUMBER;
 34     l_organization_id     NUMBER;
 35     l_item_id             NUMBER;
 36     l_organization_id1    NUMBER;
 37     l_item_id1            NUMBER;
 38   
 39     l_err_count NUMBER;
 40   
 41     --更新类别信息
 42     l_category_rec inv_item_category_pub.category_rec_type;
 43   BEGIN
 44   
 45     -- and initialize message list, include debug message hint to enter api
 46     x_return_status := hss_api.start_activity(p_pkg_name      => g_pkg_name,
 47                                               p_api_name      => l_api_name,
 48                                               p_init_msg_list => p_init_msg_list);
 49     -- check if activity started successfully
 50     IF (x_return_status = fnd_api.g_ret_sts_unexp_error) THEN
 51       RAISE fnd_api.g_exc_unexpected_error;
 52     ELSIF (x_return_status = fnd_api.g_ret_sts_error) THEN
 53       RAISE fnd_api.g_exc_error;
 54     END IF;
 55   
 56     -- hss_log.debug(‘测试=======‘);  
 57     BEGIN
 58       SELECT mcs.category_set_id,
 59              mcs.structure_id
 60         INTO l_category_set_id,
 61              l_structure_id
 62         FROM mtl_category_sets mcs
 63        WHERE mcs.category_set_name = l_category_set_name;
 64     EXCEPTION
 65       WHEN OTHERS THEN
 66         --dbms_output.put_line(‘类别集   :‘ || l_category_set_name || ‘未定义‘);
 67         RETURN;
 68     END;
 69   
 70     l_err_count := 0;
 71     FOR c IN (SELECT *
 72                 FROM cux.cux_mtl_update_prperty ccp
 73                WHERE nvl(ccp.return_stastus,
 74                          N) <> S
 75                ORDER BY ccp.item_code)
 76     LOOP
 77       SAVEPOINT l_savepoint_name; --设置保存点
 78     
 79       hss_conc_utl.log_msg(物料编码: || c.item_code);
 80     
 81       l_message := NULL;
 82       --=============================================================================
 83       /*当需要更新物料说明和默认发运组织时,需先更新主组织的物料说明和默认发运组织*/
 84       --=============================================================================
 85       IF (c.desc_mir IS NOT NULL OR c.default_shipping_org IS NOT NULL) THEN
 86       
 87         l_item_rec1.organization_code := MST;
 88         l_item_rec1.item_number       := c.item_code;
 89       
 90         --IF (c.desc_mir IS NOT NULL) THEN
 91         --  l_item_rec1.description := c.desc_mir;
 92         --ELSE
 93         --  l_item_rec1.description := NULL;
 94         ---END IF;
 95       
 96         IF c.item_desc IS NOT NULL THEN
 97           l_item_rec1.long_description := c.item_desc;
 98         ELSE
 99           l_item_rec1.long_description := NULL;
100         END IF;
101       
102         IF (c.default_shipping_org IS NOT NULL) THEN
103           BEGIN
104             SELECT oog.organization_id
105               INTO l_default_org
106               FROM org_organization_definitions oog
107              WHERE oog.organization_code = c.default_shipping_org;
108           EXCEPTION
109             WHEN OTHERS THEN
110               l_default_org := NULL;
111           END;
112         
113           l_item_rec1.default_shipping_org := l_default_org;
114         ELSE
115           l_item_rec1.default_shipping_org := NULL;
116         END IF;
117       
118         --API
119         ----更新物料信息-----
120         inv_item_grp.update_item(p_commit        => fnd_api.g_false,
121                                  p_item_rec      => l_item_rec1,
122                                  x_item_rec      => x_item_rec1,
123                                  x_return_status => x_return_status,
124                                  x_error_tbl     => x_error_tbl);
125         IF x_return_status <> fnd_api.g_ret_sts_success THEN
126           -- l_message := NULL;
127           FOR i IN 1 .. x_error_tbl.count
128           LOOP
129             l_message := l_message || x_error_tbl(i).message_name;
130           END LOOP;
131           x_error_tbl.delete;
132           --ELSE
133           --  l_message := NULL;
134         END IF;
135       END IF; --IF (c.desc_mir IS NOT NULL OR c.default_shipping_org IS NOT NULL) THEN
136     
137       --=============================================================================
138       --更新子组织信息
139       --============================================================================
140       --Master Inv Organization first, then Current Inv Organization
141       l_item_rec.organization_code := c.organization_code;
142       l_item_rec.item_number       := c.item_code;
143     
144       IF c.buyer IS NOT NULL THEN
145         BEGIN
146           SELECT he.employee_id
147             INTO l_buyer_id
148             FROM hr_employees he
149            WHERE he.full_name = c.buyer;
150         EXCEPTION
151           WHEN OTHERS THEN
152             l_buyer_id := NULL;
153         END;
154         IF l_buyer_id IS NOT NULL THEN
155           l_item_rec.buyer_id := l_buyer_id;
156         END IF;
157       ELSE
158         l_item_rec.buyer_id := NULL;
159       END IF;
160       IF c.planer IS NOT NULL THEN
161         l_item_rec.planner_code := c.planer;
162       ELSE
163         l_item_rec.planner_code := NULL;
164       END IF;
165       IF c.attribute1 IS NOT NULL THEN
166         l_item_rec.attribute1 := c.attribute1;
167       ELSE
168         l_item_rec.attribute1 := NULL;
169       END IF;
170       IF c.attribute2 IS NOT NULL THEN
171         l_item_rec.attribute2 := c.attribute2;
172       ELSE
173         l_item_rec.attribute2 := NULL;
174       END IF;
175       IF c.attribute3 IS NOT NULL THEN
176         l_item_rec.attribute3 := c.attribute3;
177       ELSE
178         l_item_rec.attribute3 := NULL;
179       END IF;
180       IF c.attribute4 IS NOT NULL THEN
181         l_item_rec.attribute4 := c.attribute4;
182       ELSE
183         l_item_rec.attribute4 := NULL;
184       END IF;
185       IF c.attribute5 IS NOT NULL THEN
186         l_item_rec.attribute5 := c.attribute5;
187       ELSE
188         l_item_rec.attribute5 := NULL;
189       END IF;
190       IF c.attribute6 IS NOT NULL THEN
191         l_item_rec.attribute6 := c.attribute6;
192       ELSE
193         l_item_rec.attribute6 := NULL;
194       END IF;
195       IF c.attribute7 IS NOT NULL THEN
196         l_item_rec.attribute7 := c.attribute7;
197       ELSE
198         l_item_rec.attribute7 := NULL;
199       END IF;
200       IF c.attribute8 IS NOT NULL THEN
201         l_item_rec.attribute8 := c.attribute8;
202       ELSE
203         l_item_rec.attribute8 := NULL;
204       END IF;
205       IF c.attribute9 IS NOT NULL THEN
206         l_item_rec.attribute9 := c.attribute9;
207       ELSE
208         l_item_rec.attribute9 := NULL;
209       END IF;
210       IF c.attribute10 IS NOT NULL THEN
211         l_item_rec.attribute10 := c.attribute10;
212       ELSE
213         l_item_rec.attribute10 := NULL;
214       END IF;
215       IF c.attribute11 IS NOT NULL THEN
216         l_item_rec.attribute11 := c.attribute11;
217       ELSE
218         l_item_rec.attribute11 := NULL;
219       END IF;
220       IF c.attribute12 IS NOT NULL THEN
221         l_item_rec.attribute12 := c.attribute12;
222       ELSE
223         l_item_rec.attribute12 := NULL;
224       END IF;
225       IF c.attribute13 IS NOT NULL THEN
226         l_item_rec.attribute13 := c.attribute13;
227       ELSE
228         l_item_rec.attribute13 := NULL;
229       END IF;
230       IF c.attribute14 IS NOT NULL THEN
231         l_item_rec.attribute14 := c.attribute14;
232       ELSE
233         l_item_rec.attribute14 := NULL;
234       END IF;
235       IF c.attribute15 IS NOT NULL THEN
236         l_item_rec.attribute15 := c.attribute15;
237       ELSE
238         l_item_rec.attribute15 := NULL;
239       END IF;
240       IF c.attribute16 IS NOT NULL THEN
241         l_item_rec.attribute16 := c.attribute16;
242       ELSE
243         l_item_rec.attribute16 := NULL;
244       END IF;
245       IF c.attribute17 IS NOT NULL THEN
246         l_item_rec.attribute17 := c.attribute17;
247       ELSE
248         l_item_rec.attribute17 := NULL;
249       END IF;
250       IF c.attribute18 IS NOT NULL THEN
251         l_item_rec.attribute18 := c.attribute18;
252       ELSE
253         l_item_rec.attribute18 := NULL;
254       END IF;
255       IF c.attribute19 IS NOT NULL THEN
256         l_item_rec.attribute19 := c.attribute19;
257       ELSE
258         l_item_rec.attribute19 := NULL;
259       END IF;
260       IF c.attribute20 IS NOT NULL THEN
261         l_item_rec.attribute20 := c.attribute20;
262       ELSE
263         l_item_rec.attribute20 := NULL;
264       END IF;
265     
266       IF (c.supply_subinventory IS NOT NULL) THEN
267         l_item_rec.wip_supply_subinventory := c.supply_subinventory;
268       ELSE
269         l_item_rec.wip_supply_subinventory := NULL;
270       END IF;
271     
272       IF (c.min_quantity IS NOT NULL) THEN
273         l_item_rec.min_minmax_quantity := c.min_quantity;
274       ELSE
275         l_item_rec.min_minmax_quantity := NULL;
276       END IF;
277       IF (c.max_quantity IS NOT NULL) THEN
278         l_item_rec.max_minmax_quantity := c.max_quantity;
279       ELSE
280         l_item_rec.max_minmax_quantity := NULL;
281       END IF;
282       IF (c.min_order_quantity IS NOT NULL) THEN
283         l_item_rec.minimum_order_quantity := c.min_order_quantity;
284       ELSE
285         l_item_rec.minimum_order_quantity := NULL;
286       END IF;
287       IF (c.max_order_quantity IS NOT NULL) THEN
288         l_item_rec.maximum_order_quantity := c.max_order_quantity;
289       ELSE
290         l_item_rec.maximum_order_quantity := NULL;
291       END IF;
292       IF (c.fixed_order_quantity IS NOT NULL) THEN
293         l_item_rec.fixed_order_quantity := c.fixed_order_quantity;
294       ELSE
295         l_item_rec.fixed_order_quantity := NULL;
296       END IF;
297       IF (c.fixed_days_supply IS NOT NULL) THEN
298         l_item_rec.fixed_days_supply := c.fixed_days_supply;
299       ELSE
300         l_item_rec.fixed_days_supply := NULL;
301       END IF;
302       IF (c.fixed_lot_multiplier IS NOT NULL) THEN
303         l_item_rec.fixed_lot_multiplier := c.fixed_lot_multiplier;
304       ELSE
305         l_item_rec.fixed_lot_multiplier := NULL;
306       END IF;
307     
308       BEGIN
309         SELECT gsob.chart_of_accounts_id
310           INTO l_chart_of_account_id
311           FROM gl_sets_of_books             gsob,
312                hr_operating_units           hou,
313                org_organization_definitions ood
314          WHERE gsob.set_of_books_id = hou.set_of_books_id
315            AND hou.organization_id = ood.operating_unit
316            AND ood.organization_code = c.organization_code;
317       EXCEPTION
318         WHEN OTHERS THEN
319           hss_conc_utl.log_msg(chart_of_account_id 没有找到);
320         
321           l_message := l_message || 组织对应chart_of_account_id 没有找到==;
322       END;
323     
324       -----------------------
325     
326       IF (c.encumbrance_account IS NOT NULL) THEN
327         l_ccid1                        := fnd_flex_ext.get_ccid(application_short_name => SQLGL,
328                                                                 key_flex_code          => GL#,
329                                                                 structure_number       => l_chart_of_account_id,
330                                                                 validation_date        => to_char(SYSDATE,
331                                                                                                   DD-MON-YYYY),
332                                                                 concatenated_segments  => c.encumbrance_account);
333         l_item_rec.encumbrance_account := l_ccid1;
334       
335         IF (l_ccid1 IS NULL) THEN
336           hss_conc_utl.log_msg(更新保留款账户异常!);
337           l_message := l_message || 保留款账户异常==;
338         END IF;
339       ELSE
340         l_item_rec.encumbrance_account := NULL;
341       END IF;
342       IF (c.expense_account IS NOT NULL) THEN
343         l_ccid2                    := fnd_flex_ext.get_ccid(application_short_name => SQLGL,
344                                                             key_flex_code          => GL#,
345                                                             structure_number       => l_chart_of_account_id,
346                                                             validation_date        => to_char(SYSDATE,
347                                                                                               DD-MON-YYYY),
348                                                             concatenated_segments  => c.expense_account);
349         l_item_rec.expense_account := l_ccid2;
350       
351         IF (l_ccid1 IS NULL) THEN
352           hss_conc_utl.log_msg(更新费用账户异常!);
353           l_message := l_message || 费用账户异常==;
354         END IF;
355       ELSE
356         l_item_rec.expense_account := NULL;
357       END IF;
358     
359       --l_item_rec.sales_account := NULL;
360       IF (c.sales_account IS NOT NULL) THEN
361         l_ccid3                  := fnd_flex_ext.get_ccid(application_short_name => SQLGL,
362                                                           key_flex_code          => GL#,
363                                                           structure_number       => l_chart_of_account_id,
364                                                           validation_date        => to_char(SYSDATE,
365                                                                                             DD-MON-YYYY),
366                                                           concatenated_segments  => c.sales_account);
367         l_item_rec.sales_account := l_ccid3;
368       
369         IF (l_ccid1 IS NULL) THEN
370           hss_conc_utl.log_msg(更新销售账户异常!);
371           l_message := l_message || 销售账户异常==;
372         END IF;
373       ELSE
374         hss_conc_utl.log_msg(物料 || c.item_code || 下的销售账户不能为空);
375         l_message := l_message || 物料 || c.item_code || 下的销售账户不能为空==;
376         --  l_item_rec.sales_account := NULL;
377       END IF;
378     
379       --l_item_rec.cost_of_sales_account := NULL;
380       IF (c.cost_of_sales_account IS NOT NULL) THEN
381         l_ccid4                          := fnd_flex_ext.get_ccid(application_short_name => SQLGL,
382                                                                   key_flex_code          => GL#,
383                                                                   structure_number       => l_chart_of_account_id,
384                                                                   validation_date        => to_char(SYSDATE,
385                                                                                                     DD-MON-YYYY),
386                                                                   concatenated_segments  => c.cost_of_sales_account);
387         l_item_rec.cost_of_sales_account := l_ccid4;
388       
389         IF (l_ccid1 IS NULL) THEN
390           hss_conc_utl.log_msg(更新销售成本账户异常!);
391           l_message := l_message || 销售成本账户异常==;
392         END IF;
393       ELSE
394         hss_conc_utl.log_msg(物料 || c.item_code || 下的销售成本账户不能为空);
395         l_message := l_message || 物料 || c.item_code || 下的销售成本账户不能为空==;
396         --  l_item_rec.cost_of_sales_account := NULL;
397       END IF;
398       --API
399       ----更新物料信息-----
400       inv_item_grp.update_item(p_commit        => fnd_api.g_false,
401                                p_item_rec      => l_item_rec,
402                                x_item_rec      => x_item_rec,
403                                x_return_status => x_return_status,
404                                x_error_tbl     => x_error_tbl);
405     
406       --Result
407       IF x_return_status <> fnd_api.g_ret_sts_success THEN
408         --ROLLBACK;
409         --l_message := NULL;
410         FOR i IN 1 .. x_error_tbl.count
411         LOOP
412           l_message := l_message || x_error_tbl(i).message_name;
413         END LOOP;
414         x_error_tbl.delete;
415         --ELSE
416         -- l_message := NULL;
417         -- COMMIT;
418       END IF;
419     
420       IF x_return_status = fnd_api.g_ret_sts_success THEN
421         IF c.inv_category_contractsegment IS NOT NULL THEN
422           BEGIN
423             --获取物料类别ID--------
424             SELECT mcv.category_id
425               INTO l_category_id
426               FROM mtl_categories_v mcv
427              WHERE 1 = 1
428                AND mcv.structure_id = l_structure_id
429                AND mcv.category_concat_segs = c.inv_category_contractsegment
430                AND (mcv.disable_date IS NULL OR mcv.disable_date > SYSDATE);
431           EXCEPTION
432             WHEN OTHERS THEN
433               l_category_id := NULL;
434           END;
435         
436           IF l_category_id IS NULL THEN
437             x_return_status := E;
438             l_message       := l_message || 物料类别 : || c.inv_category_contractsegment || 无效;
439           ELSE
440           
441             ----获取原来类别id
442             BEGIN
443               SELECT mic.category_id
444                 INTO l_old_category_id
445                 FROM mtl_system_items_b  msi,
446                      mtl_item_categories mic
447                WHERE 1 = 1
448                  AND msi.inventory_item_id = mic.inventory_item_id
449                  AND msi.organization_id = mic.organization_id
450                  AND msi.inventory_item_id = x_item_rec.inventory_item_id
451                  AND msi.organization_id = x_item_rec.organization_id
452                  AND mic.category_set_id = l_category_set_id;
453             EXCEPTION
454               WHEN OTHERS THEN
455                 l_old_category_id := NULL;
456             END;
457           
458             --- inv_item_category_pub.Create_Category_Assignment
459             IF l_old_category_id IS NOT NULL
460                AND l_old_category_id <> l_category_id THEN
461               ---更新物料类别分配
462               inv_item_category_pub.update_category_assignment(p_api_version       => 1.0,
463                                                                p_init_msg_list     => fnd_api.g_true,
464                                                                p_commit            => fnd_api.g_false,
465                                                                p_category_id       => l_category_id,
466                                                                p_old_category_id   => l_old_category_id,
467                                                                p_category_set_id   => l_category_set_id,
468                                                                p_inventory_item_id => x_item_rec.inventory_item_id,
469                                                                p_organization_id   => x_item_rec.organization_id,
470                                                                x_return_status     => x_return_status,
471                                                                x_errorcode         => l_errorcode,
472                                                                x_msg_count         => l_msg_count,
473                                                                x_msg_data          => x_message);
474             
475               IF x_return_status <> fnd_api.g_ret_sts_success THEN
476                 /*FOR i IN 2 .. l_msg_count LOOP
477                   l_message := fnd_msg_pub.get;
478                   \*dbms_output.put_line(REPLACE(l_message,
479                                                chr(0),
480                                                ‘ ‘));*481                 END LOOP;*/
482                 /*dbms_output.put_line(‘update_category_assignment:‘ ||
483                 x_return_status || l_message);*/
484                 hss_conc_utl.log_msg(l_category_id:= || l_category_id);
485                 hss_conc_utl.log_msg(l_category_set_id:= || l_category_set_id);
486               
487                 l_message := l_message || 分配物料类别报错: || x_message;
488               ELSE
489                 /*dbms_output.put_line(‘update_category_assignment:‘ ||
490                 x_return_status || l_message);*/
491                 NULL;
492               END IF;
493             ELSIF l_old_category_id IS NULL THEN
494               inv_item_category_pub.create_category_assignment(p_api_version       => 1.0,
495                                                                p_init_msg_list     => fnd_api.g_true,
496                                                                p_commit            => fnd_api.g_false,
497                                                                x_return_status     => x_return_status,
498                                                                x_errorcode         => l_errorcode,
499                                                                x_msg_count         => l_msg_count,
500                                                                x_msg_data          => x_message,
501                                                                p_category_id       => l_category_id,
502                                                                p_category_set_id   => l_category_set_id,
503                                                                p_inventory_item_id => x_item_rec.inventory_item_id,
504                                                                p_organization_id   => x_item_rec.organization_id);
505               IF x_return_status <> fnd_api.g_ret_sts_success THEN
506                 /*dbms_output.put_line(‘create_category_assignment:‘ ||
507                 x_return_status || l_message);*/
508                 hss_conc_utl.log_msg(l_category_id1:= || l_category_id);
509                 hss_conc_utl.log_msg(l_category_set_id1:= || l_category_set_id);
510               
511                 l_message := l_message || 分配物料类别报错: || x_message;
512               END IF;
513             ELSE
514               NULL;
515             END IF;
516           END IF; --IF l_old_category_id IS NOT NULL
517         END IF;
518       END IF;
519     
520       --更新物料类别信息
521       FOR rec_category IN (SELECT t.*
522                              FROM mtl_item_categories_v        t,
523                                   org_organization_definitions ood,
524                                   mtl_system_items_b           msib
525                             WHERE 1 = 1
526                               AND t.organization_id = ood.organization_id
527                               AND ood.organization_code = c.organization_code
528                               AND t.organization_id = msib.organization_id
529                               AND t.inventory_item_id = msib.inventory_item_id
530                               AND msib.segment1 = c.item_code
531                               AND t.category_set_name IN (BOSUN成本类别集,
532                                                           产品类别,
533                                                           BOSUN折扣类别集))
534       LOOP
535       
536         -- hss_conc_utl.log_msg(‘更新类别信息!‘);
537         IF (rec_category.category_set_name = BOSUN成本类别集) THEN
538           IF (c.chenben_category IS NOT NULL) THEN
539             BEGIN
540               UPDATE mtl_categories_b mcb
541                  SET mcb.segment1 = c.chenben_category
542                WHERE mcb.category_id = rec_category.category_id;
543             EXCEPTION
544               WHEN OTHERS THEN
545                 hss_conc_utl.log_msg(更新成本类别错误!);
546                 l_message := l_message || 更新成本类别错误;
547             END;
548           END IF;
549         ELSIF (rec_category.category_set_name = 产品类别) THEN
550           IF (c.shengchan_category IS NOT NULL) THEN
551             BEGIN
552               UPDATE mtl_categories_b mcb
553                  SET mcb.segment1 = c.shengchan_category
554                WHERE mcb.category_id = rec_category.category_id;
555             EXCEPTION
556               WHEN OTHERS THEN
557                 hss_conc_utl.log_msg(更新生产类别错误!);
558                 l_message := l_message || 更新生产类别错误;
559             END;
560           END IF;
561         ELSIF (rec_category.category_set_name = BOSUN折扣类别集) THEN
562           IF (c.zhekou_category IS NOT NULL) THEN
563             BEGIN
564               UPDATE mtl_categories_b mcb
565                  SET mcb.segment1 = c.zhekou_category
566                WHERE mcb.category_id = rec_category.category_id;
567             EXCEPTION
568               WHEN OTHERS THEN
569                 hss_conc_utl.log_msg(更新折扣类别错误!);
570                 l_message := l_message || 更新折扣类别错误;
571             END;
572           END IF;
573         END IF;
574       
575       END LOOP; --FOR rec_category IN (
576     
577       /* FOR rec_category IN (SELECT t.*
578                              FROM mtl_item_categories_v        t,
579                                   org_organization_definitions ood,
580                                   mtl_system_items_b           msib
581                             WHERE 1 = 1
582                               AND t.organization_id = ood.organization_id
583                               AND ood.organization_code = c.organization_code
584                               AND t.organization_id = msib.organization_id
585                               AND t.inventory_item_id = msib.inventory_item_id
586                               AND msib.segment1 = c.item_code
587                               AND t.category_set_name IN ( --‘BOSUN成本类别集‘,
588                                                           --‘产品类别‘,
589                                                           ‘BOSUN折扣类别集‘))
590       LOOP
591         l_category_rec.category_id       := rec_category.category_id;
592         l_category_rec.structure_id      := rec_category.structure_id;
593         l_category_rec.summary_flag      := rec_category.summary_flag;
594         l_category_rec.enabled_flag      := rec_category.enabled_flag;
595         --l_category_rec. := rec_category.;
596         l_category_rec.segment2          := rec_category.segment2;
597         l_category_rec.segment3          := rec_category.segment3;
598         l_category_rec.segment4          := rec_category.segment4;
599         l_category_rec.segment5          := rec_category.segment5;
600         l_category_rec.segment6          := rec_category.segment6;
601         l_category_rec.segment7          := rec_category.segment7;
602         l_category_rec.segment8          := rec_category.segment8;
603         l_category_rec.segment9          := rec_category.segment9;
604         l_category_rec.segment10         := rec_category.segment10;
605         l_category_rec.segment11         := rec_category.segment11;
606         l_category_rec.segment12         := rec_category.segment12;
607         l_category_rec.segment13         := rec_category.segment13;
608         l_category_rec.segment14         := rec_category.segment14;
609         l_category_rec.segment15         := rec_category.segment15;
610         l_category_rec.segment16         := rec_category.segment16;
611         l_category_rec.segment17         := rec_category.segment17;
612         l_category_rec.segment18         := rec_category.segment18;
613         l_category_rec.segment19         := rec_category.segment19;
614         l_category_rec.segment20         := rec_category.segment20;
615       
616         IF (rec_category.category_set_name = ‘BOSUN成本类别集‘) THEN
617           IF (c.chenben_category IS NOT NULL) THEN
618             l_category_rec.category_id := c.chenben_category;
619           END IF;
620         ELSIF (rec_category.category_set_name = ‘产品类别‘) THEN
621           IF (c.chenben_category IS NOT NULL) THEN
622             l_category_rec.segment1 := c.chenben_category;
623           END IF;
624         ELSIF (rec_category.category_set_name = ‘BOSUN折扣类别集‘) THEN
625           IF (c.zhekou_category IS NOT NULL) THEN
626             l_category_rec.segment1 := c.zhekou_category;
627           END IF;
628         END IF;
629       
630         inv_item_category_pub.update_category(p_api_version   => ‘1.0‘,
631                                               p_init_msg_list => fnd_api.g_true,
632                                               p_commit        => fnd_api.g_false,
633                                               x_return_status => x_return_status,
634                                               x_errorcode     => l_errorcode,
635                                               x_msg_count     => l_msg_count,
636                                               x_msg_data      => x_message,
637                                               p_category_rec  => l_category_rec);
638         IF x_return_status <> fnd_api.g_ret_sts_success THEN
639           hss_conc_utl.log_msg(‘更新物料类别信息错误!‘);
640           l_message := l_message || x_message;
641         END IF;
642       END LOOP; --FOR rec_category IN*/
643     
644       IF (l_message IS NOT NULL) THEN
645         --dbms_transaction.rollback_savepoint(l_savepoint_name);
646         hss_conc_utl.log_msg(l_message:= || l_message);
647         l_err_count := l_err_count + 1;
648       
649         ROLLBACK TO l_savepoint_name;
650       
651         UPDATE cux.cux_mtl_update_prperty t
652            SET t.return_stastus = E,
653                t.mes_text       = substr(l_message,
654                                          1,
655                                          2000)
656          WHERE t.id = c.id;
657       
658         l_message := NULL;
659         continue;
660       ELSE
661         UPDATE cux.cux_mtl_update_prperty t
662            SET t.return_stastus = x_return_status,
663                t.mes_text       = substr(l_message,
664                                          1,
665                                          200)
666          WHERE t.id = c.id;
667         l_message := NULL;
668       END IF;
669     END LOOP;
670   
671     IF (l_err_count > 0) THEN
672       hss_conc_utl.log_msg(存在异常未处理的数据,请求报黄!);
673       RAISE fnd_api.g_exc_error;
674     END IF;
675     -- end activity, include debug message hint to exit api
676     x_return_status := hss_api.end_activity(p_pkg_name  => g_pkg_name,
677                                             p_api_name  => l_api_name,
678                                             x_msg_count => x_msg_count,
679                                             x_msg_data  => x_msg_data);
680   
681   EXCEPTION
682     WHEN fnd_api.g_exc_error THEN
683       x_return_status := hss_api.handle_exceptions(p_pkg_name  => g_pkg_name,
684                                                    p_api_name  => l_api_name,
685                                                    p_exc_name  => hss_api.g_exc_name_error,
686                                                    x_msg_count => x_msg_count,
687                                                    x_msg_data  => x_msg_data);
688     WHEN fnd_api.g_exc_unexpected_error THEN
689       x_return_status := hss_api.handle_exceptions(p_pkg_name  => g_pkg_name,
690                                                    p_api_name  => l_api_name,
691                                                    p_exc_name  => hss_api.g_exc_name_unexp,
692                                                    x_msg_count => x_msg_count,
693                                                    x_msg_data  => x_msg_data);
694     WHEN OTHERS THEN
695       x_return_status := hss_api.handle_exceptions(p_pkg_name  => g_pkg_name,
696                                                    p_api_name  => l_api_name,
697                                                    p_exc_name  => hss_api.g_exc_name_others,
698                                                    x_msg_count => x_msg_count,
699                                                    x_msg_data  => x_msg_data);
700   END update_item;
创建物料

 

INV(库存管理)

标签:

原文地址:http://www.cnblogs.com/wang-chen/p/5902806.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!