1: PACKAGE BODY PORCPTWF AS
2: /* $Header: PORCPWFB.pls 120.22.12020000.4 2013/04/05 03:43:03 jiarsun ship $*/
3:
4: -- Read the profile option that enables/disables the debug log
5: g_po_wf_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('PO_SET_DEBUG_WORKFLOW_ON'),'N');
6:
7: -- Added parameter to check if distribution data updation is to be skipped
8: Function Populate_Order_Info(itemtype in varchar2,
9: itemkey in varchar2,
136: x_primary_uom_class VARCHAR2(10);
137: x_item_id NUMBER;
138: x_org_id NUMBER;
139: x_rcv_trans_status VARCHAR2(500) := NULL;
140: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
141: x_insert_txns_status NUMBER;
142: x_auto_receive_flag VARCHAR2(1);
143:
144: t_po_header_id rcvNumberArray;
337: x_WF_ItemKey VARCHAR2(100);
338: x_WF_ItemKey_save VARCHAR2(100);
339: x_auto_receive_flag VARCHAR2(1);
340: x_WF_process_exists BOOLEAN;
341: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
342: x_wf_itemtype varchar2(6) := 'PORCPT';
343: x_revision_num number;
344: x_internal_req_rcpt Varchar2(1) := FND_PROFILE.value('POR_INTERNAL_CONFIRM_RECEIPT');
345: x_sys_date DATE;
340: x_WF_process_exists BOOLEAN;
341: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
342: x_wf_itemtype varchar2(6) := 'PORCPT';
343: x_revision_num number;
344: x_internal_req_rcpt Varchar2(1) := FND_PROFILE.value('POR_INTERNAL_CONFIRM_RECEIPT');
345: x_sys_date DATE;
346: x_item_key_count number;
347: x_po_num_rel_num POR_RCV_ALL_ITEMS_V1.PO_NUM_REL_NUM%type;
348:
571: x_group_id NUMBER;
572: x_inserted_txn_status NUMBER := 0;
573: x_RCV_txns_rc NUMBER := 0;
574: x_rcv_trans_status VARCHAR2(500) := NULL;
575: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
576:
577: t_req_line_id rcvNumberArray;
578: t_expected_receipt_qty rcvNumberArray;
579: t_ordered_uom rcvVarcharArray;
722: x_WF_ItemKey VARCHAR2(100);
723: x_WF_ItemKey_save VARCHAR2(100);
724: x_auto_receive_flag VARCHAR2(1);
725: x_WF_process_exists BOOLEAN;
726: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
727: ssp_version VARCHAR2(30) := FND_PROFILE.value('POR_SSP_VERSION');
728: x_ssp_version_gt4 VARCHAR2(10) := 'Y';
729: x_wf_itemtype varchar2(6) := 'PORCPT';
730: x_revision_num number;
723: x_WF_ItemKey_save VARCHAR2(100);
724: x_auto_receive_flag VARCHAR2(1);
725: x_WF_process_exists BOOLEAN;
726: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
727: ssp_version VARCHAR2(30) := FND_PROFILE.value('POR_SSP_VERSION');
728: x_ssp_version_gt4 VARCHAR2(10) := 'Y';
729: x_wf_itemtype varchar2(6) := 'PORCPT';
730: x_revision_num number;
731: x_item_key_count number;
1144:
1145: x_revision_num number;
1146: x_org_id number;
1147:
1148: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
1149:
1150:
1151: BEGIN
1152:
1338:
1339: x_revision_num number;
1340:
1341:
1342: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
1343:
1344:
1345: BEGIN
1346:
1444: x_po_header_ID NUMBER;
1445: x_exp_receipt_date DATE;
1446: x_Rcv_Order_URL VARCHAR2(1000);
1447: x_org_id NUMBER;
1448: l_base_href VARCHAR(2000) := fnd_profile.value('APPS_FRAMEWORK_AGENT');
1449:
1450: BEGIN
1451:
1452: IF ( funmode = 'RUN' ) THEN
1519: x_so_header_ID NUMBER;
1520: x_exp_receipt_date DATE;
1521: x_Rcv_Order_URL VARCHAR2(1000);
1522: x_org_id NUMBER;
1523: l_base_href VARCHAR(2000) := fnd_profile.value('APPS_FRAMEWORK_AGENT');
1524:
1525: BEGIN
1526:
1527: IF ( funmode = 'RUN' ) THEN
1632: and fr.start_date < sysdate
1633: and nvl(fr.end_date, sysdate +1) >= sysdate
1634: and fur.start_date < sysdate
1635: and nvl(fur.end_date, sysdate +1) >= Sysdate
1636: AND nvl(fnd_profile.value_specific('ORG_ID', NULL,
1637: fr.responsibility_id, fur.responsibility_application_id),-1) = nvl(x_org_id,-1)
1638: and nvl(fsp.org_id,-1) = nvl(x_org_id,-1)
1639: and nvl(fsp.business_group_id,-1) =
1640: nvl(fnd_profile.value_specific('PER_BUSINESS_GROUP_ID', NULL,
1636: AND nvl(fnd_profile.value_specific('ORG_ID', NULL,
1637: fr.responsibility_id, fur.responsibility_application_id),-1) = nvl(x_org_id,-1)
1638: and nvl(fsp.org_id,-1) = nvl(x_org_id,-1)
1639: and nvl(fsp.business_group_id,-1) =
1640: nvl(fnd_profile.value_specific('PER_BUSINESS_GROUP_ID', NULL,
1641: fr.responsibility_id, fur.responsibility_application_id),-1);
1642: EXCEPTION
1643: when others then
1644: x_resp_id := -1;
1657: and fr.start_date < sysdate
1658: and nvl(fr.end_date, sysdate +1) >= sysdate
1659: and fur.start_date < sysdate
1660: and nvl(fur.end_date, sysdate +1) >= Sysdate
1661: AND nvl(fnd_profile.value_specific('ORG_ID', NULL,
1662: fr.responsibility_id, fur.responsibility_application_id),-1) = nvl(x_org_id,-1)
1663: and nvl(fsp.org_id,-1) = nvl(x_org_id,-1)
1664: and nvl(fsp.business_group_id,-1) =
1665: nvl(fnd_profile.value_specific('PER_BUSINESS_GROUP_ID', NULL,
1661: AND nvl(fnd_profile.value_specific('ORG_ID', NULL,
1662: fr.responsibility_id, fur.responsibility_application_id),-1) = nvl(x_org_id,-1)
1663: and nvl(fsp.org_id,-1) = nvl(x_org_id,-1)
1664: and nvl(fsp.business_group_id,-1) =
1665: nvl(fnd_profile.value_specific('PER_BUSINESS_GROUP_ID', NULL,
1666: fr.responsibility_id, fur.responsibility_application_id),-1);
1667: EXCEPTION
1668: when others then
1669: x_resp_id := -1;
1684: fr.start_date < sysdate and
1685: nvl(fr.end_date, sysdate +1) >= sysdate and
1686: fur.start_date < sysdate and
1687: nvl(fur.end_date, sysdate +1) >= Sysdate AND
1688: nvl(fnd_profile.value_specific('ORG_ID', NULL, fr.responsibility_id,
1689: fur.responsibility_application_id),-1) = nvl(x_org_id,-1) and
1690: nvl(fsp.org_id,-1) = nvl(x_org_id,-1) and
1691: nvl(fsp.business_group_id,-1) =
1692: nvl(fnd_profile.value_specific('PER_BUSINESS_GROUP_ID', NULL,
1688: nvl(fnd_profile.value_specific('ORG_ID', NULL, fr.responsibility_id,
1689: fur.responsibility_application_id),-1) = nvl(x_org_id,-1) and
1690: nvl(fsp.org_id,-1) = nvl(x_org_id,-1) and
1691: nvl(fsp.business_group_id,-1) =
1692: nvl(fnd_profile.value_specific('PER_BUSINESS_GROUP_ID', NULL,
1693: fr.responsibility_id, fur.responsibility_application_id),-1);
1694: EXCEPTION
1695: WHEN OTHERS THEN
1696: x_resp_appl_id := -1;
1750: x_rcv_trans_status VARCHAR2(500) := NULL;
1751: X_tmp_count NUMBER;
1752: X_tmp_count1 NUMBER;
1753: X_tmp_approve VARCHAR2(20);
1754: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
1755: x_insert_txns_status NUMBER;
1756:
1757: t_po_header_id rcvNumberArray;
1758: t_line_location_id rcvNumberArray;
1794: aname => 'REQUESTER_USERNAME');
1795: initialize(x_requester_username,x_org_id);
1796:
1797: /** rewrite after initialize **/
1798: x_allow_inv_dest_receipts := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
1799:
1800: x_requester_id := wf_engine.GetItemAttrNumber( itemtype => itemtype,
1801: itemkey => itemkey,
1802: aname => 'REQUESTER_ID');
2263: x_WF_ItemKey VARCHAR2(100);
2264: x_WF_ItemKey_save VARCHAR2(100);
2265: x_auto_receive_flag VARCHAR2(1);
2266: x_WF_process_exists BOOLEAN;
2267: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
2268:
2269: x_wf_itemtype varchar2(6) := 'PORCPT';
2270: x_revision_num number;
2271:
2416: x_count NUMBER := 0;
2417: x_org_id NUMBER;
2418: x_requester_id NUMBER;
2419: x_exp_receipt_date DATE;
2420: x_allow_inv_dest_receipts varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
2421: x_is_int_req VARCHAR2(1);
2422: x_so_header_id NUMBER;
2423: x_po_header_id NUMBER;
2424: x_progress VARCHAR2(1000):= '001';
2626: x_header_ID NUMBER;
2627: x_exp_receipt_date DATE;
2628: x_Rcv_Order_URL VARCHAR2(1000);
2629: x_org_id NUMBER;
2630: l_base_href VARCHAR(2000) := fnd_profile.value('APPS_FRAMEWORK_AGENT');
2631:
2632: BEGIN
2633:
2634: IF ( funmode = 'RUN' ) THEN
2823: x_rcv_trans_status VARCHAR2(500) := NULL;
2824: X_tmp_count NUMBER;
2825: X_tmp_count1 NUMBER;
2826: X_tmp_approve VARCHAR2(20);
2827: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
2828:
2829: x_inserted_txn_status NUMBER;
2830: x_org_id NUMBER;
2831:
2864:
2865: PORCPTWF.initialize(x_requester_username,x_org_id);
2866:
2867: /** rewrite after initialize **/
2868: x_allow_inv_dest_receipts := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
2869:
2870:
2871: x_requester_id := wf_engine.GetItemAttrNumber( itemtype => itemtype,
2872: itemkey => itemkey,
3105: x_confirm_rcpt_inst VARCHAR2(2000);
3106: x_is_int_req VARCHAR2(1);
3107:
3108: nl VARCHAR2(1) := fnd_global.newline;
3109: l_base_href VARCHAR(2000) := fnd_profile.value('APPS_FRAMEWORK_AGENT');
3110: BEGIN
3111:
3112: x_is_int_req := wf_engine.GetItemAttrText( itemtype => x_item_type,
3113: itemkey => x_item_key,
3227: i NUMBER:=0;
3228: l_rcpt_record rcpt_record ;
3229: x_req_number VARCHAR2(20);
3230:
3231: x_allow_inv_dest_receipts varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
3232: NL VARCHAR2(1) := fnd_global.newline;
3233:
3234: BEGIN
3235:
3416:
3417: type select_line_info_Cursor is ref cursor ;
3418: Porcpt_LineInfo select_line_info_Cursor;
3419:
3420: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
3421:
3422: NL VARCHAR2(1) := fnd_global.newline;
3423: l_base_href VARCHAR(2000) := fnd_profile.value('APPS_FRAMEWORK_AGENT');
3424:
3419:
3420: x_allow_inv_dest_receipts Varchar2(20) := FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
3421:
3422: NL VARCHAR2(1) := fnd_global.newline;
3423: l_base_href VARCHAR(2000) := fnd_profile.value('APPS_FRAMEWORK_AGENT');
3424:
3425:
3426: BEGIN
3427:
3598: itemkey in varchar2,
3599: skip_distribution_updation in varchar2 default 'N') Return number
3600: IS
3601: x_allow_inv_dest_receipts Varchar2(20) :=
3602: FND_PROFILE.value('POR_ALLOW_INV_DEST_RECEIPTS');
3603: x_po_header_id NUMBER;
3604: x_org_id NUMBER;
3605: x_requester_id NUMBER;
3606: x_exp_receipt_date DATE;