--Script to Assign and Unassign the delivery no
begin
mo_global.set_policy_context('S',183);
end;
183 -HS1, 184-BS1
DECLARE
P_API_VERSION NUMBER;
REQUESTID NUMBER;
l_layout BOOLEAN;
l_del_no VARCHAR2(100);
v_counter NUMBER;
P_INIT_MSG_LIST VARCHAR2(200);
P_COMMIT VARCHAR2(200);
P_VALIDATION_LEVEL NUMBER;
X_RETURN_STATUS VARCHAR2(200);
X_MSG_COUNT NUMBER;
P_TABOFDELDETS APPS.WSH_DELIVERY_DETAILS_PUB.ID_TAB_TYPE;
P_ACTION VARCHAR2(200);
P_DELIVERY_ID NUMBER;
P_DELIVERY_NAME VARCHAR2(200);
P_COUNT NUMBER;
V_CONTEXT VARCHAR2(100);
v_counter_1 NUMBER;
l_organization_id NUMBER;
l_organization_code VARCHAR2 (10);
l_return_statuss VARCHAR2 (2);
X_MSG_DATA VARCHAR2 (4000);
L_REQUEST_ID FND_CONCURRENT_REQUESTS.REQUEST_ID%TYPE;
L_STATUS_CODE FND_CONCURRENT_REQUESTS.STATUS_CODE%TYPE := '~';
x_del_rows wsh_util_core.id_tab_type;
x_line_rows wsh_util_core.id_tab_type;
l_debug_level NUMBER := 0; -- OM DEBUG LEVEL (MAX 5)
l_return_status VARCHAR2 (100);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (1000);
l_del_rows NUMBER;
l_user_id NUMBER;
l_batch_id NUMBER;
l_batch_rec WSH_PICKING_BATCHES_PUB.batch_info_rec;
CURSOR cur_main IS
SELECT wdd.delivery_detail_id, wdd.organization_id,wnd.delivery_id,wnd.name
,wdd.source_header_type_name
FROM wsh_delivery_details wdd,wsh_delivery_assignments wda,
wsh_new_deliveries wnd
WHERE wdd.organization_id = p_org_id AND wdd.delivery_detail_id =
wda.delivery_detail_id
AND wda.delivery_id =wnd.delivery_id
AND wdd.released_status = 'S'
AND wdd.customer_id = p_cust_id --5346
ORDER BY wdd.customer_id;
CURSOR cur_assign IS SELECT delivery_detail_id, organization_id
FROM wsh_delivery_details ws
WHERE organization_id =p_org_id
AND released_status = 'S'
AND customer_id = p_cust_id
AND NOT EXISTS
(SELECT delivery_detail_id
FROM wsh_delivery_assignments
WHERE delivery_detail_id = ws.delivery_detail_id
AND delivery_id IS NOT NULL)
ORDER BY customer_id;
BEGIN
DBMS_OUTPUT.PUT_LINE('1');
MO_GLOBAL.init('ONT');
P_API_VERSION := 1.0;
P_INIT_MSG_LIST := FND_API.G_TRUE;
P_COMMIT := FND_API.G_TRUE;
P_VALIDATION_LEVEL := FND_API.G_VALID_LEVEL_FULL;
-- Initialize the PLSQL table type variable with 'N' number of Deliverie Detail id's
--P_TABOFDELDETS(1) := 14342581;
v_counter :=0;
--P_TABOFDELDETS(1) := 216028;
FOR i IN cur_main
LOOP
v_counter := v_counter + 1;
P_TABOFDELDETS(v_counter) :=i.delivery_detail_id;
P_ACTION := 'UNASSIGN';
P_DELIVERY_ID := i.delivery_id;
P_DELIVERY_NAME := i.name;
END LOOP;
P_ACTION := 'ASSIGN'; -- Provide the proper Action Type
P_DELIVERY_ID := 20010; --null; -- Delivery id from which the delivery detail to be detached
P_DELIVERY_NAME := '20010'; -- respective delivery name
WSH_DELIVERY_DETAILS_PUB.DETAIL_TO_DELIVERY (
P_API_VERSION => P_API_VERSION,
P_INIT_MSG_LIST => P_INIT_MSG_LIST,
P_COMMIT => P_COMMIT,
P_VALIDATION_LEVEL => P_VALIDATION_LEVEL,
X_RETURN_STATUS => X_RETURN_STATUS,
X_MSG_COUNT => X_MSG_COUNT,
X_MSG_DATA => X_MSG_DATA,
P_TABOFDELDETS => P_TABOFDELDETS,
P_ACTION => P_ACTION,
P_DELIVERY_ID => P_DELIVERY_ID,
P_DELIVERY_NAME => P_DELIVERY_NAME
);
IF X_RETURN_STATUS = 'S' THEN
DBMS_OUTPUT.PUT_LINE('Unassigned Sucessfully ');
ELSE
DBMS_OUTPUT.PUT_LINE('Message count ' || X_MSG_COUNT);
IF X_MSG_COUNT = 1 THEN
DBMS_OUTPUT.PUT_LINE('X_msg_data '||X_MSG_DATA);
ELSIF X_MSG_COUNT > 1 THEN
LOOP
P_COUNT := P_COUNT+1;
X_MSG_DATA := FND_MSG_PUB.GET(FND_MSG_PUB.G_NEXT,FND_API.G_FALSE);
IF X_MSG_DATA IS NULL THEN
EXIT;
END IF;
DBMS_OUTPUT.PUT_LINE('Message' || P_COUNT ||'---'||X_MSG_DATA||' '||
SQLERRM||SQLCODE);
END LOOP;
END IF;
END IF;
BEGIN
v_counter_1 := 0;
FOR r_delivery IN cur_assign
LOOP
v_counter_1 := v_counter_1 + 1;
l_organization_id := r_delivery.organization_id;
x_line_rows (v_counter_1) := r_delivery.delivery_detail_id;
END LOOP;
IF x_line_rows.COUNT > 0
THEN
wsh_delivery_details_pub.autocreate_deliveries (
p_api_version_number => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_true,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_line_rows => x_line_rows,
x_del_rows => x_del_rows
);
IF (x_return_status <> wsh_util_core.g_ret_sts_success)
THEN
--fnd_file.PUT_LINE (fnd_file.OUTPUT, 'Failure');
DBMS_OUTPUT.put_line ('Failure ' || SQLERRM || SQLCODE);
NULL;
ELSE
COMMIT;
-- fnd_file.PUT_LINE (fnd_file.OUTPUT, 'Success');
DBMS_OUTPUT.put_line ('Sucess ');
DBMS_OUTPUT.put_line (x_del_rows (1));
l_del_rows := x_del_rows (1);
l_del_no := x_del_rows (1);
COMMIT;
END IF;
END IF;
END;
END;
begin
mo_global.set_policy_context('S',183);
end;
183 -HS1, 184-BS1
DECLARE
P_API_VERSION NUMBER;
REQUESTID NUMBER;
l_layout BOOLEAN;
l_del_no VARCHAR2(100);
v_counter NUMBER;
P_INIT_MSG_LIST VARCHAR2(200);
P_COMMIT VARCHAR2(200);
P_VALIDATION_LEVEL NUMBER;
X_RETURN_STATUS VARCHAR2(200);
X_MSG_COUNT NUMBER;
P_TABOFDELDETS APPS.WSH_DELIVERY_DETAILS_PUB.ID_TAB_TYPE;
P_ACTION VARCHAR2(200);
P_DELIVERY_ID NUMBER;
P_DELIVERY_NAME VARCHAR2(200);
P_COUNT NUMBER;
V_CONTEXT VARCHAR2(100);
v_counter_1 NUMBER;
l_organization_id NUMBER;
l_organization_code VARCHAR2 (10);
l_return_statuss VARCHAR2 (2);
X_MSG_DATA VARCHAR2 (4000);
L_REQUEST_ID FND_CONCURRENT_REQUESTS.REQUEST_ID%TYPE;
L_STATUS_CODE FND_CONCURRENT_REQUESTS.STATUS_CODE%TYPE := '~';
x_del_rows wsh_util_core.id_tab_type;
x_line_rows wsh_util_core.id_tab_type;
l_debug_level NUMBER := 0; -- OM DEBUG LEVEL (MAX 5)
l_return_status VARCHAR2 (100);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (1000);
l_del_rows NUMBER;
l_user_id NUMBER;
l_batch_id NUMBER;
l_batch_rec WSH_PICKING_BATCHES_PUB.batch_info_rec;
CURSOR cur_main IS
SELECT wdd.delivery_detail_id, wdd.organization_id,wnd.delivery_id,wnd.name
,wdd.source_header_type_name
FROM wsh_delivery_details wdd,wsh_delivery_assignments wda,
wsh_new_deliveries wnd
WHERE wdd.organization_id = p_org_id AND wdd.delivery_detail_id =
wda.delivery_detail_id
AND wda.delivery_id =wnd.delivery_id
AND wdd.released_status = 'S'
AND wdd.customer_id = p_cust_id --5346
ORDER BY wdd.customer_id;
CURSOR cur_assign IS SELECT delivery_detail_id, organization_id
FROM wsh_delivery_details ws
WHERE organization_id =p_org_id
AND released_status = 'S'
AND customer_id = p_cust_id
AND NOT EXISTS
(SELECT delivery_detail_id
FROM wsh_delivery_assignments
WHERE delivery_detail_id = ws.delivery_detail_id
AND delivery_id IS NOT NULL)
ORDER BY customer_id;
BEGIN
DBMS_OUTPUT.PUT_LINE('1');
MO_GLOBAL.init('ONT');
P_API_VERSION := 1.0;
P_INIT_MSG_LIST := FND_API.G_TRUE;
P_COMMIT := FND_API.G_TRUE;
P_VALIDATION_LEVEL := FND_API.G_VALID_LEVEL_FULL;
-- Initialize the PLSQL table type variable with 'N' number of Deliverie Detail id's
--P_TABOFDELDETS(1) := 14342581;
v_counter :=0;
--P_TABOFDELDETS(1) := 216028;
FOR i IN cur_main
LOOP
v_counter := v_counter + 1;
P_TABOFDELDETS(v_counter) :=i.delivery_detail_id;
P_ACTION := 'UNASSIGN';
P_DELIVERY_ID := i.delivery_id;
P_DELIVERY_NAME := i.name;
END LOOP;
P_ACTION := 'ASSIGN'; -- Provide the proper Action Type
P_DELIVERY_ID := 20010; --null; -- Delivery id from which the delivery detail to be detached
P_DELIVERY_NAME := '20010'; -- respective delivery name
WSH_DELIVERY_DETAILS_PUB.DETAIL_TO_DELIVERY (
P_API_VERSION => P_API_VERSION,
P_INIT_MSG_LIST => P_INIT_MSG_LIST,
P_COMMIT => P_COMMIT,
P_VALIDATION_LEVEL => P_VALIDATION_LEVEL,
X_RETURN_STATUS => X_RETURN_STATUS,
X_MSG_COUNT => X_MSG_COUNT,
X_MSG_DATA => X_MSG_DATA,
P_TABOFDELDETS => P_TABOFDELDETS,
P_ACTION => P_ACTION,
P_DELIVERY_ID => P_DELIVERY_ID,
P_DELIVERY_NAME => P_DELIVERY_NAME
);
IF X_RETURN_STATUS = 'S' THEN
DBMS_OUTPUT.PUT_LINE('Unassigned Sucessfully ');
ELSE
DBMS_OUTPUT.PUT_LINE('Message count ' || X_MSG_COUNT);
IF X_MSG_COUNT = 1 THEN
DBMS_OUTPUT.PUT_LINE('X_msg_data '||X_MSG_DATA);
ELSIF X_MSG_COUNT > 1 THEN
LOOP
P_COUNT := P_COUNT+1;
X_MSG_DATA := FND_MSG_PUB.GET(FND_MSG_PUB.G_NEXT,FND_API.G_FALSE);
IF X_MSG_DATA IS NULL THEN
EXIT;
END IF;
DBMS_OUTPUT.PUT_LINE('Message' || P_COUNT ||'---'||X_MSG_DATA||' '||
SQLERRM||SQLCODE);
END LOOP;
END IF;
END IF;
BEGIN
v_counter_1 := 0;
FOR r_delivery IN cur_assign
LOOP
v_counter_1 := v_counter_1 + 1;
l_organization_id := r_delivery.organization_id;
x_line_rows (v_counter_1) := r_delivery.delivery_detail_id;
END LOOP;
IF x_line_rows.COUNT > 0
THEN
wsh_delivery_details_pub.autocreate_deliveries (
p_api_version_number => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_true,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_line_rows => x_line_rows,
x_del_rows => x_del_rows
);
IF (x_return_status <> wsh_util_core.g_ret_sts_success)
THEN
--fnd_file.PUT_LINE (fnd_file.OUTPUT, 'Failure');
DBMS_OUTPUT.put_line ('Failure ' || SQLERRM || SQLCODE);
NULL;
ELSE
COMMIT;
-- fnd_file.PUT_LINE (fnd_file.OUTPUT, 'Success');
DBMS_OUTPUT.put_line ('Sucess ');
DBMS_OUTPUT.put_line (x_del_rows (1));
l_del_rows := x_del_rows (1);
l_del_no := x_del_rows (1);
COMMIT;
END IF;
END IF;
END;
END;
No comments:
Post a Comment