[Home] [Help]
1: PACKAGE BODY jai_cmn_rg_i_trxs_pkg AS
2: /* $Header: jai_cmn_rg_i.plb 120.3 2007/08/16 11:20:30 vkaranam ship $ */
3:
4: PROCEDURE validate_rg1_balances(
5: P_ORGANIZATION_ID IN NUMBER,
12: P_ERR_BUF OUT NOCOPY VARCHAR2
13: ) IS
14:
15: /* Added by Ramananda for bug#4407165 */
16: lv_object_name CONSTANT VARCHAR2(61) := 'jai_cmn_rg_i_trxs_pkg.validate_rg1_balances';
17:
18: v_primary_uom_code MTL_UNITS_OF_MEASURE.uom_code%TYPE;
19: v_transaction_uom_code MTL_UNITS_OF_MEASURE.uom_code%TYPE;
20: CURSOR c_item_primary_uom(p_organization_id NUMBER, p_inventory_item_id NUMBER) IS
42: This procedure is used to validate whether required amount of balances are available to issue the goods.
43: Populates P_ERR_BUF variable with proper message if balances are not sufficient to hit RG1 register
44:
45: - FUNCTION get_rg1_transaction_id
46: This function returns a UNIQUE NUMBER used to identify the RG1 transaction type in JAI_CMN_RG_I_TRXS table
47:
48: - PROCEDURE create_rg1_entry
49: This procedure takes in all the values that has to be populated into database columns.
50: Generates the sequence no, serial no for REGISTER_ID, SLNO columns. Calculates the quantity balance to
47:
48: - PROCEDURE create_rg1_entry
49: This procedure takes in all the values that has to be populated into database columns.
50: Generates the sequence no, serial no for REGISTER_ID, SLNO columns. Calculates the quantity balance to
51: be populated into BALANCE_LOOSE column of the table and finally inserts data into JAI_CMN_RG_I_TRXS table.
52:
53:
54:
55: Change History
108:
109: v_quantity := nvl(p_quantity, 0) * vTransToPrimaryUOMConv;
110:
111: SELECT max(slno) INTO vMaxSlno
112: FROM JAI_CMN_RG_I_TRXS
113: WHERE organization_id = p_organization_id
114: AND location_id = p_location_id
115: AND inventory_item_id = p_inventory_item_id
116: AND fin_year = p_fin_year;
116: AND fin_year = p_fin_year;
117:
118: IF vMaxSlno IS NOT NULL THEN
119: SELECT NVL(balance_packed,0), NVL(balance_loose,0) INTO vBalancePacked, vBalanceLoose
120: FROM JAI_CMN_RG_I_TRXS
121: WHERE organization_id = p_organization_id
122: and location_id = p_location_id
123: and inventory_item_id = p_inventory_item_id
124: AND fin_year = p_fin_year
154:
155: v_transaction_id NUMBER := -1;
156:
157: /* Added by Ramananda for bug#4407165 */
158: lv_object_name CONSTANT VARCHAR2(61) := 'jai_cmn_rg_i_trxs_pkg.get_rg1_transaction_id';
159:
160: BEGIN
161: IF p_called_from = 'MANUAL ENTRY' THEN
162: IF p_transaction_type = 'R' THEN
268: P_SH_CESS_AMOUNT IN NUMBER DEFAULT NULL/*Bug 5989740 bduvarag*/
269: ) IS
270:
271: /* Added by Ramananda for bug#4407165 */
272: lv_object_name CONSTANT VARCHAR2(61) := 'jai_cmn_rg_i_trxs_pkg.create_rg1_entry';
273:
274: vMaxSlno NUMBER;
275: v_transaction_id JAI_CMN_RG_I_TRXS.TRANSACTION_SOURCE_NUM%TYPE;
276: v_primary_uom_code MTL_UNITS_OF_MEASURE.uom_code%TYPE;
271: /* Added by Ramananda for bug#4407165 */
272: lv_object_name CONSTANT VARCHAR2(61) := 'jai_cmn_rg_i_trxs_pkg.create_rg1_entry';
273:
274: vMaxSlno NUMBER;
275: v_transaction_id JAI_CMN_RG_I_TRXS.TRANSACTION_SOURCE_NUM%TYPE;
276: v_primary_uom_code MTL_UNITS_OF_MEASURE.uom_code%TYPE;
277: v_transaction_uom_code MTL_UNITS_OF_MEASURE.uom_code%TYPE;
278: vTransToPrimaryUOMConv NUMBER;
279:
339:
340: v_quantity := nvl(p_quantity, 0) * vTransToPrimaryUOMConv;
341:
342: SELECT max(slno) INTO vMaxSlno
343: FROM JAI_CMN_RG_I_TRXS
344: WHERE organization_id = p_organization_id
345: AND location_id = p_location_id
346: AND inventory_item_id = p_inventory_item_id
347: AND fin_year = p_fin_year;
347: AND fin_year = p_fin_year;
348:
349: IF vMaxSlno IS NOT NULL THEN
350: SELECT NVL(balance_packed,0), NVL(balance_loose,0) INTO vBalancePacked, vBalanceLoose
351: FROM JAI_CMN_RG_I_TRXS
352: WHERE organization_id = p_organization_id
353: and location_id = p_location_id
354: and inventory_item_id = p_inventory_item_id
355: AND fin_year = p_fin_year
408: ELSE
409: P_SLNO := vMaxSlno + 1;
410: END IF;
411:
412: SELECT JAI_CMN_RG_I_TRXS_S.nextval INTO P_REGISTER_ID FROM DUAL;
413:
414: v_transaction_id := get_rg1_transaction_id(
415: p_transaction_type,
416: p_issue_type,
416: p_issue_type,
417: p_called_from
418: );
419:
420: INSERT INTO JAI_CMN_RG_I_TRXS(
421: REGISTER_ID,
422: REGISTER_ID_PART_II,
423: FIN_YEAR,
424: SLNO,
544: app_exception.raise_exception;
545:
546: END create_rg1_entry;
547:
548: END jai_cmn_rg_i_trxs_pkg;