OracleEBS創建LPN
創建LPN
PROCEDURE create_lpn(errbuf OUT VARCHAR2,
retcode OUT VARCHAR2 ,
p_organization_id IN NUMBER ,
p_lpn_prefix IN VARCHAR2 ,
p_lpn_suffix IN VARCHAR2 ,
p_lpn IN VARCHAR2 ) IS
BEGIN
--Initialize
wms_container_pvt.generate_lpn_cp(errbuf => errbuf,
retcode => retcode,
p_api_version => 1,
p_organization_id => p_organization_id,
p_container_item_id => NULL,
p_revision => NULL,
p_lot_number => NULL,
p_from_serial_number => NULL,
p_to_serial_number => NULL,
p_subinventory => NULL,
p_locator_id => NULL,
p_org_parameters => 2,
p_parm_dummy_1 => 'N',
p_total_length => NULL,
p_lpn_prefix => p_lpn_prefix,
p_starting_num => p_lpn,
p_ucc_128_suffix_flag => 2,
p_parm_dummy_2 => 'N',
p_lpn_suffix => p_lpn_suffix,
p_quantity => 1,
p_source => NULL,
p_cost_group_id => NULL);
END;
-- --------------------------------------------
-- Get LPN
Id
-- --------------------------------------------
PROCEDURE get_lpn_id(x_lpn_id OUT NUMBER ,
p_lpn IN VARCHAR2) IS
--l_lpn_exist
NUMBER;
BEGIN
x_lpn_id := - 9999;
SELECT lpn.lpn_id
INTO x_lpn_id
FROM wms_license_plate_numbers
lpn
WHERE 1 = 1
AND lpn.license_plate_number
= p_lpn;
EXCEPTION
WHEN no_data_found THEN
x_lpn_id := - 1;
--LPN不存在
WHEN OTHERS THEN
x_lpn_id := - 9999;
END;
--創建LPN
--檢查LPN是否存在
get_lpn_id(l_outer_lpn_id, p_n_lpn_num);
--拆分LPN號
SELECT substr (p_n_lpn_num,
-1),
substr(p_n_lpn_num, 1 , length(p_n_lpn_num)
- 1)
INTO l_lpn_number,
l_lpn_prefix
FROM dual;
--創建LPN
IF l_outer_lpn_id
= -1 THEN
create_lpn(errbuf => l_errbuf,
retcode => l_retcode,
p_organization_id => p_organization_id,
p_lpn_prefix => l_lpn_prefix,
p_lpn_suffix => NULL,
p_lpn => l_lpn_number);
IF l_errbuf
<> '0' THEN
x_msg_data := l_msg_data || '創建LPN失敗:' ||
l_errbuf;
RAISE header_error;
ELSE
--獲取創建後的LPN_ID
get_lpn_id(l_new_lpn_id, p_n_lpn_num);
--箱號添加毛重
l_lpn_rec := NULL;
l_lpn_rec.lpn_id := l_new_lpn_id;
l_lpn_rec.gross_weight_uom_code := 'kg';
l_lpn_rec.gross_weight := p_n_gross_weight;
wms_container_pvt.modify_lpn(p_api_version => 1,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_false,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
p_caller => NULL,
p_lpn => l_lpn_rec);
IF l_return_status
<> 'S' THEN
x_msg_data := l_msg_data || '修改毛重失敗' ;
RAISE header_error;
END IF ;
END IF;