Oracle EBS OPM 创建生产批

--创建生产批
--created by jenrry
DECLARE
x_message_count NUMBER;
x_message_list VARCHAR2 (2000);
x_return_status VARCHAR2 (1);
p_batch_header gme_batch_header%ROWTYPE;
x_batch_header gme_batch_header%ROWTYPE;
x_exception_material_tbl gme_common_pvt.exceptions_tab;
l_user_name VARCHAR2 (80):= 'SYSADMIN';
l_user_id NUMBER; CURSOR get_user_id (v_user_name IN VARCHAR2)
IS
SELECT user_id
FROM fnd_user
WHERE user_name = v_user_name; PROCEDURE display_messages (p_msg_count IN NUMBER)
IS
MESSAGE VARCHAR2 (2000);
dummy NUMBER;
l_api_name CONSTANT VARCHAR2 (30) := 'DISPLAY_MESSAGES';
BEGIN
FOR i IN 1 .. p_msg_count
LOOP
fnd_msg_pub.get (p_msg_index => i,
p_data => MESSAGE,
p_encoded => 'F',
p_msg_index_out => dummy
);
DBMS_OUTPUT.put_line ('Message ' || TO_CHAR (i) || ' ' || MESSAGE);
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
fnd_msg_pub.add_exc_msg ('insert_step', l_api_name);
END display_messages;
BEGIN
DBMS_OUTPUT.ENABLE (20000);
l_user_name := 'SYSADMIN'; OPEN get_user_id (l_user_name); FETCH get_user_id
INTO l_user_id; IF get_user_id%NOTFOUND
THEN
DBMS_OUTPUT.put_line ('Invalid User ' || l_user_name); CLOSE get_user_id; RAISE NO_DATA_FOUND;
END IF; CLOSE get_user_id;
fnd_profile.initialize (l_user_id);
fnd_global.apps_initialize (user_id => l_user_id,
resp_id => 51010,
resp_appl_id => 553
);
fnd_profile.put ('AFLOG_LEVEL', '1');
p_batch_header.batch_no := '20170731';-- batch_type .. 10=fpo, 0=batch
p_batch_header.batch_type := 0;
-- p_batch_header.recipe_validity_rule_id := 1336;
p_batch_header.plan_start_date := SYSDATE;
-- p_batch_header.due_date := TO_DATE('');
-- p_batch_header.plan_cmplt_date := TO_DATE('');
p_batch_header.update_inventory_ind := 'Y';
gme_api_pub.create_batch
(p_api_version => 2.0,
p_validation_level => 100,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_true,
x_message_count => x_message_count,
x_message_list => x_message_list,
x_return_status => x_return_status,
p_org_code => 'B01',
p_batch_header_rec => p_batch_header,
x_batch_header_rec => x_batch_header,
p_batch_size => NULL,
p_batch_size_uom => NULL,
p_creation_mode => 'RECIPE',
p_recipe_id => NULL,
p_recipe_no => '60215000002',
p_recipe_version => 1,
p_product_no => NULL,
p_item_revision => NULL,
p_product_id => NULL,
p_ignore_qty_below_cap => fnd_api.g_true,
p_use_workday_cal => NULL,
p_contiguity_override => NULL,
p_use_least_cost_validity_rule => fnd_api.g_false,
x_exception_material_tbl => x_exception_material_tbl
);
DBMS_OUTPUT.put_line ('x_message_count = ' || TO_CHAR (x_message_count));
DBMS_OUTPUT.put_line (SUBSTR ('x_message_list = ' || x_message_list, 1,
255)
);
DBMS_OUTPUT.put_line ('x_return_status = ' || x_return_status);
DBMS_OUTPUT.put_line ('x_batch_header.batch_id = '|| x_batch_header.batch_id);
DBMS_OUTPUT.put_line ('x_batch_header.plant_code = '|| x_batch_header.plant_code);
DBMS_OUTPUT.put_line ('x_batch_header.batch_no = '|| x_batch_header.batch_no);
DBMS_OUTPUT.put_line ('x_batch_header.batch_type = '|| x_batch_header.batch_type);
DBMS_OUTPUT.put_line ('x_batch_header.recipe_validity_rule_id = ' || x_batch_header.recipe_validity_rule_id);
DBMS_OUTPUT.put_line ('x_batch_header.formula_id = '|| x_batch_header.formula_id);
DBMS_OUTPUT.put_line ('x_batch_header.routing_id = '|| x_batch_header.routing_id);
DBMS_OUTPUT.put_line ('x_batch_header.plan_start_date = '
|| TO_CHAR (x_batch_header.plan_start_date,'DD-MON-YYYY HH24:MI:SS'
)
);
DBMS_OUTPUT.put_line ( 'x_batch_header.due_date = '
|| TO_CHAR (x_batch_header.due_date,
'DD-MON-YYYY HH24:MI:SS'
)
);
DBMS_OUTPUT.put_line ( 'x_batch_header.plan_cmplt_date = '
|| TO_CHAR (x_batch_header.plan_cmplt_date,
'DD-MON-YYYY HH24:MI:SS'
)
);
DBMS_OUTPUT.put_line ('x_batch_header.batch_status = '|| x_batch_header.batch_status);
DBMS_OUTPUT.put_line ('x_batch_header.wip_whse_code = '|| x_batch_header.wip_whse_code);
DBMS_OUTPUT.put_line ('x_batch_header.poc_ind = '|| x_batch_header.poc_ind);
DBMS_OUTPUT.put_line ('x_batch_header.update_inventory_ind = '|| x_batch_header.update_inventory_ind);
DBMS_OUTPUT.put_line ( 'x_batch_header.last_update_date = '
|| TO_CHAR (x_batch_header.last_update_date,
'DD-MON-YYYY HH24:MI:SS'
)
);
DBMS_OUTPUT.put_line ( 'x_batch_header.last_updated_by = '||x_batch_header.last_updated_by);
DBMS_OUTPUT.put_line ( 'x_batch_header.creation_date = '
|| TO_CHAR (x_batch_header.creation_date,
'DD-MON-YYYY HH24:MI:SS'
)
);
DBMS_OUTPUT.put_line ('x_batch_header.created_by = '||x_batch_header.created_by);
DBMS_OUTPUT.put_line ('x_batch_header.last_update_login = '|| x_batch_header.last_update_login);
DBMS_OUTPUT.put_line ('x_batch_header.delete_mark = '||x_batch_header.delete_mark);
DBMS_OUTPUT.put_line ('x_batch_header.text_code = '||x_batch_header.text_code);
DBMS_OUTPUT.put_line ('x_batch_header.automatic_step_calculation = '||x_batch_header.automatic_step_calculation); IF x_exception_material_tbl.COUNT > 0
THEN
FOR i IN
x_exception_material_tbl.FIRST .. x_exception_material_tbl.LAST
LOOP
IF x_exception_material_tbl.EXISTS (i)
THEN
DBMS_OUTPUT.put_line
( 'x_exception_material_tbl('
|| TO_CHAR (i)
|| ').organization_id = '
|| TO_CHAR
(x_exception_material_tbl (i).organization_id
)
);
DBMS_OUTPUT.put_line ( 'x_exception_material_tbl('
|| TO_CHAR (i)
|| ').att = '
|| x_exception_material_tbl (i).att
);
DBMS_OUTPUT.put_line ( 'x_exception_material_tbl('
|| TO_CHAR (i)
|| ').atr = '
|| x_exception_material_tbl (i).atr
);
DBMS_OUTPUT.put_line
( 'x_exception_material_tbl('
|| TO_CHAR (i)
|| ').material_detail_id = '
|| x_exception_material_tbl (i).material_detail_id
);
DBMS_OUTPUT.put_line ( 'x_exception_material_tbl('
|| TO_CHAR (i)
|| ').batch_id = '
|| x_exception_material_tbl (i).batch_id
);
END IF;
END LOOP;
END IF; IF x_message_count > 1
THEN
display_messages (x_message_count);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error ' || TO_CHAR (SQLCODE) || ': ' || SQLERRM);
RAISE;
END;
/

  

上一篇:Oracle EBS OPM update material txn


下一篇:IOS判断设备是否已越狱