IF l_msg <> 'E' AND retcode <> 2
THEN
fnd_file.put_line (fnd_file.LOG, 'Creating Batch Header : ');
BEGIN
pay_batch_element_entry_api.create_batch_header
(p_session_date => TRUNC (SYSDATE),
p_batch_name => l_batch_name,
p_business_group_id => fnd_profile.VALUE
('PER_BUSINESS_GROUP_ID'),
p_action_if_exists => 'I',
p_batch_id => l_batch_id,
p_object_version_number => l_object_version_number
);
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
retcode := 2;
fnd_file.put_line
(fnd_file.LOG,
'Error while creating Batch header.Please contact your support administrator. - '
|| SQLERRM
);
l_msg := 'E';
END;
END IF;
fnd_file.put_line (fnd_file.LOG,
'Location 2 l_msg : '
|| l_msg
|| ' Retcode '
|| retcode
);
fnd_file.put_line (fnd_file.LOG,
'Batch Header Created, Batch id : '
|| l_batch_id
|| ' OVN '
|| l_object_version_number
);
v_batch_id := l_batch_id;
v_object_version_number := l_object_version_number;
IF l_msg <> 'E' AND retcode <> 2
THEN
fnd_file.put_line (fnd_file.LOG, 'Creating Batch Lines: ');
BEGIN
FOR i IN
csr_get_ot_off_data
(p_sbu,
p_dept,
p_sect,
p_tk_group_id,
p_person_id,
TRUNC (fnd_date.canonical_to_date (p_start_date)),
TRUNC (fnd_date.canonical_to_date (p_end_date))
)
LOOP
fnd_file.put_line (fnd_file.LOG,
'Creating Batch For : '
|| i.assignment_number
);
l_count := l_count + 1;
BEGIN
pay_batch_element_entry_api.create_batch_line
(p_session_date => TRUNC (SYSDATE),
p_batch_id => v_batch_id,
p_assignment_id => i.assignment_id,
p_assignment_number => i.assignment_number,
p_date_earned => i.punch_date,
p_effective_date => i.punch_date,
p_effective_start_date => i.punch_date,
-- p_effective_end_date => v_eff_end_date,
p_element_name => v_csr_get_lement_details.element_name,
p_element_type_id => v_csr_get_lement_details.element_type_id,
p_value_1 => (i.total_hours),
p_batch_line_id => v_batch_line_id,
p_object_version_number => v_batch_object_version_number
);
EXCEPTION
WHEN OTHERS
THEN
retcode := 2;
fnd_file.put_line
(fnd_file.LOG,
'Error while creating Batch Line for Assignments.Please contact your support administrator. - '
|| i.assignment_number
|| ' '
|| SQLERRM
);
l_msg := 'E';
EXIT;
END;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
retcode := 2;
fnd_file.put_line
(fnd_file.LOG,
'Error while creating Batch Lines outer layout.Please contact your support administrator. - '
|| SQLERRM
);
l_msg := 'E';
END;
BEGIN
SELECT responsibility_id, application_id
INTO l_responsibility_id, l_resp_appl_id
FROM fnd_responsibility_tl
WHERE responsibility_name LIKE 'OA HQ HRMS Manager'
AND LANGUAGE = 'US';
EXCEPTION
WHEN OTHERS
THEN
retcode := 2;
fnd_file.put_line
(fnd_file.LOG,
'Error while fetching responsibility details.Please contact your support administrator. - '
|| SQLERRM
);
l_msg := 'E';
END;
END IF;
fnd_file.put_line (fnd_file.LOG,
'Location 3 l_msg : '
|| l_msg
|| ' Retcode '
|| retcode
);
fnd_file.put_line (fnd_file.LOG, 'Creating Batch Lines Completes : ');
fnd_file.put_line (fnd_file.LOG,
'Number Of Batch Lines l_count: ' || l_count
);
IF l_count = 0
THEN
fnd_file.put_line
(fnd_file.LOG,
'Tracker v_batch_id and v_object_version_number: '
|| v_batch_id
|| ' '
|| v_object_version_number
);
BEGIN
pay_batch_element_entry_api.delete_batch_header
(p_validate => FALSE,
p_batch_id => v_batch_id,
p_object_version_number => v_object_version_number
);
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
retcode := 2;
fnd_file.put_line
(fnd_file.LOG,
'Error while trying to delete Batch Header,Hence exit with retcode 2.Please contact your support administrator. - '
|| SQLERRM
);
l_msg := 'E';
END;
retcode := 2;
fnd_file.put_line
(fnd_file.LOG,
'They are no lines to be proceesed in Validate and Transfer,Hence exit with retcode 2.Please contact your support administrator. - '
|| SQLERRM
);
l_msg := 'E';
END IF;
/* Launching Validate BEE batch once it is created*/
IF l_count > 0
THEN
IF l_msg <> 'E' AND retcode <> 2
THEN
fnd_file.put_line
(fnd_file.LOG,
'*******************************Validate of BEE Start ************************************ '
);
fnd_file.put_line (fnd_file.LOG,
'Launching Batch Process - Validate : '
);
BEGIN
fnd_global.apps_initialize (fnd_profile.VALUE ('USER_ID'),
l_responsibility_id,
l_resp_appl_id
);
--mo_global.init ('S');
--v_notify_user := fnd_request.add_notification ('USER_NAME');
v_request_id1 :=
fnd_request.submit_request
(application => 'PER',
program => 'PAYLINK(VALIDATE)',
description => 'Validates BEE batch',
start_time => SYSDATE,
sub_request => FALSE,
argument1 => 'BATCHEE',
argument2 => 'VALIDATE',
argument3 => v_batch_id
);
COMMIT;
-- COMMIT;
IF v_request_id1 > 0
THEN
fnd_file.put_line
(fnd_file.LOG,
'Launched Batch Process - Validate, Request Id v_request_id1 : '
|| v_request_id1
);
LOOP
lv_req_return_status1 :=
fnd_concurrent.wait_for_request (v_request_id1,
60,
0,
lv_req_phase,
lv_req_status,
lv_req_dev_phase,
lv_req_dev_status,
lv_req_message
);
EXIT WHEN UPPER (lv_req_phase) = 'COMPLETED'
OR UPPER (lv_req_status) IN
('CANCELLED', 'ERROR', 'TERMINATED');
END LOOP;
IF UPPER (lv_req_phase) = 'COMPLETED'
AND UPPER (lv_req_status) = 'ERROR'
THEN
fnd_file.put_line
(fnd_file.LOG,
'In BEE Validate Batch Request @ Wait for request Stage.Contact System Administrotor - '
|| SQLERRM
);
retcode := 2;
l_msg := 'E';
END IF;
fnd_file.put_line
(fnd_file.LOG,
'BEE Validate Batch Request submitted.Request id - '
|| v_request_id1
);
ELSE
fnd_file.put_line
(fnd_file.LOG,
'BEE Validate Batch Request submitted.Request id not submitted.Contact System Administrotor - '
|| SQLERRM
);
retcode := 2;
l_msg := 'E';
END IF;
EXCEPTION
WHEN OTHERS
THEN
retcode := 2;
fnd_file.put_line
(fnd_file.LOG,
'Error while validating the batch Batch Lines outer layout.Please contact your support administrator. - '
|| SQLERRM
);
l_msg := 'E';
END;
fnd_file.put_line
(fnd_file.LOG,
'Batch Process - Validate Completes with Status : '
|| lv_req_status
|| v_request_id1
);
fnd_file.put_line
(fnd_file.LOG,
'*******************************Validate of BEE Ends ************************************ '
);
END IF;
END IF;
BEGIN
SELECT NVL (COUNT (batch_line_status), 0)
INTO l_error_count
FROM pay_batch_lines
WHERE batch_line_status = 'E' AND batch_id = v_batch_id;
EXCEPTION
WHEN OTHERS
THEN
retcode := 2;
fnd_file.put_line
(fnd_file.LOG,
'Error while fetching Batch error count.Please contact your support administrator. - '
|| SQLERRM
);
l_msg := 'E';
END;
IF l_error_count > 0
THEN
retcode := 2;
fnd_file.put_line
(fnd_file.LOG,
'Error while validating batch As error count crossed 0.Please contact your support administrator. - '
|| SQLERRM
);
l_msg := 'E';
END IF;
fnd_file.put_line
(fnd_file.LOG,
'Validate Batch Process - Completes and Error count for assignments in Batch while validating is : '
|| l_error_count
);
/* Launching Transfer BEE batch once it is validated*/
IF l_msg <> 'E'
AND retcode <> 2
AND l_error_count = 0
AND v_request_id1 IS NOT NULL
THEN
-- END IF;
fnd_file.put_line
(fnd_file.LOG,
'*******************************Transfer of BEE Starts ************************************ '
);
fnd_file.put_line (fnd_file.LOG, 'Transfer Batch Process - Launched');
BEGIN
fnd_global.apps_initialize (fnd_profile.VALUE ('USER_ID'),
l_responsibility_id,
l_resp_appl_id
);
--mo_global.init ('S');
--v_notify_user := fnd_request.add_notification ('USER_NAME');
v_request_id2 :=
fnd_request.submit_request
(application => 'PER',
program => 'PAYLINK(TRANSFER)',
description => 'Transfers BEE batch',
start_time => SYSDATE,
sub_request => FALSE,
argument1 => 'BATCHEE',
argument2 => 'TRANSFER',
argument3 => v_batch_id
);
COMMIT;
IF v_request_id2 > 0
THEN
fnd_file.put_line
(fnd_file.LOG,
'BEE Transfer Batch Request submitted.Request id - '
|| v_request_id2
);
LOOP
lv_req_return_status2 :=
fnd_concurrent.wait_for_request (v_request_id2,
60,
0,
lv_req_phase1,
lv_req_status1,
lv_req_dev_phase1,
lv_req_dev_status1,
lv_req_message1
);
EXIT WHEN UPPER (lv_req_phase1) = 'COMPLETED'
OR UPPER (lv_req_status1) IN
('CANCELLED', 'ERROR', 'TERMINATED');
END LOOP;
ELSE
fnd_file.put_line
(fnd_file.LOG,
'BEE Transfer Batch Request submitted.Request id not submitted.Contact System Administrotor - '
|| SQLERRM
);
retcode := 2;
l_msg := 'E';
END IF;
EXCEPTION
WHEN OTHERS
THEN
retcode := 2;
fnd_file.put_line
(fnd_file.LOG,
'Error while validating the batch Batch Lines outer layout.Please contact your support administrator. - '
|| SQLERRM
);
l_msg := 'E';
END;
fnd_file.put_line
(fnd_file.LOG,
'*******************************Transfer of BEE Ends ************************************ '
);
END IF;
-- END IF;
fnd_file.put_line (fnd_file.LOG,
'Location 4 l_msg : '
|| l_msg
|| ' Retcode '
|| retcode
);
IF l_msg = 'E'
THEN
ROLLBACK;
ELSE
COMMIT;
END IF;
"Team Work"
More We Less Me.