OPM Batch Release :
The Release_Batch API checks for the validity of the batch validity rule, and ingredient reservations to create transactions. It also checks for unexploded phantoms, except for those that are Automatic by Step with a step association. The Batch status is set to work in process.
API: GME_API_PUB.RELEASE_BATCH
Sample Code:
create or replace PROCEDURE release_batch (p_batch_id IN NUMBER, p_run_seq_id IN NUMBER)
IS
lr_batch_header gme_batch_header%ROWTYPE;
lt_exception_material_tbl gme_common_pvt.exceptions_tab;
x_return_status VARCHAR2 (10);
x_batch_header gme_batch_header%ROWTYPE;
ld_st_date DATE;
ld_com_date DATE;
ln_msg_index_out NUMBER;
ln_batch_no NUMBER;
ln_rule_id NUMBER;
ln_org_id NUMBER;
lc_org_code VARCHAR2 (5);
lc_status VARCHAR2 (5);
lc_message_list VARCHAR2 (2000);
ln_step_no NUMBER;
x_message_count NUMBER;
x_message_list VARCHAR2 (2000);
BEGIN
fnd_global.apps_initialize (user_id => gn_user_id,
resp_id => gn_resp_id,
resp_appl_id => gn_prog_appl_id
);
BEGIN
SELECT plan_start_date, plan_cmplt_date, batch_no,
recipe_validity_rule_id, organization_id
INTO ld_st_date, ld_com_date, ln_batch_no,
ln_rule_id, ln_org_id
FROM gme_batch_header
WHERE batch_id = p_batch_id;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( 'Error In Selecting Batch Mat Details'
|| SQLERRM
);
END;
IF ln_org_id IS NOT NULL
THEN
SELECT organization_code
INTO lc_org_code
FROM org_organization_definitions
WHERE organization_id = ln_org_id;
END IF;
lr_batch_header.batch_type := 0;
lr_batch_header.batch_no := ln_batch_no;
lr_batch_header.plan_start_date := ld_st_date;
lr_batch_header.plan_cmplt_date := ld_com_date;
lr_batch_header.update_inventory_ind := 'Y';
lr_batch_header.recipe_validity_rule_id := ln_rule_id;
lr_batch_header.actual_start_date := SYSDATE;
gme_api_pub.release_batch
(p_api_version => 2.0,
p_validation_level => 100,
p_init_msg_list => fnd_api.g_false,
p_commit => fnd_api.g_false,
x_message_count => x_message_count,
x_message_list => x_message_list,
x_return_status => x_return_status,
p_batch_header_rec => lr_batch_header,
p_org_code => lc_org_code,
p_ignore_exception => 'T',
p_validate_flexfields => fnd_api.g_false,
x_batch_header_rec => x_batch_header,
x_exception_material_tbl => lt_exception_material_tbl
);
COMMIT;
IF x_return_status = fnd_api.g_ret_sts_success
THEN
DBMS_OUTPUT.put_line ('Batch Released');
ELSE
DBMS_OUTPUT.put_line ('Batch Release failed');
IF x_message_count = 1
THEN
DBMS_OUTPUT.put_line ('Error:' || x_message_list);
ELSE
FOR i IN 1 .. x_message_count
LOOP
fnd_msg_pub.get (p_msg_index => i,
p_data => x_message_list,
p_msg_index_out => ln_msg_index_out
);
DBMS_OUTPUT.put_line ('Error: ' || x_message_list);
END LOOP;
END IF;
END IF;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error ' || TO_CHAR (SQLCODE) || ': '
|| SQLERRM
);
END;
OPM Batch Unrelease :
Once a batch is released, the status will be reversed from Released to Pending. The completed transactions are reversed, actual values are reset to zero, and inventory is updated.
API: GME_API_PUB.UNRELEASE_BATCH
Sample Code:
create or replace PROCEDURE unrelease_batch (p_batch_id IN NUMBER, p_run_seq_id IN NUMBER)
IS
lr_batch_header gme_batch_header%ROWTYPE;
lt_exception_material_tbl gme_common_pvt.exceptions_tab;
x_return_status VARCHAR2 (10);
x_batch_header gme_batch_header%ROWTYPE;
ln_msg_index_out NUMBER;
ln_batch_no NUMBER;
lc_org_code VARCHAR2 (5);
lc_status VARCHAR2 (5);
lc_message_list VARCHAR2 (2000);
x_message_count NUMBER;
x_message_list VARCHAR2 (2000);
i NUMBER;
BEGIN
fnd_global.apps_initialize (user_id => gn_user_id,
resp_id => gn_resp_id,
resp_appl_id => gn_prog_appl_id
);
lr_batch_header.batch_id := p_batch_id;
BEGIN
SELECT organization_code
INTO lc_org_code
FROM org_organization_definitions
WHERE organization_id = (SELECT organization_id
FROM gme_batch_header
WHERE batch_id = p_batch_id);
EXCEPTION
WHEN OTHERS
THEN
lc_org_code := NULL;
END;
gme_api_pub.unrelease_batch (p_api_version => 2.0,
p_validation_level => 100,
p_init_msg_list => fnd_api.g_false,
p_commit => fnd_api.g_false,
p_save_batch => fnd_api.g_false,
x_message_count => x_message_count,
x_message_list => lc_message_list,
x_return_status => x_return_status,
p_batch_header_rec => lr_batch_header,
p_org_code => lc_org_code,
p_create_resv_pend_lots => 1, -- Recreate reservations- NO
p_continue_lpn_txn => 'N',
x_batch_header_rec => x_batch_header
);
COMMIT;
IF x_return_status = fnd_api.g_ret_sts_success
THEN
DBMS_OUTPUT.put_line ('Batch Unreleased' || x_message_list);
ELSE
IF x_message_count = 1
THEN
DBMS_OUTPUT.put_line ('Error' || lc_message_list);
ELSE
FOR i IN 1 .. x_message_count
LOOP
fnd_msg_pub.get (p_msg_index => i,
p_data => x_message_list,
p_msg_index_out => ln_msg_index_out
);
END LOOP;
COMMIT;
END IF;
END IF;
END;
No comments:
Post a Comment