Begin
IF nvl(mv_xyz_id,'A') = 'A' then
if (nvl(mv_rec.sec_b_id,'B') <> 'B') and (mv_rec.sec_b_id_type = 'XYZ') then
m_b_end_date_2 := to_char(sysdate-1,'YYYYMMDD');
end if;
Else
if (nvl(mv_rec.sec_b_id,'B') <> 'B') and (mv_rec.sec_buid_id_type = 'XYZ') then
if mv_rec.pri_b_id <> mv_abc_id then -- IF not for the same BU
m_b_end_date_2 := to_char(sysdate-1,'YYYYMMDD');
end if;
else
mv_message :='ADD NEW XYZ USING THE SYSDATE';
m_b_2 := mv_rec.sec_b_id;
m_b_type_2 := mv_rec.sec_b_id_type;
m_buid_start_date_2 := to_char(sysdate,'YYYYMMDD');
end if;
END IF;
End;
ELSE
IF nvl(mv_xyz_id,'A') = 'A' then
if (nvl(mv_rec.sec_b_id,'B') <> 'B') and (mv_rec.sec_b_id_type = 'XYZ') then
m_b_end_date_2 := to_char(sysdate-1,'YYYYMMDD');
end if;
Else
if (nvl(mv_rec.sec_b_id,'B') <> 'B') and (mv_rec.sec_buid_id_type = 'XYZ') then
if mv_rec.pri_b_id <> mv_abc_id then -- IF not for the same BU
m_b_end_date_2 := to_char(sysdate-1,'YYYYMMDD');
end if;
else
mv_message :='ADD NEW XYZ USING THE SYSDATE';
m_b_2 := mv_rec.sec_b_id;
m_b_type_2 := mv_rec.sec_b_id_type;
m_buid_start_date_2 := to_char(sysdate,'YYYYMMDD');
end if;
END IF;
End;
ELSE