Below anonymous block will Add hold to existing Sales order in Order Management.
(Note: Change values as per your requirement also On DBMS Output window to see DBMS Output message)
DECLARE
v_return_status VARCHAR2(30);
v_msg_data VARCHAR2(4000);
v_msg_count NUMBER;
v_hold_source_rec OE_HOLDS_PVT.HOLD_SOURCE_REC_TYPE;
v_hold_id NUMBER DEFAULT 2032;
v_hold_entity_code VARCHAR2(10) DEFAULT 'O';
v_header_id NUMBER DEFAULT 5;
l_debug_file VARCHAR2(200);
l_debug_level NUMBER := 5; -- OM DEBUG LEVEL (MAX 5)
l_org NUMBER := 194; -- OPERATING UNIT
BEGIN
-- INITIALIZATION REQUIRED FOR R12
mo_global.set_policy_context ('S', l_org);
mo_global.init('ONT');
-- INITIALIZE DEBUG INFO
IF (l_debug_level > 0) THEN
l_debug_file := OE_DEBUG_PUB.Set_Debug_Mode('FILE');
oe_debug_pub.initialize;
oe_debug_pub.setdebuglevel(l_debug_level);
Oe_Msg_Pub.initialize;
END IF;
-- INITIALIZE ENVIRONMENT
fnd_global.apps_initialize (user_id => 2106, resp_id => 50663, resp_appl_id => 660);
mo_global.set_policy_context ('S', 194);
--- context done ------------
v_hold_source_rec := OE_HOLDS_PVT.G_MISS_HOLD_SOURCE_REC;
v_hold_source_rec.hold_id := v_hold_id;
v_hold_source_rec.hold_entity_code := v_hold_entity_code;
v_hold_source_rec.hold_entity_id := v_header_id;
v_hold_source_rec.header_id := v_header_id;
v_return_status := NULL;
v_msg_data := NULL;
v_msg_count := NULL;
dbms_output.put_line('Calling the API to Apply hold' );
OE_HOLDS_PUB.APPLY_HOLDS (
p_api_version => 1.0,
p_init_msg_list => FND_API.G_TRUE,
p_commit => FND_API.G_FALSE,
p_hold_source_rec => v_hold_source_rec,
x_return_status => v_return_status,
x_msg_count => v_msg_count,
x_msg_data => v_msg_data
);
IF v_return_status = FND_API.G_RET_STS_SUCCESS THEN
dbms_output.put_line('success:');
COMMIT;
ELSIF v_return_status IS NULL THEN
DBMS_OUTPUT.PUT_LINE('Status is null');
ELSE
DBMS_OUTPUT.PUT_LINE('failure:'|| v_msg_data ||'v_msg_count'||v_msg_count);
FOR i IN 1 .. v_msg_count
LOOP
v_msg_data := oe_msg_pub.get( p_msg_index => i, p_encoded => 'F');
dbms_output.put_line( i|| ') '|| v_msg_data);
END LOOP;
ROLLBACK;
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error : '||SQLCODE||'---'||SQLERRM);
END;
(Note: Change values as per your requirement also On DBMS Output window to see DBMS Output message)
DECLARE
v_return_status VARCHAR2(30);
v_msg_data VARCHAR2(4000);
v_msg_count NUMBER;
v_hold_source_rec OE_HOLDS_PVT.HOLD_SOURCE_REC_TYPE;
v_hold_id NUMBER DEFAULT 2032;
v_hold_entity_code VARCHAR2(10) DEFAULT 'O';
v_header_id NUMBER DEFAULT 5;
l_debug_file VARCHAR2(200);
l_debug_level NUMBER := 5; -- OM DEBUG LEVEL (MAX 5)
l_org NUMBER := 194; -- OPERATING UNIT
BEGIN
-- INITIALIZATION REQUIRED FOR R12
mo_global.set_policy_context ('S', l_org);
mo_global.init('ONT');
-- INITIALIZE DEBUG INFO
IF (l_debug_level > 0) THEN
l_debug_file := OE_DEBUG_PUB.Set_Debug_Mode('FILE');
oe_debug_pub.initialize;
oe_debug_pub.setdebuglevel(l_debug_level);
Oe_Msg_Pub.initialize;
END IF;
-- INITIALIZE ENVIRONMENT
fnd_global.apps_initialize (user_id => 2106, resp_id => 50663, resp_appl_id => 660);
mo_global.set_policy_context ('S', 194);
--- context done ------------
v_hold_source_rec := OE_HOLDS_PVT.G_MISS_HOLD_SOURCE_REC;
v_hold_source_rec.hold_id := v_hold_id;
v_hold_source_rec.hold_entity_code := v_hold_entity_code;
v_hold_source_rec.hold_entity_id := v_header_id;
v_hold_source_rec.header_id := v_header_id;
v_return_status := NULL;
v_msg_data := NULL;
v_msg_count := NULL;
dbms_output.put_line('Calling the API to Apply hold' );
OE_HOLDS_PUB.APPLY_HOLDS (
p_api_version => 1.0,
p_init_msg_list => FND_API.G_TRUE,
p_commit => FND_API.G_FALSE,
p_hold_source_rec => v_hold_source_rec,
x_return_status => v_return_status,
x_msg_count => v_msg_count,
x_msg_data => v_msg_data
);
IF v_return_status = FND_API.G_RET_STS_SUCCESS THEN
dbms_output.put_line('success:');
COMMIT;
ELSIF v_return_status IS NULL THEN
DBMS_OUTPUT.PUT_LINE('Status is null');
ELSE
DBMS_OUTPUT.PUT_LINE('failure:'|| v_msg_data ||'v_msg_count'||v_msg_count);
FOR i IN 1 .. v_msg_count
LOOP
v_msg_data := oe_msg_pub.get( p_msg_index => i, p_encoded => 'F');
dbms_output.put_line( i|| ') '|| v_msg_data);
END LOOP;
ROLLBACK;
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error : '||SQLCODE||'---'||SQLERRM);
END;
No comments:
Post a Comment