cancel
Showing results for 
Search instead for 
Did you mean: 

IllegalStateException's

Former Member
0 Kudos

Dear all,

When reviewing some trace files of some of our technicians that are using the MAM, I did notice the following error message quite often:


com.sap.mbs.core.api.BOException: Failed inserting Mam010Item080: java.lang.IllegalStateException: State NEW does not allow this transition: clnAdd
	at com.sap.mbs.mam.bo.impl.Mam010ManagerImpl.insertMam010Item080(Mam010ManagerImpl.java:3263)

We are using an item on the notification to save 'internal comments' in. It seems to occur when (sometimes?) saving an internal comment (Mam010Item080 is a notification item).

Until now I didn't get a message from the backoffice that internal comments are missing, but I am a bit worried about this error (I don't think it is normal). Does anyone know why and when this error occurs and how to solve it?

This is the code that should save the internal comments (and sometimes gives this error message):


// Variable declaration
String newComments = null;
BOList newCommentsList = null;
BOList manipulateLongtextList = null;
Context context = null;
Mam010Manager manager = null;
Mam010 notification = null;
Mam010Item080 internalCommentsItem = null;
NotificationComponent notificationComponent = null;
NotificationCustomController notificationCustomController = null;

// Start up the notification manager
manager = (Mam010Manager)naming.lookup(Mam010Manager.class.getName());

// Get notification custom controller
notificationComponent = (NotificationComponent)getComponent().getApplication().getComponent("notification");
notificationCustomController = notificationComponent.getNotificationCustomController();

// Get context
context = getContext();

// Get values from context
newComments = (String) context.getValue(ctx_from_longTextNew);

// if nothing to save...
if ( newComments == null || newComments.trim().equals("") )
	return false;
	
// Get notification
notification = notificationCustomController.getSelectedNotification();

// Get item where internal comments are saved
internalCommentsItem = (Mam010Item080)notificationCustomController.getManipulateObject();

// Let's save the stuff
// Split the new comments into seperate lines and put them in a list
newCommentsList = NotificationHelper.setItemLongText(notification, internalCommentsItem, newComments.trim());
notificationCustomController.setManipulateLongtext(newCommentsList);

if	( (notificationCustomController.getManipulateLongtext() != null && ((BOList)notificationCustomController.getManipulateLongtext()).size() > 0) ||
	  (notificationCustomController.getLongtextLocked() != null && ((BOList)notificationCustomController.getLongtextLocked()).size() > 0) )
	internalCommentsItem.setLongText("X");
else
	internalCommentsItem.setLongText("");

//let's update data in DB
if ( notificationCustomController.getManipulateMode().equals(PropertyMgr.getProperty("NEW")) )
{
	internalCommentsItem.setItemSortNo(internalCommentsItem.getItemKey());
	manager.insertMam010Item080(notification, internalCommentsItem);
}
else
{
	manager.updateMam010Item080(notification, internalCommentsItem);
	
	//Delete old unlocked (editable) Longtext if it was changed (status is initial)
	manipulateLongtextList = (BOList)notificationCustomController.getManipulateLongtext();
	if (manipulateLongtextList != null && manipulateLongtextList.size() > 0 && manipulateLongtextList.get(0).getSyncStatus() == BusinessObject.STATUS_INITIAL )
	{
		manipulateLongtextList = NotificationHelper.getItemLongtext(notification, internalCommentsItem, NotificationHelper.UNLOCKED);
		NotificationHelper.deleteLongtext(notification, manipulateLongtextList);
	}
}

if (internalCommentsItem.getLongText() != null && internalCommentsItem.getLongText().equalsIgnoreCase("X"))
{
	// Add new (non-synchronized) internal comments
	manipulateLongtextList = (BOList)notificationCustomController.getManipulateLongtext();
	
	if (manipulateLongtextList != null && manipulateLongtextList.size() > 0 && manipulateLongtextList.get(0).getSyncStatus() == manipulateLongtextList.get(0).STATUS_INITIAL )
		for (int i = 0; i < manipulateLongtextList.size(); i++)
			NotificationHelper.getNotifManager().insertMam010Item090(notification, (Mam010Item090)manipulateLongtextList.get(i));
}

Thanks in advance for your time and help!

Best regards,

Diederik Van Wassenhove

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi all,

Sorry for the late answer: the last 2 weeks we had a Chinese colleague which I had to train, so I didn't have more time to spend on this.

Anyway, thanks for the insight. I did manage to solve the issue.

The problem was however slightly different, and caused by not well programming: some variables in memory where not properly updated when calling this functionality.

Thanks for your help and knowledge!

Diederik

Former Member
0 Kudos

Hi,

have a look into your coding. You have the following line:

manager.updateMam010Item080(notification, internalCommentsItem);

It is nearly at the end of your code. The issue is: in that method, ITEM80 will be updated. Usually this is fine. But there are a few circumstances when update is not allowed on an item. One of these is, when you try to update an item that is in Sync mode. Murthy already mentioned that before.

This you can test directly inside the update method, cause there I guess the lines are missing.

In there you have something like:

Mam30010Manager mam010Manager = NotificationHelper.getNotifManager();

Mam30010 mam010 = mam010Manager.lookupMam30010(orderDetail.getMam010ID());

........

if you would like to update this item, you could get the actual sync state with:

int state = mam010.getSyncStatus();

Well, from an int you can not really see what the sate is. So there is a helper class available. With

int val = BusinessObject.STATUS_IN_SYNC

for example, you get the relevant number for the IN_SYNC state.

Based on that info it should be easy for you to fix the issue. You simply have to check, that the item you would like to update is not in state IN_SYNC.

Hope that helps!

Regsrds,

Oliver

Former Member
0 Kudos

Hi Diederik Van Wassenhove,

This error usually comes when we try to modify/delte the record when the state of the Business Object is in Sync Mode. Solution is you need put a check before editing/deleting the object.

Regards,

Murthy.

Former Member
0 Kudos

Hello Diederik,

Have the notification been saved before or is it still "in memory" ? I think it might be the reason here, any other idea?

Thank you,

Julien.