Hi Jatin,
As said Mr.Sanil, please check the assignment whether the cost element is already assigned. Moreover, if you have assigned any cost element group for the assignment 30, then check the cost element exist in the cost element group. If it exists, then remove the cost element from the group and do the assignment for 40.
Regards,
Mukthar