PROCEDURE XXVEM_SO_PICK_RELEASE
(P_ORDER_NUMBER IN NUMBER,
P_RETURN_STATUS OUT VARCHAR2)
IS
l_return_status VARCHAR2 (1);
l_msg_count NUMBER (15);
l_msg_data VARCHAR2 (2000);
l_count NUMBER (15);
l_msg_data_out VARCHAR2 (2000);
l_mesg VARCHAR2 (2000);
p_count NUMBER (15);
p_new_batch_id NUMBER;
l_rule_id NUMBER;
l_rule_name VARCHAR2 (2000);
l_batch_prefix VARCHAR2 (2000);
l_batch_info_rec wsh_picking_batches_pub.batch_info_rec;
l_REQUEST_ID NUMBER;
v_context varchar2(100);
ln_customer_id NUMBER;
ln_header_id NUMBER;
ln_ship_from_org_id NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE('1');
--1. Set applications context if not already set.
mo_global.set_policy_context ('S', l_org_id);
mo_global.init ('ONT');
fnd_global.apps_initialize (user_id, resp_id, resp_appl_id);
BEGIN
SELECT h.sold_to_org_id
, h.header_id
, (select distinct l.ship_from_org_id
from oe_order_lines_all l
where l.header_id = h.header_id
and rownum = 1 ) ship_from_org_id
INTO ln_customer_id
, ln_header_id
, ln_ship_from_org_id
FROM oe_order_headers_all h
WHERE H.ORDER_NUMBER = P_ORDER_NUMBER
AND H.ORG_ID = fnd_profile.value('org_id');
dbms_output.put_line('ln_customer_id ' ||ln_customer_id);
dbms_output.put_line('ln_header_id ' ||ln_header_id);
dbms_output.put_line('ln_ship_from_org_id ' ||ln_ship_from_org_id);
exception
when others then
dbms_output.put_line('Error occured while getting order customer id : ' ||SQLERRM);
END;
l_batch_info_rec.backorders_only_flag := 'E';
l_batch_info_rec.existing_rsvs_only_flag := 'N';
l_batch_info_rec.customer_id := ln_customer_id ;
l_batch_info_rec.order_header_id := ln_header_id ;
l_batch_info_rec.from_scheduled_ship_date := sysdate;
l_batch_info_rec.organization_id := ln_ship_from_org_id;
--l_batch_info_rec.Ship_Method_Code := '0001_ship_method_code'; -- pass ship method code
--l_batch_info_rec.Ship_Set_Id :=
--l_batch_info_rec.Ship_Set_Number :=
l_batch_info_rec.include_planned_lines := 'N';
l_batch_info_rec.autocreate_delivery_flag := 'Y';
l_batch_info_rec.autodetail_pr_flag := 'Y';
l_batch_info_rec.allocation_method := 'I';
--l_batch_info_rec.pick_from_locator_id := 567678; -- pass from_locator_id
l_batch_info_rec.auto_pick_confirm_flag := 'Y';
l_batch_info_rec.autopack_flag := 'Y';
--l_rule_id := 10;
l_rule_name := 'XXVEM Pick Rule';
l_batch_prefix := NULL;
wsh_picking_batches_pub.create_batch
(
p_api_version => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_true,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
p_rule_id => l_rule_id,
p_rule_name => l_rule_name,
p_batch_rec => l_batch_info_rec,
p_batch_prefix => l_batch_prefix,
x_batch_id => p_new_batch_id
);
commit;
IF l_return_status = 'S' THEN
DBMS_OUTPUT.put_line('Pick Release Batch Got Created Sucessfully '||p_new_batch_id);
ELSE
DBMS_OUTPUT.put_line('Message count ' || l_msg_count);
IF l_msg_count = 1 THEN
DBMS_OUTPUT.put_line('l_msg_data '||l_msg_data);
ELSIF l_msg_count > 1 THEN
LOOP
p_count := p_count+1;
l_msg_data := FND_MSG_PUB.Get(FND_MSG_PUB.G_NEXT,FND_API.G_FALSE);
IF l_msg_data IS NULL THEN
EXIT;
END IF;
DBMS_OUTPUT.put_line('Message' || p_count ||'---'||l_msg_data);
END LOOP;
END IF;
END IF;
-- Release the batch Created Above
WSH_PICKING_BATCHES_PUB.RELEASE_BATCH(
P_API_VERSION => 1.0,
P_INIT_MSG_LIST => fnd_api.g_true,
P_COMMIT => fnd_api.g_true,
X_RETURN_STATUS => P_RETURN_STATUS,
X_MSG_COUNT => l_MSG_COUNT,
X_MSG_DATA => l_MSG_DATA,
P_BATCH_ID => p_new_batch_id,
P_BATCH_NAME => NULL,
P_LOG_LEVEL => 1,
P_RELEASE_MODE => 'ONLINE',-- (ONLINE or CONCURRENT)
X_REQUEST_ID => l_REQUEST_ID
);
commit;
IF P_RETURN_STATUS = 'S' THEN
DBMS_OUTPUT.put_line('Pick Selection List Generation '||l_REQUEST_ID);
DBMS_OUTPUT.put_line('Pick Selection List Generation P_RETURN_STATUS '||P_RETURN_STATUS);
ELSE
DBMS_OUTPUT.put_line('Message count ' || l_msg_count);
IF l_msg_count = 1 THEN
DBMS_OUTPUT.put_line('l_msg_data '||l_msg_data);
ELSIF l_msg_count > 1 THEN
LOOP
p_count := p_count+1;
l_msg_data := FND_MSG_PUB.Get(FND_MSG_PUB.G_NEXT,FND_API.G_FALSE);
IF l_msg_data IS NULL THEN
EXIT;
END IF;
DBMS_OUTPUT.put_line('Message' || p_count ||'---'||l_msg_data);
END LOOP;
END IF;
END IF;
END;
(P_ORDER_NUMBER IN NUMBER,
P_RETURN_STATUS OUT VARCHAR2)
IS
l_return_status VARCHAR2 (1);
l_msg_count NUMBER (15);
l_msg_data VARCHAR2 (2000);
l_count NUMBER (15);
l_msg_data_out VARCHAR2 (2000);
l_mesg VARCHAR2 (2000);
p_count NUMBER (15);
p_new_batch_id NUMBER;
l_rule_id NUMBER;
l_rule_name VARCHAR2 (2000);
l_batch_prefix VARCHAR2 (2000);
l_batch_info_rec wsh_picking_batches_pub.batch_info_rec;
l_REQUEST_ID NUMBER;
v_context varchar2(100);
ln_customer_id NUMBER;
ln_header_id NUMBER;
ln_ship_from_org_id NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE('1');
--1. Set applications context if not already set.
mo_global.set_policy_context ('S', l_org_id);
mo_global.init ('ONT');
fnd_global.apps_initialize (user_id, resp_id, resp_appl_id);
BEGIN
SELECT h.sold_to_org_id
, h.header_id
, (select distinct l.ship_from_org_id
from oe_order_lines_all l
where l.header_id = h.header_id
and rownum = 1 ) ship_from_org_id
INTO ln_customer_id
, ln_header_id
, ln_ship_from_org_id
FROM oe_order_headers_all h
WHERE H.ORDER_NUMBER = P_ORDER_NUMBER
AND H.ORG_ID = fnd_profile.value('org_id');
dbms_output.put_line('ln_customer_id ' ||ln_customer_id);
dbms_output.put_line('ln_header_id ' ||ln_header_id);
dbms_output.put_line('ln_ship_from_org_id ' ||ln_ship_from_org_id);
exception
when others then
dbms_output.put_line('Error occured while getting order customer id : ' ||SQLERRM);
END;
l_batch_info_rec.backorders_only_flag := 'E';
l_batch_info_rec.existing_rsvs_only_flag := 'N';
l_batch_info_rec.customer_id := ln_customer_id ;
l_batch_info_rec.order_header_id := ln_header_id ;
l_batch_info_rec.from_scheduled_ship_date := sysdate;
l_batch_info_rec.organization_id := ln_ship_from_org_id;
--l_batch_info_rec.Ship_Method_Code := '0001_ship_method_code'; -- pass ship method code
--l_batch_info_rec.Ship_Set_Id :=
--l_batch_info_rec.Ship_Set_Number :=
l_batch_info_rec.include_planned_lines := 'N';
l_batch_info_rec.autocreate_delivery_flag := 'Y';
l_batch_info_rec.autodetail_pr_flag := 'Y';
l_batch_info_rec.allocation_method := 'I';
--l_batch_info_rec.pick_from_locator_id := 567678; -- pass from_locator_id
l_batch_info_rec.auto_pick_confirm_flag := 'Y';
l_batch_info_rec.autopack_flag := 'Y';
--l_rule_id := 10;
l_rule_name := 'XXVEM Pick Rule';
l_batch_prefix := NULL;
wsh_picking_batches_pub.create_batch
(
p_api_version => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_true,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
p_rule_id => l_rule_id,
p_rule_name => l_rule_name,
p_batch_rec => l_batch_info_rec,
p_batch_prefix => l_batch_prefix,
x_batch_id => p_new_batch_id
);
commit;
IF l_return_status = 'S' THEN
DBMS_OUTPUT.put_line('Pick Release Batch Got Created Sucessfully '||p_new_batch_id);
ELSE
DBMS_OUTPUT.put_line('Message count ' || l_msg_count);
IF l_msg_count = 1 THEN
DBMS_OUTPUT.put_line('l_msg_data '||l_msg_data);
ELSIF l_msg_count > 1 THEN
LOOP
p_count := p_count+1;
l_msg_data := FND_MSG_PUB.Get(FND_MSG_PUB.G_NEXT,FND_API.G_FALSE);
IF l_msg_data IS NULL THEN
EXIT;
END IF;
DBMS_OUTPUT.put_line('Message' || p_count ||'---'||l_msg_data);
END LOOP;
END IF;
END IF;
-- Release the batch Created Above
WSH_PICKING_BATCHES_PUB.RELEASE_BATCH(
P_API_VERSION => 1.0,
P_INIT_MSG_LIST => fnd_api.g_true,
P_COMMIT => fnd_api.g_true,
X_RETURN_STATUS => P_RETURN_STATUS,
X_MSG_COUNT => l_MSG_COUNT,
X_MSG_DATA => l_MSG_DATA,
P_BATCH_ID => p_new_batch_id,
P_BATCH_NAME => NULL,
P_LOG_LEVEL => 1,
P_RELEASE_MODE => 'ONLINE',-- (ONLINE or CONCURRENT)
X_REQUEST_ID => l_REQUEST_ID
);
commit;
IF P_RETURN_STATUS = 'S' THEN
DBMS_OUTPUT.put_line('Pick Selection List Generation '||l_REQUEST_ID);
DBMS_OUTPUT.put_line('Pick Selection List Generation P_RETURN_STATUS '||P_RETURN_STATUS);
ELSE
DBMS_OUTPUT.put_line('Message count ' || l_msg_count);
IF l_msg_count = 1 THEN
DBMS_OUTPUT.put_line('l_msg_data '||l_msg_data);
ELSIF l_msg_count > 1 THEN
LOOP
p_count := p_count+1;
l_msg_data := FND_MSG_PUB.Get(FND_MSG_PUB.G_NEXT,FND_API.G_FALSE);
IF l_msg_data IS NULL THEN
EXIT;
END IF;
DBMS_OUTPUT.put_line('Message' || p_count ||'---'||l_msg_data);
END LOOP;
END IF;
END IF;
END;
No comments:
Post a Comment