0% found this document useful (0 votes)
114 views

OPM Batch Release API

This document contains code for releasing batches in an inventory management system. It declares variables and records to hold batch header and material detail information. It calls a release_batch procedure, passing the batch header and other parameters. If successful, it saves the changes and outputs a success message. If not, it outputs error messages. It also contains a separate release_batches procedure that calls release_batch in a loop to process multiple batches.

Uploaded by

msrinviasreddy85
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views

OPM Batch Release API

This document contains code for releasing batches in an inventory management system. It declares variables and records to hold batch header and material detail information. It calls a release_batch procedure, passing the batch header and other parameters. If successful, it saves the changes and outputs a success message. If not, it outputs error messages. It also contains a separate release_batches procedure that calls release_batch in a loop to process multiple batches.

Uploaded by

msrinviasreddy85
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

/* Formatted on 2014/11/20 14:53 (Formatter Plus v4.8.

8) */
DECLARE
l_batch_header

gme_batch_header%ROWTYPE;

x_batch_header

gme_batch_header%ROWTYPE;

p_batch_header

gme_batch_header%ROWTYPE;

x_message_count
x_message_list

NUMBER;
VARCHAR2 (2000);

x_unallocated_material gme_api_pub.unallocated_materials_tab;
x_return_status

VARCHAR2 (1);

l_material_detail

gme_material_details%ROWTYPE;

x_material_detail

gme_material_details%ROWTYPE;

p_values_tab
l_field

gme_api_pub.field_values_tab;
gme_api_pub.p_field;

l_unallocated_material gme_api_pub.unallocated_materials_tab;
l_msg_index_out

NUMBER;

BEGIN

-- Set the applications context

fnd_global.apps_initialize (user_id
resp_id
resp_appl_id

=> 1007882,

=> NULL,
=> NULL

);
l_batch_header.batch_type := 0;
l_batch_header.batch_id := '103237';

--batch_id

l_batch_header.update_inventory_ind := 'Y';
l_batch_header.actual_start_date := SYSDATE;
---

--- RELEASE IT

---

gme_api_pub.release_batch
(p_api_version

=> 1,

p_validation_level
p_init_msg_list
p_commit

=> 1000,
=> TRUE,
=> FALSE,

x_message_count

=> x_message_count,

x_message_list

=> x_message_list,

x_return_status

=> x_return_status,

p_batch_header

=> l_batch_header,

x_batch_header

=> x_batch_header,

p_ignore_shortages

=> TRUE,

x_unallocated_material
p_ignore_unalloc

=> l_unallocated_material,
=> TRUE

);

IF x_return_status = fnd_api.g_ret_sts_success
THEN
DBMS_OUTPUT.put_line ('Batch Released');
p_batch_header.batch_id := 103237;

--batch_id

--

-- SAVE THE CHANGES

gme_api_pub.save_batch (p_batch_header
x_return_status
p_commit

--

=> p_batch_header,

=> x_return_status,
=> TRUE

);
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
p_data

=> i,

=> x_message_list,

p_msg_index_out

=> l_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);


RAISE;
END;

/* Formatted on 2014/11/20 14:58 (Formatter Plus v4.8.8) */


CREATE OR REPLACE PROCEDURE release_batches (
p_batch_id NUMBER,
p_err_buf VARCHAR2,
p_ret_code NUMBER
)
IS
r_batch_header

gme_batch_header%ROWTYPE;

x_message_count

NUMBER;

x_return_status

VARCHAR2 (2);

x_message_list

VARCHAR2 (2000);

r_batch_header_out

gme_batch_header%ROWTYPE;

r_unallocated_material1 gme_api_pub.unallocated_materials_tab;
--PL/SQL Table definition
BEGIN
r_batch_header.batch_id := p_batch_id;
r_batch_header.actual_start_date := SYSDATE;
r_batch_header.actual_cmplt_date := SYSDATE;
r_batch_header.update_inventory_ind := 'Y';
gme_api_main.release_batch

(p_api_version

=> 1,

-- Gme_Api_Pub.api_version, --API Version,


p_validation_level

=> gme_api_pub.max_errors,
--Validation Level

p_init_msg_list

=> TRUE,
--false,--TRUE,

p_commit

=> FALSE,

x_message_count

--p_init_msg_list
--TRUE, --p_commit

=> x_message_count, --output Parameter

x_message_list

=> x_message_list,

x_return_status

=> x_return_status, --output Parameter

p_batch_header

=> r_batch_header, --record declartion,

x_batch_header

=> r_batch_header_out, --output Record

p_ignore_shortages
x_unallocated_material

=> TRUE,

--output Parameter

--batch size

=> r_unallocated_material1
--, --output Record

-- p_ignore_unalloc

=>TRUE --p_ignore_unalloc

);
fnd_file.put_line (fnd_file.LOG,
'release batch return_status = ' || x_return_status
);
gme_debug.display_messages (x_message_count);
-- FND_FILE.PUT_LINE (FND_FILE.LOG,'RELEASE BATCH =' || TO_CHAR (X_MESSAGE_COUNT));

IF x_return_status != 'S'
THEN

fnd_file.put_line (fnd_file.LOG,
'release batch return_status = '
|| x_return_status
|| ' - '
|| x_message_list
);
END IF;
END;

-- End of Relase Batch

You might also like