[Home] [Help]
736: ELSIF p_doc_type = 'IDV' THEN
737:
738: l_functional_area := 'PURCHASING';
739: --
740: IF (po_autocreate_params.g_clm_source_document_id IS NOT NULL) THEN
741: SELECT type_lookup_code
742: INTO l_doc_type
743: FROM po_headers_all
744: WHERE po_header_id = po_autocreate_params.g_clm_source_document_id;
740: IF (po_autocreate_params.g_clm_source_document_id IS NOT NULL) THEN
741: SELECT type_lookup_code
742: INTO l_doc_type
743: FROM po_headers_all
744: WHERE po_header_id = po_autocreate_params.g_clm_source_document_id;
745: ELSE
746: l_doc_type := 'BLANKET';
747: END IF;
748:
796:
797:
798: l_progress := '020';
799:
800: IF po_autocreate_params.g_interface_source_code='SOURCING'
801: THEN
802:
803: l_progress := '030';
804:
808:
809: SELECT bid_number
810: INTO x_pk1_value
811: FROM po_lines_interface
812: WHERE interface_header_id=po_autocreate_params.g_interface_header_id
813: AND ROWNUM=1;
814:
815: IF x_pk1_value IS NOT NULL AND p_doc_level='LINE' AND p_intf_line_id IS NOT NULL
816: THEN
818: l_progress := '050';
819:
820: SELECT bid_line_number INTO x_pk2_value
821: FROM po_lines_interface
822: WHERE interface_header_id = po_autocreate_params.g_interface_header_id
823: AND interface_line_id = p_intf_line_id;
824: END IF;
825:
826: ELSIF p_doc_type = 'SOL' THEN
832: FROM pon_bid_headers
833: WHERE BID_NUMBER=
834: (SELECT bid_number
835: FROM po_lines_interface
836: WHERE interface_header_id=po_autocreate_params.g_interface_header_id
837: AND ROWNUM=1);
838:
839: IF x_pk1_value IS NOT NULL AND p_doc_level='LINE' AND p_intf_line_id IS NOT NULL
840: THEN
857: FROM po_requisition_lines_all
858: WHERE requisition_line_id =(
859: SELECT requisition_line_id
860: FROM po_lines_interface
861: WHERE interface_header_id=po_autocreate_params.g_interface_header_id
862: AND requisition_line_id IS NOT NULL
863: AND ROWNUM=1);
864:
865: IF x_pk1_value IS NOT NULL AND p_doc_level='LINE' AND p_intf_line_id IS NOT NULL
882: FROM pon_bid_headers
883: WHERE BID_NUMBER=
884: (SELECT bid_number
885: FROM po_lines_interface
886: WHERE interface_header_id=po_autocreate_params.g_interface_header_id
887: AND ROWNUM=1);
888:
889: IF x_pk1_value IS NOT NULL THEN
890: l_progress := '105';
907: AND bid.line_number = PLI.bid_line_number;
908: END IF;
909:
910: END IF;
911: END IF; -- po_autocreate_params.g_interface_source_code='SOURCING'
912:
913: IF po_autocreate_params.g_interface_source_code='PO' THEN
914: l_progress := '120';
915:
909:
910: END IF;
911: END IF; -- po_autocreate_params.g_interface_source_code='SOURCING'
912:
913: IF po_autocreate_params.g_interface_source_code='PO' THEN
914: l_progress := '120';
915:
916: IF p_doc_type = 'PR' THEN
917:
923: INTO x_pk1_value
924: FROM po_requisition_lines_all
925: WHERE requisition_line_id =( SELECT requisition_line_id
926: FROM PO_LINES_INTERFACE
927: WHERE interface_header_id=po_autocreate_params.g_interface_header_id
928: AND ROWNUM=1);
929: END IF;
930:
931: IF p_doc_level='LINE' AND p_intf_line_id IS NOT NULL
943:
944: --
945: SELECT Nvl(from_header_id,contract_id), -1 INTO x_pk1_value, x_pk2_value
946: FROM po_lines_interface
947: WHERE interface_header_id=po_autocreate_params.g_interface_header_id
948: AND (from_header_id is not NULL OR contract_id IS NOT NULL)
949: AND ROWNUM=1;
950:
951: IF x_pk1_value IS NOT NULL THEN
972: l_progress := '180';
973:
974: SELECT from_header_id INTO x_pk1_value
975: FROM po_lines_interface
976: WHERE interface_header_id=po_autocreate_params.g_interface_header_id
977: AND from_header_id is not null
978: AND ROWNUM=1;
979:
980: l_progress := '190';
1006: l_progress := '220';
1007:
1008: SELECT from_header_id INTO x_pk1_value
1009: FROM po_lines_interface
1010: WHERE interface_header_id=po_autocreate_params.g_interface_header_id
1011: AND ROWNUM=1;
1012:
1013: l_progress := '230';
1014: SELECT auction_header_id
1561: ,p_src_doc_level => p_src_doc_level
1562: ,p_intf_line_id => NULL
1563: ,p_attr_group => p_attr_group
1564: ,p_to_pk1_col_name => 'PO_HEADER_ID'
1565: ,p_to_pk1_value => po_autocreate_params.g_po_header_id
1566: ,p_priorities_tbl => p_priorities_tbl
1567: );
1568:
1569:
1599: pli.shipment_num,
1600: pli.unit_price,
1601: PLI.interface_line_id) rn
1602: FROM po_lines_interface pli
1603: WHERE pli.interface_header_id = po_autocreate_params.g_interface_header_id
1604: /*Bug : 13561015
1605: Introducing an NVL condition which take NULL value(coming from SOURCING) in action
1606: as NEW action.
1607: */
1671: pli.shipment_num,
1672: pli.unit_price,
1673: pli.interface_line_id) rn
1674: FROM po_lines_interface PLI
1675: WHERE pli.interface_header_id = po_autocreate_params.g_interface_header_id
1676: /*Bug : 13561015
1677: Introducing an NVL condition which take NULL value(coming from SOURCING) in action
1678: as NEW action.
1679: */
1680: AND Nvl(pli.action,'NEW') = 'NEW')
1681: WHERE rn = 1) intf_lines
1682: WHERE poll.po_line_id = intf_lines.po_line_id
1683: AND poll.shipment_num = intf_lines.shipment_num
1684: AND poll.po_header_id = po_autocreate_params.g_po_header_id
1685: AND draft_id = po_autocreate_params.g_draft_id;
1686: --When shipments are grouped we have to pick the first shipment for defaulting UDA.
1687: --Ordering should be done on the bases of line_num, shipment_num, unit_price,
1688: --interface_line_id
1681: WHERE rn = 1) intf_lines
1682: WHERE poll.po_line_id = intf_lines.po_line_id
1683: AND poll.shipment_num = intf_lines.shipment_num
1684: AND poll.po_header_id = po_autocreate_params.g_po_header_id
1685: AND draft_id = po_autocreate_params.g_draft_id;
1686: --When shipments are grouped we have to pick the first shipment for defaulting UDA.
1687: --Ordering should be done on the bases of line_num, shipment_num, unit_price,
1688: --interface_line_id
1689: --If shipments are being added to existing PO shipment no processing is required.
1737: END IF;
1738:
1739:
1740: IF p_doc_level = 'HEADER'
1741: AND ( po_autocreate_params.g_mode = 'NEW'
1742: /*bug 12611018 starts
1743: OR (po_autocreate_params.g_mode='ADD'
1744: AND NOT po_autocreate_params.g_is_mod_exists
1745: ) bug 12611018 ends */
1739:
1740: IF p_doc_level = 'HEADER'
1741: AND ( po_autocreate_params.g_mode = 'NEW'
1742: /*bug 12611018 starts
1743: OR (po_autocreate_params.g_mode='ADD'
1744: AND NOT po_autocreate_params.g_is_mod_exists
1745: ) bug 12611018 ends */
1746: )
1747: THEN
1740: IF p_doc_level = 'HEADER'
1741: AND ( po_autocreate_params.g_mode = 'NEW'
1742: /*bug 12611018 starts
1743: OR (po_autocreate_params.g_mode='ADD'
1744: AND NOT po_autocreate_params.g_is_mod_exists
1745: ) bug 12611018 ends */
1746: )
1747: THEN
1748: l_progress := '010';
1799: SELECT PLI.interface_line_id,PLI.requisition_line_id,PLI.bid_number,PLI.bid_line_number,PLI.line_num
1800: FROM po_line_types plt, po_lines_interface pli
1801: WHERE plt.line_type_id = pli.line_type_id
1802: AND plt.ORDER_TYPE_LOOKUP_CODE IN ('AMOUNT','FIXED PRICE')--Bug 9945827
1803: AND PLI.interface_header_id = po_autocreate_params.g_interface_header_id
1804: --CLM Phase 2 Autocreate Changes start
1805: --Bug 13612198 : Comlpex pricing attributes were not copied.
1806: /*Bug : 13561015
1807: Introducing an NVL condition which take NULL value(coming from SOURCING) in action
1820: CURSOR cur_target_lines(p_intf_line_id NUMBER)
1821: IS
1822: SELECT pla.po_line_id
1823: FROM po_lines_interface PLI,po_lines_draft_all pla
1824: WHERE PLI.interface_header_id = po_autocreate_params.g_interface_header_id
1825: AND PLI.interface_line_id = p_intf_line_id
1826: AND PLI.line_num = pla.line_num
1827: AND pla.draft_id = po_autocreate_params.g_draft_id;
1828:
1823: FROM po_lines_interface PLI,po_lines_draft_all pla
1824: WHERE PLI.interface_header_id = po_autocreate_params.g_interface_header_id
1825: AND PLI.interface_line_id = p_intf_line_id
1826: AND PLI.line_num = pla.line_num
1827: AND pla.draft_id = po_autocreate_params.g_draft_id;
1828:
1829: l_src_template_id NUMBER;
1830: l_target_template_id NUMBER;
1831: from_pk_col_value_pairs EGO_COL_NAME_VALUE_PAIR_ARRAY;
1862:
1863: FOR l_src_rec IN cur_src_lines
1864: LOOP
1865:
1866: IF po_autocreate_params.g_interface_source_code='SOURCING' THEN
1867: l_progress := '040';
1868: l_src_template_id := get_template_id ('PON_BID_ITEM_PRICES'
1869: ,'BID_NUMBER'
1870: ,l_src_rec.bid_number
2015: IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
2016: UPDATE po_lines_draft_all
2017: SET clm_uda_pricing_total = Decode(matching_basis, 'QUANTITY', quantity, amount)
2018: WHERE po_line_id = l_to_pk1_value
2019: AND draft_id = po_autocreate_params.g_draft_id
2020: AND order_type_lookup_code IN ('AMOUNT','FIXED PRICE');
2021: END IF;
2022:
2023: END IF;
2578: );
2579: END IF;
2580:
2581: --bug 13640946 start, for new documents the data is still in the draft tables. Hence modified the logic to select attribute_group_id from draft tables
2582: IF po_autocreate_params.g_mode = 'NEW' THEN
2583: IF p_level = 'HEADER' THEN
2584:
2585: SELECT distinct pudat.attribute_group_id
2586: BULK COLLECT INTO x_attr_group_id_tbl
2591: WHERE ea.action_id = ead.action_id
2592: AND ea.attr_group_id = pudat.attribute_group_id
2593: AND ea.classification_code = To_Char(pudat.template_id )
2594: AND ead.EXECUTION_METHOD = 'XPD'
2595: AND poh.po_header_id = po_autocreate_params.g_po_header_id
2596: AND poh.uda_template_id = pudat.template_id;
2597:
2598:
2599: ELSIF p_level = 'LINE' THEN
2607: WHERE ea.action_id = ead.action_id
2608: AND ea.attr_group_id = pudat.attribute_group_id
2609: AND ea.classification_code = To_Char(pudat.template_id )
2610: AND ead.EXECUTION_METHOD = 'XPD'
2611: AND poh.po_header_id = po_autocreate_params.g_po_header_id
2612: AND pudat.template_id = (SELECT uda_template_id
2613: FROM po_lines_draft_all
2614: WHERE po_header_id = poh.po_header_id
2615: AND ROWNUM < 2) ;
2626: WHERE ea.action_id = ead.action_id
2627: AND ea.attr_group_id = pudat.attribute_group_id
2628: AND ea.classification_code = To_Char(pudat.template_id )
2629: AND ead.EXECUTION_METHOD = 'XPD'
2630: AND poh.po_header_id = po_autocreate_params.g_po_header_id
2631: AND pudat.template_id = (SELECT uda_template_id
2632: FROM po_line_locations_draft_all
2633: WHERE po_header_id = poh.po_header_id
2634: AND ROWNUM < 2) ;
2646: WHERE ea.action_id = ead.action_id
2647: AND ea.attr_group_id = pudat.attribute_group_id
2648: AND ea.classification_code = To_Char(pudat.template_id )
2649: AND ead.EXECUTION_METHOD = 'XPD'
2650: AND poh.po_header_id = po_autocreate_params.g_po_header_id
2651: AND poh.uda_template_id = pudat.template_id;
2652:
2653:
2654: ELSIF p_level = 'LINE' THEN
2662: WHERE ea.action_id = ead.action_id
2663: AND ea.attr_group_id = pudat.attribute_group_id
2664: AND ea.classification_code = To_Char(pudat.template_id )
2665: AND ead.EXECUTION_METHOD = 'XPD'
2666: AND poh.po_header_id = po_autocreate_params.g_po_header_id
2667: AND pudat.template_id = (SELECT uda_template_id
2668: FROM po_lines_all
2669: WHERE po_header_id = poh.po_header_id
2670: AND ROWNUM < 2) ;
2681: WHERE ea.action_id = ead.action_id
2682: AND ea.attr_group_id = pudat.attribute_group_id
2683: AND ea.classification_code = To_Char(pudat.template_id )
2684: AND ead.EXECUTION_METHOD = 'XPD'
2685: AND poh.po_header_id = po_autocreate_params.g_po_header_id
2686: AND pudat.template_id = (SELECT uda_template_id
2687: FROM po_line_locations_all
2688: WHERE po_header_id = poh.po_header_id
2689: AND ROWNUM < 2) ;
2726: FROM po_lines_draft_all pld, po_lines_interface PLI
2727: WHERE
2728: --bug 13640946 commenting out the condition as template_id has been stamped in the drafts table before making thisa uda call.
2729: --pld.uda_template_id IS NULL AND
2730: PLI.interface_header_id = po_autocreate_params.g_interface_header_id
2731: AND PLD.po_header_id = po_autocreate_params.g_po_header_id
2732: AND pld. line_num =PLI.line_num
2733: AND pld. draft_id = po_autocreate_params.g_draft_id
2734: ;
2727: WHERE
2728: --bug 13640946 commenting out the condition as template_id has been stamped in the drafts table before making thisa uda call.
2729: --pld.uda_template_id IS NULL AND
2730: PLI.interface_header_id = po_autocreate_params.g_interface_header_id
2731: AND PLD.po_header_id = po_autocreate_params.g_po_header_id
2732: AND pld. line_num =PLI.line_num
2733: AND pld. draft_id = po_autocreate_params.g_draft_id
2734: ;
2735:
2729: --pld.uda_template_id IS NULL AND
2730: PLI.interface_header_id = po_autocreate_params.g_interface_header_id
2731: AND PLD.po_header_id = po_autocreate_params.g_po_header_id
2732: AND pld. line_num =PLI.line_num
2733: AND pld. draft_id = po_autocreate_params.g_draft_id
2734: ;
2735:
2736: CURSOR c_shipments
2737: IS
2739: FROM po_lines_draft_all pld, po_lines_interface PLI, po_line_locations_draft_all pll
2740: WHERE
2741: --bug 13640946 commenting out the condition as template_id has been stamped in the drafts table before making thisa uda call.
2742: --pll.uda_template_id IS NULL AND
2743: PLI.interface_header_id = po_autocreate_params.g_interface_header_id
2744: AND PLD.po_header_id = po_autocreate_params.g_po_header_id
2745: AND pld. line_num =PLI.line_num
2746: AND pld.po_line_id = pll.po_line_id
2747: AND pll.shipment_num=PLI.shipment_num
2740: WHERE
2741: --bug 13640946 commenting out the condition as template_id has been stamped in the drafts table before making thisa uda call.
2742: --pll.uda_template_id IS NULL AND
2743: PLI.interface_header_id = po_autocreate_params.g_interface_header_id
2744: AND PLD.po_header_id = po_autocreate_params.g_po_header_id
2745: AND pld. line_num =PLI.line_num
2746: AND pld.po_line_id = pll.po_line_id
2747: AND pll.shipment_num=PLI.shipment_num
2748: AND pld. draft_id = po_autocreate_params.g_draft_id
2744: AND PLD.po_header_id = po_autocreate_params.g_po_header_id
2745: AND pld. line_num =PLI.line_num
2746: AND pld.po_line_id = pll.po_line_id
2747: AND pll.shipment_num=PLI.shipment_num
2748: AND pld. draft_id = po_autocreate_params.g_draft_id
2749: AND pll.draft_id = po_autocreate_params.g_draft_id
2750: ;
2751:
2752: BEGIN
2745: AND pld. line_num =PLI.line_num
2746: AND pld.po_line_id = pll.po_line_id
2747: AND pll.shipment_num=PLI.shipment_num
2748: AND pld. draft_id = po_autocreate_params.g_draft_id
2749: AND pll.draft_id = po_autocreate_params.g_draft_id
2750: ;
2751:
2752: BEGIN
2753:
2768: l_progress := '030';
2769: exec_uda_function(
2770: p_template_id => p_template_id ,
2771: p_pk1_col_name => 'PO_HEADER_ID',
2772: p_pk1_col_value => po_autocreate_params.g_po_header_id,
2773: p_pk2_col_name => 'DRAFT_ID',
2774: p_pk2_col_value => g_draft_id,
2775: p_attr_group_id_tbl => x_attr_group_id_tbl
2776: );
2876: AND DESCRIPTIVE_FLEX_CONTEXT_CODE = p_ag_name;
2877:
2878: BEGIN
2879: /*
2880: IF po_autocreate_params.g_mode <> 'NEW' AND p_doc_level = 'HEADER' THEN
2881: RETURN;
2882: END IF; */
2883:
2884: IF g_debug_stmt THEN
3083: l_document_subtype VARCHAR(100);
3084:
3085: BEGIN
3086:
3087: -- PO_AUTOCREATE_PARAMS.g_document_type = 'PO'
3088: -- PO_AUTOCREATE_PARAMS.g_document_subtype in ('STANDARD', 'PLANNED', 'RELEASE'))
3089:
3090:
3091: IF g_debug_stmt THEN
3084:
3085: BEGIN
3086:
3087: -- PO_AUTOCREATE_PARAMS.g_document_type = 'PO'
3088: -- PO_AUTOCREATE_PARAMS.g_document_subtype in ('STANDARD', 'PLANNED', 'RELEASE'))
3089:
3090:
3091: IF g_debug_stmt THEN
3092: PO_DEBUG.debug_begin(p_log_head => g_log_head||l_api_name);
3095: l_progress := '010';
3096: SELECT interface_source_code, document_type_code, document_subtype, style_id
3097: INTO l_interface_source_code, l_document_type, l_document_subtype, l_document_style_id
3098: FROM po_headers_interface
3099: WHERE interface_header_id = po_autocreate_params.g_interface_header_id;
3100:
3101: l_progress := '020';
3102:
3103: IF l_interface_source_code ='PO'
3129: g_target_doc_style := l_document_style_id;
3130:
3131: g_tar_head_col_name_val_pairs := EGO_COL_NAME_VALUE_PAIR_ARRAY(
3132: EGO_COL_NAME_VALUE_PAIR_OBJ(
3133: 'PO_HEADER_ID', po_autocreate_params.g_po_header_id
3134: ),
3135: EGO_COL_NAME_VALUE_PAIR_OBJ(
3136: 'DRAFT_ID',g_draft_id)
3137: );
3250: address also need to defaulted explicitly
3251: */
3252: l_progress := '021';
3253:
3254: IF (x_doc_level_tbl(i) = 'HEADER' AND PO_AUTOCREATE_PARAMS.g_mode = 'ADD') then
3255:
3256: BEGIN
3257:
3258: select authorization_status
3257:
3258: select authorization_status
3259: INTO l_authorization_status
3260: FROM po_headers_all
3261: WHERE po_header_id = PO_AUTOCREATE_PARAMS.g_po_header_id;
3262:
3263: EXCEPTION
3264: WHEN No_Data_Found THEN
3265: l_authorization_status:='';
3266: END;
3267:
3268: /* Header level UDA attributes should be copied from base award to MOD
3269: only while creating a new modification in the ADD to mode.*/
3270: IF ( NOT po_autocreate_params.g_is_mod_exists
3271: AND Nvl(l_authorization_status,'INCOMPLETE') = 'APPROVED') THEN
3272:
3273: l_progress := '022';
3274:
3401:
3402: BEGIN
3403: x_pk1_col_name := 'PO_HEADER_ID';
3404: x_pk2_col_name := 'DRAFT_ID';
3405: x_pk1_value := po_autocreate_params.g_po_header_id;
3406: x_pk2_value := -1;
3407:
3408: x_src_template_id := get_template_id (p_table_name => 'PO_HEADERS_ALL'
3409: ,p_pkey1_col_name => 'PO_HEADER_ID'
3406: x_pk2_value := -1;
3407:
3408: x_src_template_id := get_template_id (p_table_name => 'PO_HEADERS_ALL'
3409: ,p_pkey1_col_name => 'PO_HEADER_ID'
3410: ,p_pkey1_val => po_autocreate_params.g_po_header_id
3411: ,p_pkey2_col_name => NULL
3412: ,p_pkey2_val => NULL
3413: );
3414:
3421: END IF;
3422:
3423: from_pk_col_value_pairs := EGO_COL_NAME_VALUE_PAIR_ARRAY(
3424: EGO_COL_NAME_VALUE_PAIR_OBJ(
3425: 'PO_HEADER_ID', po_autocreate_params.g_po_header_id
3426: ),
3427: EGO_COL_NAME_VALUE_PAIR_OBJ(
3428: 'DRAFT_ID', -1
3429: ));
3428: 'DRAFT_ID', -1
3429: ));
3430: to_pk_col_value_pairs := EGO_COL_NAME_VALUE_PAIR_ARRAY(
3431: EGO_COL_NAME_VALUE_PAIR_OBJ(
3432: 'PO_HEADER_ID', po_autocreate_params.g_po_header_id
3433: ),
3434: EGO_COL_NAME_VALUE_PAIR_OBJ(
3435: 'DRAFT_ID',g_draft_id));
3436: