90: p_sub_comp => l_sub_comp,
91: p_filename_val => NULL,
92: x_Return_Status => l_Return_Status
93: );
94: IF (l_Return_Status <> FND_API.G_RET_STS_SUCCESS) THEN
95: fnd_file.put_line(fnd_file.log,'g_exc_error');
96: raise FND_API.G_EXC_ERROR;
97: END IF;
98:
92: x_Return_Status => l_Return_Status
93: );
94: IF (l_Return_Status <> FND_API.G_RET_STS_SUCCESS) THEN
95: fnd_file.put_line(fnd_file.log,'g_exc_error');
96: raise FND_API.G_EXC_ERROR;
97: END IF;
98:
99: RETURN;
100:
102: -- Exception handler section for the Put_Debug_Msg procedure.
103: -- --------------------------------------------------------------------
104: EXCEPTION
105:
106: WHEN FND_API.G_EXC_ERROR THEN
107: RETURN;
108:
109: WHEN OTHERS THEN
110: IF (FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)) THEN
128: -- p_document_id Id of document
129: --
130: -- OUT Parameters
131: -- --------------
132: -- Returns Fnd_Api.G_True for success, otherwise G_False
133: --
134: FUNCTION Lock_Documents(p_document_type IN VARCHAR2,
135: p_document_id IN NUMBER
136: ) RETURN VARCHAR2 AS
284: END LOOP;
285: END IF; -- p_document_type = 'PO'
286:
287: IF l_exception = FALSE THEN
288: RETURN FND_API.G_RET_STS_SUCCESS;
289: ELSE
290: RETURN FND_API.G_RET_STS_ERROR;
291: END IF;
292:
286:
287: IF l_exception = FALSE THEN
288: RETURN FND_API.G_RET_STS_SUCCESS;
289: ELSE
290: RETURN FND_API.G_RET_STS_ERROR;
291: END IF;
292:
293:
294: EXCEPTION
763: -- l_con_enc_type_id NUMBER := 0 ;
764: -- l_prv_enc_flag VARCHAR2(1) := 'N' ;
765: -- l_con_enc_flag VARCHAR2(1) := 'N' ;
766: l_sql_string VARCHAR2(100) := null ;
767: l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
768: l_msg_count NUMBER := 0 ;
769: l_msg_data VARCHAR2(2000) := null ;
770: l_err_code VARCHAR2(100) := null ;
771:
793: ,x_msg_data => l_msg_data
794: ,x_cbc_enabled => l_cbc_enabled
795: ) ;
796:
797: IF l_return_status <> FND_API.G_RET_STS_SUCCESS
798: THEN
799: -- if update unsuccessful report errors
800: l_msg_data := '';
801: For j in 1..NVL(l_msg_count,0) LOOP
1588:
1589: c_valid_dist c_valid_dist_type;
1590:
1591: l_msg_data VARCHAR2(2000) := null ;
1592: l_return_status VARCHAR2(1):= FND_API.G_RET_STS_SUCCESS;
1593:
1594: l_full_path VARCHAR2(500) := g_path||'Validate_Distributions';
1595: BEGIN
1596:
1658: ELSE
1659: IF (g_debug_mode = 'Y') THEN
1660: Put_Debug_Msg (l_full_path,p_debug_msg => 'No distributions for this document type');
1661: END IF;
1662: RETURN FND_API.G_RET_STS_SUCCESS;
1663: END IF; -- p_document_type = 'PO' and p_document_subtype = 'STANDARD'
1664:
1665: -- fetch distributions in batches determined by user parameter
1666: LOOP
1705: p_line_id => l_valid_dist_rec.line_id(l_index),
1706: p_line_location_id => l_valid_dist_rec.line_location_id(l_index),
1707: p_distribution_id => l_valid_dist_rec.distribution_id(l_index)
1708: );
1709: l_return_status := FND_API.G_RET_STS_ERROR;
1710: ELSE
1711: EXIT;
1712: END IF; -- result_error_code(l_index) IS NOT NULL
1713: END LOOP;
3192: TYPE c_prev_val_type IS REF CURSOR ;
3193:
3194: c_prev_val c_prev_val_type ;
3195:
3196: l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
3197: l_msg_count NUMBER := 0;
3198: l_msg_data VARCHAR2(2000) := null ;
3199: l_info_request VARCHAR2(25) := null ;
3200: l_document_status VARCHAR2(240) := null ;
3285: p_document_type => p_document_type,
3286: p_document_sub_type => p_document_subtype,
3287: p_cbc_acct_date => p_prev_year_end_date,
3288: p_api_version => 1,
3289: p_init_msg_list => FND_API.G_FALSE,
3290: p_commit => FND_API.G_FALSE,
3291: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3292: x_return_status => l_return_status,
3293: x_msg_count => l_msg_count,
3286: p_document_sub_type => p_document_subtype,
3287: p_cbc_acct_date => p_prev_year_end_date,
3288: p_api_version => 1,
3289: p_init_msg_list => FND_API.G_FALSE,
3290: p_commit => FND_API.G_FALSE,
3291: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3292: x_return_status => l_return_status,
3293: x_msg_count => l_msg_count,
3294: x_msg_data => l_msg_data
3287: p_cbc_acct_date => p_prev_year_end_date,
3288: p_api_version => 1,
3289: p_init_msg_list => FND_API.G_FALSE,
3290: p_commit => FND_API.G_FALSE,
3291: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3292: x_return_status => l_return_status,
3293: x_msg_count => l_msg_count,
3294: x_msg_data => l_msg_data
3295: );
3297: Put_Debug_Msg (l_full_path,p_debug_msg => 'Completed Update CBC Acct Date');
3298: END IF;
3299:
3300: -- if update unsuccessful then report errors and terminate processing with errors.
3301: IF l_return_status <> FND_API.G_RET_STS_SUCCESS
3302: THEN
3303: l_msg_data := '';
3304: For j in 1..NVL(l_msg_count,0) LOOP
3305: l_msg_data := FND_MSG_PUB.Get(p_msg_index => j,
3312: FND_MESSAGE.set_name('IGC','IGC_PO_YEP_ACCT_DATE_UPD_ERR');
3313: x_msg_buf := FND_MESSAGE.get ;
3314: RETURN;
3315: END LOOP;
3316: END IF; -- l_return_status <> fnd_api.g_ret_sts_success
3317:
3318: -- set document_type for use in PO funds checker
3319: IF p_document_type = 'REQ'
3320: THEN
3397: p_document_type => p_document_type,
3398: p_document_sub_type => p_document_subtype,
3399: p_cbc_acct_date => p_prev_cbc_acct_date,
3400: p_api_version => 1,
3401: p_init_msg_list => FND_API.G_FALSE,
3402: p_commit => FND_API.G_FALSE,
3403: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3404: x_return_status => l_return_status,
3405: x_msg_count => l_msg_count,
3398: p_document_sub_type => p_document_subtype,
3399: p_cbc_acct_date => p_prev_cbc_acct_date,
3400: p_api_version => 1,
3401: p_init_msg_list => FND_API.G_FALSE,
3402: p_commit => FND_API.G_FALSE,
3403: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3404: x_return_status => l_return_status,
3405: x_msg_count => l_msg_count,
3406: x_msg_data => l_msg_data
3399: p_cbc_acct_date => p_prev_cbc_acct_date,
3400: p_api_version => 1,
3401: p_init_msg_list => FND_API.G_FALSE,
3402: p_commit => FND_API.G_FALSE,
3403: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3404: x_return_status => l_return_status,
3405: x_msg_count => l_msg_count,
3406: x_msg_data => l_msg_data
3407: );
3408:
3409: IF (g_debug_mode = 'Y') THEN
3410: Put_Debug_Msg (l_full_path,p_debug_msg => 'completed Update CBC Acct Date - Unreserve failure');
3411: END IF;
3412: IF l_return_status <> FND_API.G_RET_STS_SUCCESS
3413: THEN
3414: -- if update unsuccessful report errors
3415: l_msg_data := '';
3416: For j in 1..NVL(l_msg_count,0) LOOP
3420: p_exception_code => l_return_status,
3421: p_document_type => p_document_type,
3422: p_document_id => p_document_id);
3423: END LOOP;
3424: END IF; -- l_return_status <> fnd_api.g_ret_sts_success
3425:
3426: -- commit updates
3427: COMMIT ;
3428:
3442: -- here ourselves, so as not to invalidate the following lock.
3443: COMMIT;
3444: -- Lock the document and children
3445: IF Lock_Documents(p_document_type => p_document_type,
3446: p_document_id => p_document_id) <> FND_API.G_RET_STS_SUCCESS
3447: THEN
3448: -- if unable to relock doc report error and do not process this doc any further
3449: l_err_code := 'IGC_PO_YEP_RELOCK_DOCUMENT';
3450: FND_MESSAGE.set_name('IGC',l_err_code);
3524: p_document_type => p_document_type,
3525: p_document_sub_type => p_document_subtype,
3526: p_cbc_acct_date => p_curr_year_start_date,
3527: p_api_version => 1,
3528: p_init_msg_list => FND_API.G_FALSE,
3529: p_commit => FND_API.G_FALSE,
3530: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3531: x_return_status => l_return_status,
3532: x_msg_count => l_msg_count,
3525: p_document_sub_type => p_document_subtype,
3526: p_cbc_acct_date => p_curr_year_start_date,
3527: p_api_version => 1,
3528: p_init_msg_list => FND_API.G_FALSE,
3529: p_commit => FND_API.G_FALSE,
3530: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3531: x_return_status => l_return_status,
3532: x_msg_count => l_msg_count,
3533: x_msg_data => l_msg_data
3526: p_cbc_acct_date => p_curr_year_start_date,
3527: p_api_version => 1,
3528: p_init_msg_list => FND_API.G_FALSE,
3529: p_commit => FND_API.G_FALSE,
3530: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3531: x_return_status => l_return_status,
3532: x_msg_count => l_msg_count,
3533: x_msg_data => l_msg_data
3534: );
3535: IF (g_debug_mode = 'Y') THEN
3536: Put_Debug_Msg (l_full_path,p_debug_msg => 'completed Update CBC Acct Date - current year');
3537: END IF;
3538:
3539: IF l_return_status <> FND_API.G_RET_STS_SUCCESS
3540: THEN
3541: -- if update unsuccessful rollback the transaction, report errors and terminate processing with error
3542: Rollback ;
3543: l_msg_data := '';
3551: END LOOP;
3552: x_return_code := 2;
3553: FND_MESSAGE.set_name('IGC','IGC_PO_YEP_ACCT_DATE_UPD_ERR');
3554: x_msg_buf := FND_MESSAGE.get;
3555: END IF; -- l_return_status <> fnd_api.g_ret_sts_success
3556:
3557:
3558:
3559: -- we need to commit, as the PO funds checker is called as an autonomous transaction, so if we
3616:
3617: -- as the funds check will have released the locks on the document, we need to relock
3618: -- Lock the document and children
3619: IF Lock_Documents(p_document_type => p_document_type,
3620: p_document_id => p_document_id) <> FND_API.G_RET_STS_SUCCESS
3621: THEN
3622: -- if unable to relock doc report error and do not process this doc any further
3623: l_err_code := 'IGC_PO_YEP_RELOCK_DOCUMENT';
3624: FND_MESSAGE.set_name('IGC',l_err_code);
3638: p_document_type => p_document_type,
3639: p_document_sub_type => p_document_subtype,
3640: p_cbc_acct_date => p_prev_year_end_date,
3641: p_api_version => 1,
3642: p_init_msg_list => FND_API.G_FALSE,
3643: p_commit => FND_API.G_FALSE,
3644: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3645: x_return_status => l_return_status,
3646: x_msg_count => l_msg_count,
3639: p_document_sub_type => p_document_subtype,
3640: p_cbc_acct_date => p_prev_year_end_date,
3641: p_api_version => 1,
3642: p_init_msg_list => FND_API.G_FALSE,
3643: p_commit => FND_API.G_FALSE,
3644: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3645: x_return_status => l_return_status,
3646: x_msg_count => l_msg_count,
3647: x_msg_data => l_msg_data
3640: p_cbc_acct_date => p_prev_year_end_date,
3641: p_api_version => 1,
3642: p_init_msg_list => FND_API.G_FALSE,
3643: p_commit => FND_API.G_FALSE,
3644: p_validation_level => FND_API.G_VALID_LEVEL_FULL,
3645: x_return_status => l_return_status,
3646: x_msg_count => l_msg_count,
3647: x_msg_data => l_msg_data
3648: );
3649: IF (g_debug_mode = 'Y') THEN
3650: Put_Debug_Msg (l_full_path,p_debug_msg => 'completed Update CBC Acct Date - Reserve failure');
3651: END IF;
3652:
3653: IF l_return_status <> FND_API.G_RET_STS_SUCCESS
3654: THEN
3655: -- if update unsuccessful then report errors
3656: l_msg_data := '';
3657: For j in 1..NVL(l_msg_count,0) LOOP
3661: p_exception_code => l_return_status,
3662: p_document_type => p_document_type,
3663: p_document_id => p_document_id);
3664: END LOOP;
3665: END IF; -- l_return_status <> fnd_api.g_ret_stst_success
3666:
3667: -- As reserve funds has failed, reset the GL dates of all distributions related to the document
3668: IF p_document_type = 'REQ'
3669: THEN
3961: l_release c_get_releases%ROWTYPE ;
3962: l_po c_get_po_headers%ROWTYPE ;
3963: l_requisition c_get_requisitions%ROWTYPE ;
3964: l_bpa c_get_po_headers%ROWTYPE ;
3965: l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
3966: l_found_error VARCHAR2(1) ;
3967: l_found_future VARCHAR2(1) ;
3968: l_msg_data VARCHAR2(2000) := null ;
3969: l_err_code VARCHAR2(100) := null ;
3988: THEN
3989: SAVEPOINT savepoint_release ;
3990: -- Attempt to lock the entire document, i.e. header, shipments, distributions
3991: IF Lock_Documents(p_document_type => p_document_type,
3992: p_document_id => p_po_release_id) <> FND_API.G_RET_STS_SUCCESS
3993: THEN
3994: -- if unable to lock doc, then report error and do not process this doc any further
3995: l_err_code := 'IGC_PO_YEP_LOCK_DOCUMENT';
3996: FND_MESSAGE.set_name('IGC',l_err_code);
4071: IF (g_debug_mode = 'Y') THEN
4072: Put_Debug_Msg (l_full_path,p_debug_msg => 'completed Validate Distributions');
4073: END IF;
4074:
4075: IF l_return_status <> FND_API.G_RET_STS_SUCCESS
4076: THEN
4077: -- if not valid then do not process this document any further
4078: IF p_process_phase = 'F'
4079: THEN
4080: ROLLBACK TO savepoint_release;
4081: END IF;
4082: x_return_code := -99;
4083: RETURN ;
4084: END IF; -- l_return_status <> fnd_api.g_ret_sts_success
4085:
4086: -- if in Final Mode, process the document
4087: IF p_process_phase = 'F'
4088: THEN
4131: THEN
4132: SAVEPOINT savepoint_po ;
4133: --lock document incl child records
4134: IF Lock_Documents(p_document_type => p_document_type,
4135: p_document_id => p_po_header_id) <> FND_API.G_RET_STS_SUCCESS
4136: THEN
4137: -- if unable to lock doc then do not process this doc any further
4138: l_err_code := 'IGC_PO_YEP_LOCK_DOCUMENT';
4139: FND_MESSAGE.set_name('IGC',l_err_code);
4272: );
4273: IF (g_debug_mode = 'Y') THEN
4274: Put_Debug_Msg (l_full_path,p_debug_msg => 'completed Validate Distributions');
4275: END IF;
4276: IF l_return_status <> FND_API.G_RET_STS_SUCCESS
4277: THEN
4278: -- If distributions invalid report error and do not process this doc any further
4279: IF p_process_phase = 'F'
4280: THEN
4281: ROLLBACK TO savepoint_po ;
4282: END IF;
4283: x_return_code := -99;
4284: RETURN ;
4285: END IF; -- l_return_status <> fnd_api.g_ret_sts_success
4286:
4287: -- IF in Final Mode process the document
4288: IF p_process_phase = 'F'
4289: THEN
4333: THEN
4334: SAVEPOINT savepoint_requisition ;
4335: --lock document incl child records
4336: IF Lock_Documents(p_document_type => p_document_type,
4337: p_document_id => p_req_header_id) <> FND_API.G_RET_STS_SUCCESS
4338: THEN
4339: -- if unable to lock doc then report error and do not process this doc any further
4340: l_err_code := 'IGC_PO_YEP_LOCK_DOCUMENT';
4341: FND_MESSAGE.set_name('IGC',l_err_code);
4450: IF (g_debug_mode = 'Y') THEN
4451: Put_Debug_Msg (l_full_path,p_debug_msg => 'completed validate distributions');
4452: END IF;
4453:
4454: IF l_return_status <> FND_API.G_RET_STS_SUCCESS
4455: THEN
4456: -- If distributions invalid then report error and do not process this doc any further
4457: IF p_process_phase = 'F'
4458: THEN
4459: ROLLBACK TO savepoint_requisition ;
4460: END IF;
4461: x_return_code := -99;
4462: RETURN ;
4463: END IF; -- l_return_status <> fnd_api.g_ret_sts_success
4464:
4465:
4466: -- if in Final Mode then process the requisition
4467: IF p_process_phase = 'F'
4515: THEN
4516: SAVEPOINT savepoint_BPA ;
4517: --lock document incl child records
4518: IF Lock_Documents(p_document_type => p_document_type,
4519: p_document_id => p_po_header_id) <> FND_API.G_RET_STS_SUCCESS
4520: THEN
4521: -- if unable to lock doc then report error and do not process this doc any further
4522: l_err_code := 'IGC_PO_YEP_LOCK_DOCUMENT';
4523: FND_MESSAGE.set_name('IGC',l_err_code);