210: RETURN NUMBER IS
211: l_line_rec OE_ORDER_PUB.LINE_REC_TYPE;
212: l_unit_cost NUMBER;
213: l_cost_group_id NUMBER;
214: l_item_rec OE_ORDER_CACHE.item_rec_type;
215: l_set_of_books Oe_Order_Cache.Set_Of_Books_Rec_Type;
216: l_order_currency VARCHAR2(30);
217: l_set_of_books_id VARCHAR2(30);
218: l_sob_currency VARCHAR2(30);
211: l_line_rec OE_ORDER_PUB.LINE_REC_TYPE;
212: l_unit_cost NUMBER;
213: l_cost_group_id NUMBER;
214: l_item_rec OE_ORDER_CACHE.item_rec_type;
215: l_set_of_books Oe_Order_Cache.Set_Of_Books_Rec_Type;
216: l_order_currency VARCHAR2(30);
217: l_set_of_books_id VARCHAR2(30);
218: l_sob_currency VARCHAR2(30);
219: l_old_unit_cost NUMBER;
504: END IF;
505:
506: -- INVCONV
507: If l_item_rec.primary_uom_code is null or l_item_rec.primary_uom_code = fnd_api.g_miss_char then
508: l_item_rec := OE_Order_Cache.Load_Item(l_line_rec.inventory_item_id,
509: G_SHIP_FROM_ORG_ID);
510: End if;
511:
512: -- IF Process org call OPM API to get cost
560:
561: debug(' unit cost before convert:'||l_unit_cost);
562: debug('primary_uom_code : '||l_item_rec.primary_uom_code);
563: If l_item_rec.primary_uom_code is null or l_item_rec.primary_uom_code = fnd_api.g_miss_char then
564: l_item_rec := OE_Order_Cache.Load_Item(l_line_rec.inventory_item_id,
565: G_SHIP_FROM_ORG_ID);
566: End If;
567: debug('Order_quantity_uom : '||l_Line_rec.Order_quantity_uom);
568: debug('Inventory_item_id : '||l_Line_rec.Inventory_item_id);
581: END IF;
582:
583:
584: debug(' Line ship_from_org_id:'||l_line_rec.ship_from_org_id);
585: debug(' Order ship_from_org_id:'||OE_ORDER_CACHE.g_header_rec.ship_from_org_id);
586:
587: --Pricing and Availbility call
588: IF l_PA_CALL THEN
589: SELECT NVL(default_cost_group_id,-1)
609: BEGIN
610: SELECT SET_OF_BOOKS_ID
611: INTO l_set_of_books_id
612: FROM ORG_ORGANIZATION_DEFINITIONS
613: -- WHERE ORGANIZATION_ID = nvl(OE_ORDER_CACHE.g_header_rec.ship_from_org_id,G_SHIP_FROM_ORG_ID);
614: -- bug 6518329/6709490
615: WHERE ORGANIZATION_ID = nvl(G_SHIP_FROM_ORG_ID,OE_ORDER_CACHE.g_header_rec.ship_from_org_id);
616:
617: EXCEPTION
611: INTO l_set_of_books_id
612: FROM ORG_ORGANIZATION_DEFINITIONS
613: -- WHERE ORGANIZATION_ID = nvl(OE_ORDER_CACHE.g_header_rec.ship_from_org_id,G_SHIP_FROM_ORG_ID);
614: -- bug 6518329/6709490
615: WHERE ORGANIZATION_ID = nvl(G_SHIP_FROM_ORG_ID,OE_ORDER_CACHE.g_header_rec.ship_from_org_id);
616:
617: EXCEPTION
618: WHEN OTHERS THEN
619: --need to handle... to be added....
636:
637: IF l_PA_CALL THEN
638: l_order_currency := p_order_currency;
639: ELSE
640: IF OE_ORDER_CACHE.g_header_rec.header_id IS NULL OR
641: OE_ORDER_CACHE.g_header_rec.header_id <> l_line_rec.header_id
642: THEN
643: OE_Header_Util.query_row(p_header_id => l_line_rec.header_id
644: , x_header_rec => OE_ORDER_CACHE.g_header_rec);
637: IF l_PA_CALL THEN
638: l_order_currency := p_order_currency;
639: ELSE
640: IF OE_ORDER_CACHE.g_header_rec.header_id IS NULL OR
641: OE_ORDER_CACHE.g_header_rec.header_id <> l_line_rec.header_id
642: THEN
643: OE_Header_Util.query_row(p_header_id => l_line_rec.header_id
644: , x_header_rec => OE_ORDER_CACHE.g_header_rec);
645: END IF;
640: IF OE_ORDER_CACHE.g_header_rec.header_id IS NULL OR
641: OE_ORDER_CACHE.g_header_rec.header_id <> l_line_rec.header_id
642: THEN
643: OE_Header_Util.query_row(p_header_id => l_line_rec.header_id
644: , x_header_rec => OE_ORDER_CACHE.g_header_rec);
645: END IF;
646: l_order_currency := OE_ORDER_CACHE.g_header_rec.transactional_curr_code;
647: END IF;
648:
642: THEN
643: OE_Header_Util.query_row(p_header_id => l_line_rec.header_id
644: , x_header_rec => OE_ORDER_CACHE.g_header_rec);
645: END IF;
646: l_order_currency := OE_ORDER_CACHE.g_header_rec.transactional_curr_code;
647: END IF;
648:
649: DEBUG(' Order currency:'||l_order_currency);
650: DEBUG(' Cost''s sob currency:'||g_sob_currency);
654: IF l_order_currency <> G_SOB_CURRENCY THEN
655: BEGIN
656:
657: IF NOT l_PA_CALL THEN
658: IF OE_ORDER_CACHE.g_header_rec.conversion_type_code = 'User'
659: AND OE_ORDER_CACHE.g_header_rec.conversion_rate IS NULL
660: THEN
661: DEBUG(' USER conversion type without rate, unable to perform cost conversion');
662: RETURN NULL;
655: BEGIN
656:
657: IF NOT l_PA_CALL THEN
658: IF OE_ORDER_CACHE.g_header_rec.conversion_type_code = 'User'
659: AND OE_ORDER_CACHE.g_header_rec.conversion_rate IS NULL
660: THEN
661: DEBUG(' USER conversion type without rate, unable to perform cost conversion');
662: RETURN NULL;
663: END IF;
661: DEBUG(' USER conversion type without rate, unable to perform cost conversion');
662: RETURN NULL;
663: END IF;
664:
665: IF OE_ORDER_CACHE.g_header_rec.conversion_type_code IS NULL THEN
666: DEBUG(' Conversion type not entered in sales order header,unable to perfor cost conversion');
667: RETURN NULL;
668: END IF;
669:
680:
681: END IF;
682:
683: IF NOT l_PA_CALL THEN
684: l_conversion_type_code := OE_ORDER_CACHE.g_header_rec.conversion_type_code;
685: l_conversion_rate := OE_ORDER_CACHE.g_header_rec.conversion_rate;
686: ELSE
687: l_conversion_type_code := p_conversion_type_code;
688: l_conversion_rate := p_conversion_rate;
681: END IF;
682:
683: IF NOT l_PA_CALL THEN
684: l_conversion_type_code := OE_ORDER_CACHE.g_header_rec.conversion_type_code;
685: l_conversion_rate := OE_ORDER_CACHE.g_header_rec.conversion_rate;
686: ELSE
687: l_conversion_type_code := p_conversion_type_code;
688: l_conversion_rate := p_conversion_rate;
689: END IF;