OPM – GMD – Delete Row from the formula in R12
The procedure to delete the row from the formula
PROCEDURE delete_formuladetail(
p_formula_id NUMBER ,
p_formulaline_id NUMBER ,
p_return_status OUT VARCHAR2 ,
p_message OUT VARCHAR2 )
IS
l_api_version CONSTANT NUMBER := 1.1;
l_init_msg_list VARCHAR2(1) := FND_API.G_TRUE ;
l_commit VARCHAR2(1) := FND_API.G_FALSE;
l_called_from_forms VARCHAR2(10) := ‘NO’;
l_return_status VARCHAR2(1) ;
l_msg_count NUMBER ;
l_msg_data VARCHAR2(400) ;
L_FORMULA_DETAIL_TBL GMD_FORMULA_DETAIL_PUB.FORMULA_UPDATE_DTL_TBL_TYPE;
— l_formula_head fm_form_mst_b%rowtype;
L_FORMULA_LINE FM_MATL_DTL%ROWTYPE;
— i pls_integer := 1;
NO_PROC_FINISH EXCEPTION ;
BEGIN
IF (P_FORMULA_ID IS NULL) THEN
P_MESSAGE := ‘ P_formula_id parameter can not be empty ‘;
RAISE NO_PROC_FINISH;
END IF ;
— получаем данные заголовка
BEGIN
SELECT *
INTO l_formula_head
FROM fm_form_mst_b fm
WHERE fm.formula_id = p_formula_id;
EXCEPTION
WHEN OTHERS THEN
p_message := ‘ Unable to find a formula ‘;
raise no_proc_finish;
END ;
— get the data string formula
BEGIN
SELECT *
INTO l_formula_line
FROM fm_matl_dtl fm
WHERE fm.formulaline_id = p_formulaline_id;
EXCEPTION
WHEN OTHERS THEN
p_message := ‘ Could not find a string formula ‘;
raise no_proc_finish;
END ;
gme_common_pvt.set_who;
l_formula_detail_tbl(i).RECORD_TYPE := ‘D’;
l_formula_detail_tbl(i).formula_id := p_formula_id;
l_formula_detail_tbl(i).formula_no := l_formula_head.formula_no;
l_formula_detail_tbl(i).formula_vers := l_formula_head.formula_vers;
l_formula_detail_tbl(i).formulaline_id := p_formulaline_id;
GMD_FORMULA_DETAIL_PUB.DELETE_FORMULADETAIL( P_API_VERSION => L_API_VERSION, P_INIT_MSG_LIST => L_INIT_MSG_LIST, P_COMMIT => L_COMMIT, P_CALLED_FROM_FORMS => L_CALLED_FROM_FORMS, X_RETURN_STATUS => L_RETURN_STATUS, X_MSG_COUNT => L_MSG_COUNT, X_MSG_DATA => L_MSG_DATA, P_FORMULA_DETAIL_TBL => L_FORMULA_DETAIL_TBL );
IF l_return_status != FND_API.g_ret_sts_success THEN
IF l_msg_count = 1 THEN
p_message := FND_MSG_PUB.get(1,’F’);
RAISE no_proc_finish;
ELSE
FOR l IN 1..l_msg_count
LOOP
FND_MSG_PUB.get (p_msg_index => l ,p_encoded => ‘F’ ,p_data => p_message ,p_msg_index_out => l_msg_count);
END LOOP ;
RAISE no_proc_finish;
END IF ;
END IF ;
p_return_status := ‘S’;
EXCEPTION
WHEN no_proc_finish THEN
p_return_status := ‘ E ‘;
WHEN OTHERS THEN
p_message := SQLERRM ;
p_return_status := ‘ E ‘;
END ;
How to use GMD_FORMULA_DETAIL_PUB.Update_FormulaDetail?
Hi Krishna,
Hope this might help you.
procedure update_formuladetail (p_formula_id NUMBER,
p_formulaline_id NUMBER,
p_new_qty NUMBER
p_return_status OUT VARCHAR2,
p_message OUT VARCHAR2) is
l_api_version CONSTANT NUMBER : = 2.0;
l_init_msg_list VARCHAR2 (1): = FND_API.G_TRUE;
l_commit VARCHAR2 (1): = FND_API.G_FALSE;
l_called_from_forms VARCHAR2 (10): = ‘NO’;
l_return_status VARCHAR2 (1);
l_msg_count NUMBER ;
l_msg_data VARCHAR2 (400);
l_formula_detail_tbl GMD_FORMULA_DETAIL_PUB.formula_update_dtl_tbl_type;
–
l_formula_head fm_form_mst_b% rowtype;
l_formula_line fm_matl_dtl% rowtype;
–
i pls_integer: = 1;
no_proc_finish exception ;
begin
if (p_formula_id is null) then
p_message: = ‘ The p_formula_id parameter cannot be empty ‘;
raise no_proc_finish;
end if ;
begin
select * into l_formula_head
from fm_form_mst_b fm where fm.formula_id = p_formula_id;
exception
when others then
p_message: = ‘ Could not find formula ‘;
raise no_proc_finish;
end ;
begin
select * into l_formula_line
from fm_matl_dtl fm where fm.FORMULALINE_ID = p_formulaline_id;
exception
when others then
p_message: = ‘ Could not find formula line ‘;
raise no_proc_finish;
end ;
gme_common_pvt.set_who;
l_formula_detail_tbl (i) .formula_id: = p_formula_id;
l_formula_detail_tbl (i) .formula_no: = l_formula_head.formula_no;
l_formula_detail_tbl (i) .formula_vers: = l_formula_head.formula_vers;
l_formula_detail_tbl (i) .formulaline_id: = p_formulaline_id;
l_formula_detail_tbl (i) .QTY: = p_new_qty;
gmd_formula_detail_pub.update_formuladetail (
p_api_version => l_api_version,
p_init_msg_list => l_init_msg_list,
p_commit => l_commit,
p_called_from_forms => l_called_from_forms,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
p_formula_detail_tbl => l_formula_detail_tbl
);
if l_return_status <> FND_API.g_ret_sts_success THEN
if l_msg_count = 1 THEN
p_message: = FND_MSG_PUB.get (1, ‘ F ‘);
RAISE no_proc_finish;
else
for l in 1..l_msg_count loop
FND_MSG_PUB.get (p_msg_index => l
, p_encoded => ‘ F ‘
, p_data => p_message
, p_msg_index_out => l_msg_count);
end loop ;
RAISE no_proc_finish;
end if ;
end if ;
p_return_status: = ‘ S ‘;
exception
when no_proc_finish then
p_return_status: = ‘ E ‘;
when others then
p_message: = SQLERRM ;
p_return_status: = ‘ E ‘;
end ;
Thanks
Thanks Velmurugan, but I need to update with below condition –
update fm_matl_dtl md
set release_type = 1
where line_type = -1
and release_type = 0
and formula_id in (select formula_id from apps.fm_form_mst fm where fm.formula_status in(700,900));
Like I want to know how can I add more conditions?
Many thanks!