--close_batch --created by jenrry DECLARE x_message_count NUMBER; x_message_list VARCHAR2 (4000); x_return_status VARCHAR2 (2000); p_batch_header gme_batch_header%ROWTYPE; x_batch_header gme_batch_header%ROWTYPE; l_user_name VARCHAR2 (80); l_user_id NUMBER; CURSOR get_user_id (v_user_name IN VARCHAR2) IS SELECT user_id FROM fnd_user WHERE user_name = v_user_name; PROCEDURE display_messages (p_msg_count IN NUMBER) IS MESSAGE VARCHAR2 (2000); dummy NUMBER; l_api_name CONSTANT VARCHAR2 (30) := 'DISPLAY_MESSAGES'; BEGIN FOR i IN 1 .. p_msg_count LOOP fnd_msg_pub.get (p_msg_index => i, p_data => MESSAGE, p_encoded => 'F', p_msg_index_out => dummy ); DBMS_OUTPUT.put_line ('Message ' || TO_CHAR (i) || ' ' || MESSAGE); END LOOP; EXCEPTION WHEN OTHERS THEN fnd_msg_pub.add_exc_msg ('wrapper for Close_batch', l_api_name); END display_messages; BEGIN DBMS_OUTPUT.ENABLE (20000); l_user_name := 'PROCESS_OPS'; OPEN get_user_id (l_user_name); FETCH get_user_id INTO l_user_id; IF get_user_id%NOTFOUND THEN DBMS_OUTPUT.put_line ('Invalid User ' || l_user_name); CLOSE get_user_id; RAISE NO_DATA_FOUND; END IF; CLOSE get_user_id; fnd_profile.initialize (l_user_id); fnd_global.apps_initialize (user_id => l_user_id, resp_id => NULL, resp_appl_id => NULL ); p_batch_header.batch_id := 217713; p_batch_header.plant_code := NULL; p_batch_header.batch_no := NULL; p_batch_header.batch_type := NULL; -- p_batch_header.batch_close_date := TO_DATE('31-JAN-2004 23:00:00','DD-MON-YYYY HH24:MI:SS'); DBMS_OUTPUT.put_line ('Calling gme_api_pub.close_batch ... '); gme_api_pub.close_batch (p_api_version => 2, p_validation_level => 100, p_init_msg_list => 'T', p_commit => 'F', x_message_count => x_message_count, x_message_list => x_message_list, x_return_status => x_return_status, p_batch_header_rec => p_batch_header, x_batch_header_rec => x_batch_header, p_org_code => NULL ); DBMS_OUTPUT.put_line ( 'After Calling gme_api_pub.close_batch ... x_return_status = ' || x_return_status ); DBMS_OUTPUT.put_line ('x_message_count = ' || TO_CHAR (x_message_count)); DBMS_OUTPUT.put_line ('x_message_list = ' || x_message_list); DBMS_OUTPUT.put_line ('x_return_status = ' || x_return_status); DBMS_OUTPUT.put_line ( 'x_batch_header.batch_id = ' || TO_CHAR (x_batch_header.batch_id) ); DBMS_OUTPUT.put_line ( 'x_batch_header.plant_code = ' || x_batch_header.plant_code ); DBMS_OUTPUT.put_line ( 'x_batch_header.batch_no = ' || x_batch_header.batch_no ); DBMS_OUTPUT.put_line ( 'x_batch_header.batch_type = ' || TO_CHAR (x_batch_header.batch_type) ); DBMS_OUTPUT.put_line ( 'x_batch_header.batch_status = ' || TO_CHAR (x_batch_header.batch_status) ); DBMS_OUTPUT.put_line ( 'x_batch_header.batch_close_date = ' || TO_CHAR (x_batch_header.batch_close_date) ); IF x_message_count > 1 THEN display_messages (x_message_count); END IF; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line ('Error ' || TO_CHAR (SQLCODE) || ': ' || SQLERRM); RAISE; END; /