300: p_whse_code IN VARCHAR2
301: )
302: IS
303: SELECT to_number(a.org_information2) legal_entity_id
304: FROM hr_organization_information a, ic_whse_mst b
305: WHERE a.organization_id = decode(nvl(b.subinventory_ind_flag, 'N'), 'Y', b.organization_id, b.mtl_organization_id)
306: AND b.whse_code = p_whse_code
307: AND a.org_information_context = 'Accounting Information';
308:
1686: )
1687: IS
1688: select a.co_code
1689: from sy_orgn_mst a,
1690: ic_whse_mst b
1691: where a.orgn_code = b.orgn_code
1692: and b.whse_code = p_whse_code;
1693:
1694: BEGIN
3283: cm_mthd_mst h,
3284: gl_plcy_mst i,
3285: sy_orgn_mst j,
3286: cm_cmpt_dtl k,
3287: ic_whse_mst l
3288: WHERE g.co_code IS NOT NULL
3289: AND l.whse_code = k.whse_code
3290: AND j.orgn_code = l.orgn_code
3291: AND i.co_code = j.co_code
3381: cm_mthd_mst h,
3382: gl_plcy_mst i,
3383: sy_orgn_mst j,
3384: cm_adjs_dtl k,
3385: ic_whse_mst l
3386: WHERE g.co_code IS NOT NULL
3387: AND l.whse_code = k.whse_code
3388: AND j.orgn_code = l.orgn_code
3389: AND i.co_code = j.co_code
3744: FROM (
3745: SELECT a.item_id,
3746: nvl(DECODE(NVL(c.subinventory_ind_flag,'N'), 'Y', c.organization_id, c.mtl_organization_id), DECODE(NVL(b.subinventory_ind_flag,'N'), 'Y', b.organization_id, b.mtl_organization_id)) organization_id
3747: FROM gmf_burden_percentages a,
3748: ic_whse_mst b,
3749: ic_whse_mst c
3750: WHERE a.item_id IS NOT NULL
3751: AND b.orgn_code = a.orgn_code
3752: AND c.whse_code(+) = a.whse_code
3745: SELECT a.item_id,
3746: nvl(DECODE(NVL(c.subinventory_ind_flag,'N'), 'Y', c.organization_id, c.mtl_organization_id), DECODE(NVL(b.subinventory_ind_flag,'N'), 'Y', b.organization_id, b.mtl_organization_id)) organization_id
3747: FROM gmf_burden_percentages a,
3748: ic_whse_mst b,
3749: ic_whse_mst c
3750: WHERE a.item_id IS NOT NULL
3751: AND b.orgn_code = a.orgn_code
3752: AND c.whse_code(+) = a.whse_code
3753: );
3846: a.gl_category_id,
3847: a.cost_category_id,
3848: a.gl_prod_line_category_id
3849: FROM gmf_burden_percentages a,
3850: ic_whse_mst e
3851: WHERE a.orgn_code IS NOT NULL
3852: AND a.whse_code IS NULL
3853: AND a.orgn_code = e.orgn_code
3854: AND e.mtl_organization_id IS NOT NULL
3898: )
3899: = (
3900: SELECT DECODE(a.whse_code, null, DECODE(NVL(Y.INVENTORY_ORG_IND,'N'), 'Y', y.organization_id, NULL), DECODE(NVL(x.subinventory_ind_flag,'N'), 'Y', x.organization_id, x.mtl_organization_id)),
3901: DECODE(a.delete_mark, 1, a.delete_mark, DECODE(a.whse_code, null, DECODE(NVL(Y.INVENTORY_ORG_IND,'N'), 'Y', 0, 1), DECODE(NVL(x.subinventory_ind_flag,'N'), 'Y', 1, 0)))
3902: FROM ic_whse_mst x, sy_orgn_mst y
3903: WHERE x.whse_code = nvl(a.whse_code, x.whse_code)
3904: and y.orgn_code = DECODE(a.whse_code, NULL, a.orgn_code, x.orgn_code)
3905: AND ROWNUM = 1
3906: )
4216: )
4217: = (
4218: SELECT decode(x.cost_organization_id, -1, -1, y.organization_id),
4219: y.inventory_item_id
4220: FROM ic_whse_mst x,
4221: ic_item_mst_b_mig y
4222: WHERE x.whse_code = a.whse_code
4223: AND y.item_id = a.item_id
4224: AND y.organization_id = NVL(DECODE(x.cost_organization_id, -1, x.mtl_organization_id, x.cost_organization_id), x.mtl_organization_id)
4971: )
4972: = (
4973: SELECT decode(x.cost_organization_id, -1, -1, y.organization_id),
4974: y.inventory_item_id
4975: FROM ic_whse_mst x,
4976: ic_item_mst_b_mig y
4977: WHERE x.whse_code = a.whse_code
4978: AND y.item_id = a.item_id
4979: AND y.organization_id = NVL(DECODE(x.cost_organization_id, -1, x.mtl_organization_id, x.cost_organization_id), x.mtl_organization_id)
5599: )
5600: = (
5601: SELECT decode(x.cost_organization_id, -1, -1, y.organization_id),
5602: y.inventory_item_id
5603: FROM ic_whse_mst x,
5604: ic_item_mst_b_mig y
5605: WHERE x.whse_code = a.whse_code
5606: AND y.item_id = a.item_id
5607: AND y.organization_id = NVL(DECODE(x.cost_organization_id, -1, x.mtl_organization_id, x.cost_organization_id), x.mtl_organization_id)
5940: FROM (
5941: SELECT a.item_id,
5942: DECODE(NVL(b.subinventory_ind_flag,'N'), 'Y', b.organization_id, b.mtl_organization_id) organization_id
5943: FROM gl_aloc_bas a,
5944: ic_whse_mst b
5945: WHERE a.item_id IS NOT NULL
5946: AND b.whse_code = a.whse_code
5947: );
5948:
6011: )
6012: = (
6013: SELECT y.organization_id,
6014: y.inventory_item_id
6015: FROM ic_whse_mst x,
6016: ic_item_mst_b_mig y
6017: WHERE x.whse_code = a.whse_code
6018: AND y.item_id = a.item_id
6019: AND y.organization_id = DECODE(NVL(x.subinventory_ind_flag, 'N'), 'Y', x.organization_id, x.mtl_organization_id)
6452: TYPE t_ar_trx_type_id IS TABLE OF GL_ACCT_MAP.AR_TRX_TYPE_ID%TYPE INDEX BY BINARY_INTEGER;
6453: TYPE t_rowid IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
6454: TYPE t_inventory_org_ind IS TABLE OF SY_ORGN_MST.INVENTORY_ORG_IND%TYPE INDEX BY BINARY_INTEGER;
6455: TYPE t_organization_id IS TABLE OF SY_ORGN_MST.ORGANIZATION_ID%TYPE INDEX BY BINARY_INTEGER;
6456: TYPE t_mtl_organization_id IS TABLE OF IC_WHSE_MST.MTL_ORGANIZATION_ID%TYPE INDEX BY BINARY_INTEGER;
6457: TYPE t_subinventory_ind_flag IS TABLE OF IC_WHSE_MST.SUBINVENTORY_IND_FLAG%TYPE INDEX BY BINARY_INTEGER;
6458: TYPE t_acct_no IS TABLE OF GL_ACCT_MST.ACCT_NO%TYPE INDEX BY BINARY_INTEGER;
6459: TYPE t_source_type IS TABLE OF GL_ACCT_MAP.SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
6460:
6453: TYPE t_rowid IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
6454: TYPE t_inventory_org_ind IS TABLE OF SY_ORGN_MST.INVENTORY_ORG_IND%TYPE INDEX BY BINARY_INTEGER;
6455: TYPE t_organization_id IS TABLE OF SY_ORGN_MST.ORGANIZATION_ID%TYPE INDEX BY BINARY_INTEGER;
6456: TYPE t_mtl_organization_id IS TABLE OF IC_WHSE_MST.MTL_ORGANIZATION_ID%TYPE INDEX BY BINARY_INTEGER;
6457: TYPE t_subinventory_ind_flag IS TABLE OF IC_WHSE_MST.SUBINVENTORY_IND_FLAG%TYPE INDEX BY BINARY_INTEGER;
6458: TYPE t_acct_no IS TABLE OF GL_ACCT_MST.ACCT_NO%TYPE INDEX BY BINARY_INTEGER;
6459: TYPE t_source_type IS TABLE OF GL_ACCT_MAP.SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
6460:
6461: /******************
6646: a.accu_map_id
6647: FROM gl_accu_map a,
6648: gl_accu_mst b,
6649: sy_orgn_mst c,
6650: ic_whse_mst d
6651: WHERE a.co_code = p_co_code
6652: AND b.acctg_unit_id = a.acctg_unit_id
6653: AND c.orgn_code(+) = a.orgn_code
6654: AND d.whse_code(+) = a.whse_code
6667: SELECT a.whse_code,
6668: a.whse_name,
6669: NVL(a.subinventory_ind_flag,'N') subinventory_ind_flag,
6670: a.mtl_organization_id
6671: FROM ic_whse_mst a
6672: WHERE a.orgn_code = p_orgn_code
6673: AND NOT EXISTS
6674: (
6675: SELECT 'X'
6691: SELECT a.whse_code,
6692: a.whse_name,
6693: NVL(a.subinventory_ind_flag,'N') subinventory_ind_flag,
6694: a.mtl_organization_id
6695: FROM ic_whse_mst a
6696: WHERE a.orgn_code = p_orgn_code
6697: AND NOT EXISTS
6698: (
6699: SELECT 'X'
7707: EXECUTE IMMEDIATE X_sqlcolumns ||
7708: ' FROM gl_acct_map a,
7709: gl_acct_mst b,
7710: sy_orgn_mst c,
7711: ic_whse_mst d '
7712: ||
7713: X_sqlwhere
7714: ||
7715: X_sqlordby
8894: ic_cldr_dtl b,
8895: ic_cldr_dtl c,
8896: org_acct_periods d,
8897: hr_organization_information hoi,
8898: ic_whse_mst e,
8899: gl_ledgers f
8900: WHERE a.orgn_code = b.orgn_code
8901: AND c.orgn_code = a.orgn_code
8902: AND e.orgn_code = a.orgn_code
9625: SELECT a.item_id,
9626: decode(NVL(c.subinventory_ind_flag,'N'), 'Y', c.organization_id, c.mtl_organization_id) organization_id
9627: FROM cm_cmpt_mtl a,
9628: sy_orgn_mst b,
9629: ic_whse_mst c
9630: WHERE a.item_id IS NOT NULL
9631: AND a.co_code = b.co_code
9632: AND b.orgn_code = c.orgn_code
9633: AND nvl(c.subinventory_ind_flag, 'N') <> 'Y'
10402: AND w.co_code = z.co_code
10403: ),
10404: a.source_organization_id = (
10405: SELECT DECODE(NVL(subinventory_ind_flag,'N'), 'Y', organization_id, mtl_organization_id)
10406: FROM ic_whse_mst w1
10407: WHERE w1.whse_code = a.whse_code
10408: )
10409: WHERE (a.legal_entity_id IS NULL AND a.orgn_code IS NOT NULL)
10410: OR (a.organization_id IS NULL AND a.orgn_code IS NOT NULL)
10479: a.source_organization_id,
10480: a.master_organization_id,
10481: a.legal_entity_id
10482: FROM cm_whse_src a,
10483: ic_whse_mst e
10484: WHERE NOT EXISTS (
10485: SELECT 'X'
10486: FROM cm_whse_src x
10487: WHERE x.legal_entity_id = a.legal_entity_id
10605: (
10606: SELECT a.item_id,
10607: NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10608: FROM cm_acst_led a,
10609: ic_whse_mst b
10610: WHERE a.item_id IS NOT NULL
10611: AND a.whse_code = b.whse_code
10612: UNION
10613: SELECT a.item_id,
10612: UNION
10613: SELECT a.item_id,
10614: NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10615: FROM cm_adjs_dtl a,
10616: ic_whse_mst b
10617: WHERE a.item_id IS NOT NULL
10618: AND a.whse_code = b.whse_code
10619: UNION
10620: SELECT a.item_id,
10619: UNION
10620: SELECT a.item_id,
10621: NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10622: FROM cm_brdn_dtl a,
10623: ic_whse_mst b
10624: WHERE a.item_id IS NOT NULL
10625: AND a.whse_code = b.whse_code
10626: UNION
10627: SELECT a.item_id,
10626: UNION
10627: SELECT a.item_id,
10628: NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10629: FROM cm_cmpt_dtl a,
10630: ic_whse_mst b
10631: WHERE a.item_id IS NOT NULL
10632: AND a.whse_code = b.whse_code
10633: UNION
10634: SELECT a.item_id,
10633: UNION
10634: SELECT a.item_id,
10635: NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10636: FROM cm_scst_led a,
10637: ic_whse_mst b
10638: WHERE a.item_id IS NOT NULL
10639: AND a.whse_code = b.whse_code
10640: UNION
10641: SELECT a.item_id,
10640: UNION
10641: SELECT a.item_id,
10642: nvl(DECODE(NVL(c.subinventory_ind_flag,'N'), 'Y', c.organization_id, c.mtl_organization_id), DECODE(NVL(b.subinventory_ind_flag,'N'), 'Y', b.organization_id, b.mtl_organization_id)) organization_id
10643: FROM cm_whse_src a,
10644: ic_whse_mst b,
10645: ic_whse_mst c
10646: WHERE a.item_id IS NOT NULL
10647: AND b.orgn_code = a.orgn_code
10648: AND c.whse_code(+) = a.whse_code
10641: SELECT a.item_id,
10642: nvl(DECODE(NVL(c.subinventory_ind_flag,'N'), 'Y', c.organization_id, c.mtl_organization_id), DECODE(NVL(b.subinventory_ind_flag,'N'), 'Y', b.organization_id, b.mtl_organization_id)) organization_id
10643: FROM cm_whse_src a,
10644: ic_whse_mst b,
10645: ic_whse_mst c
10646: WHERE a.item_id IS NOT NULL
10647: AND b.orgn_code = a.orgn_code
10648: AND c.whse_code(+) = a.whse_code
10649: UNION
10649: UNION
10650: SELECT a.item_id,
10651: NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10652: FROM gl_item_cst a,
10653: ic_whse_mst b
10654: WHERE a.item_id IS NOT NULL
10655: AND a.whse_code = b.whse_code
10656: UNION
10657: SELECT a.item_id,
10657: SELECT a.item_id,
10658: DECODE(NVL(c.subinventory_ind_flag,'N'), 'Y', c.organization_id, c.mtl_organization_id) organization_id
10659: FROM gmf_lot_costed_items a,
10660: sy_orgn_mst b,
10661: ic_whse_mst c
10662: WHERE a.item_id IS NOT NULL
10663: AND a.co_code = b.co_Code
10664: AND b.orgn_code = c.orgn_code
10665: AND nvl(c.subinventory_ind_flag,'N') <> 'Y'
10666: UNION
10667: SELECT a.item_id,
10668: NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10669: FROM gmf_lot_Costs a,
10670: ic_whse_mst b
10671: WHERE a.item_id IS NOT NULL
10672: AND a.whse_code = b.whse_code
10673: UNION
10674: SELECT a.item_id,
10673: UNION
10674: SELECT a.item_id,
10675: NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10676: FROM gmf_lot_Cost_adjustments a,
10677: ic_whse_mst b
10678: WHERE a.item_id IS NOT NULL
10679: AND a.whse_code = b.whse_code
10680: UNION
10681: SELECT a.item_id,
10680: UNION
10681: SELECT a.item_id,
10682: NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10683: FROM gmf_lot_Cost_burdens a,
10684: ic_whse_mst b
10685: WHERE a.item_id IS NOT NULL
10686: AND a.whse_code = b.whse_code
10687: ) x
10688: WHERE NOT EXISTS
11776:
11777: /**********
11778: * Cursors *
11779: **********/
11780: CURSOR cur_ic_whse_mst
11781: IS
11782: SELECT a.whse_code,
11783: NVL(a.subinventory_ind_flag, 'N') subinventory_ind_flag,
11784: a.mtl_organization_id,
11791: DECODE(COUNT(d.cost_whse_code), 0, 'N', 'Y') cost_warehouse,
11792: DECODE(COUNT(f.cost_whse_code), 0, 'N', 'Y') same_plant_cost_warehouse,
11793: DECODE(SUM(DECODE(f.cost_whse_code, NULL, 0, DECODE(NVL(c.subinventory_ind_flag, 'N'), 'N', 0, 1))), 0, 'N', 'Y') cost_whse_is_subinv,
11794: DECODE(COUNT(e.whse_code), 0, 'N', 'Y') inv_warehouse
11795: FROM ic_whse_mst a,
11796: sy_orgn_mst b,
11797: ic_whse_mst c,
11798: cm_whse_asc d,
11799: cm_whse_asc e,
11793: DECODE(SUM(DECODE(f.cost_whse_code, NULL, 0, DECODE(NVL(c.subinventory_ind_flag, 'N'), 'N', 0, 1))), 0, 'N', 'Y') cost_whse_is_subinv,
11794: DECODE(COUNT(e.whse_code), 0, 'N', 'Y') inv_warehouse
11795: FROM ic_whse_mst a,
11796: sy_orgn_mst b,
11797: ic_whse_mst c,
11798: cm_whse_asc d,
11799: cm_whse_asc e,
11800: cm_whse_asc f
11801: WHERE a.orgn_code = b.orgn_code
11837: p_app_short_name => 'GMA'
11838: );
11839:
11840: /***********************************************************************************
11841: * Migrate warehouse records in IC_WHSE_MST to facilitate Cost Warehouse Derivation *
11842: ***********************************************************************************/
11843: FOR i IN cur_ic_whse_mst LOOP
11844: IF nvl(i.subinventory_ind_flag, 'N') <> 'Y' THEN /* Migrated as Inventory Organization */
11845: l_costing_organization_id := i.mtl_organization_id;
11839:
11840: /***********************************************************************************
11841: * Migrate warehouse records in IC_WHSE_MST to facilitate Cost Warehouse Derivation *
11842: ***********************************************************************************/
11843: FOR i IN cur_ic_whse_mst LOOP
11844: IF nvl(i.subinventory_ind_flag, 'N') <> 'Y' THEN /* Migrated as Inventory Organization */
11845: l_costing_organization_id := i.mtl_organization_id;
11846: ELSE /* Migrated as Sub-Inventory */
11847: IF nvl(i.Subinventory_count,0) = 1 THEN /* Only Warehouse under the plant Migrated as Sub-Inventory */
11866: END IF;
11867: END IF;
11868: END IF;
11869:
11870: UPDATE ic_whse_mst a
11871: SET a.cost_organization_id = l_costing_organization_id
11872: WHERE a.whse_code = i.whse_code;
11873: END LOOP;
11874:
11877: a.organization_id
11878: )
11879: = (
11880: SELECT x.cost_organization_id
11881: FROM ic_whse_mst x
11882: WHERE x.whse_code = a.whse_code
11883: ),
11884: (
11885: a.cost_organization_id
11885: a.cost_organization_id
11886: )
11887: = (
11888: SELECT x.cost_organization_id
11889: FROM ic_whse_mst x
11890: WHERE x.whse_code = a.cost_whse_code
11891: );
11892:
11893: UPDATE cm_whse_asc a