Issue in Deleting Object via SDK

While trying to delete one of the item via SDK OR UI, i am getting the below error :

“Can not delete item: This item is a BOM component of at least one item” 

This WARNING is “APDM_DELETECOMPINUSE_WARNING” which comes where the object is in use. 

In order to handle this i tried disabling the Warning and then deleting and then tried to enable it back. But it didn’t work.  Tried API recommendation and sample code but it didn’t work. 

Posting the code below, Let me know if you see any issue with this or in case you have any alternate approach. 

try {
objLogger.debug(“—Inside DeleteItem method—–“);
obj.delete();
objLogger.info(“Object deleted now”);

} catch (APIException e) {

try {
objLogger.info(“Receieved exception while deleting. “);
objLogger.error(e.getMessage());
objLogger.error(e.getErrorCode());
if (e.getErrorCode() == ExceptionConstants.APDM_DELETECOMPINUSE_WARNING) {
m_session
.disableWarning(ExceptionConstants.APDM_DELETECOMPINUSE_WARNING);
obj.delete();
m_session
.enableWarning(ExceptionConstants.APDM_DELETECOMPINUSE_WARNING);

}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
objLogger.error(e.getMessage());
}

The logger captures 374 code as the error which is nothing but this exception only. 

Looking forward for help.

Regards,
Arif

No Files Were Attached
Arif Agile Angel Asked on September 21, 2016 in Product Collaboration.
Add Comment
1 Answer(s)

Hi Arif,
There is a Smart Rule that disallow by default to delete an item with BOM

19.2.13 Delete Instance With BOM

Settings: Allow, Disallow, Warning (default)

Should prevent accidental deletion of Instances, which already have a BOM, from the Instance tab. Deleting the Instance would lead to the loss of the Model relationship, including the Configuration Draft.

THis rule cannot be disabled by SDK so if you cannot disable the smart rule due to business reason, you have to remove BOM items before delete from sdk (item.getTable(BOM).clear();)

Antonio Agile Angel Answered on September 26, 2016.

Hi Antonio,

Thanks for the response. Actually the item is a Preliminary item with No visible BOM or Where-Used entry. Still it shows the error.  I tried Table clear approach as well, but still that error comes up. 

Regards,
Arif

on September 26, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.