cancel
Showing results for 
Search instead for 
Did you mean: 

7.1: Handling Rejections in the Client

Former Member
0 Kudos

This relates to NW Mobile 7.1, development for PDAs, NWDS SP05 P01

Dear all,

how do I handle rejections? How do I get notified, that there was a rejection?

any example code?

My current code always returns an empty collection of Rejections. But in the debug log, I can see that a new row was rejected (as intended) because of a duplicate key.

This is the debug trace entry:


<r id="1216650430989" t="16:27:10" d="2008-07-21" s="D" c="000" u="ZKIAGE" g="en" 
m="INSERT INTO CFS_ERROR_SEGMENT VALUES
( &apos;D5BFDCDE9C96D4EA0000011B460449F8&apos;, &apos;FDF710B6A688DF360000011B46044A08&apos;, 
&apos;000C293640701DED95E6167A69FD551C&apos;, &apos;1216650267&apos;, &apos;E&apos;, 
&apos;BGMSG&apos;, NULL,&apos;I:BGMSG:000 Equip already exists.&apos;,NULL,NULL,&apos;Equip already exists.&apos;,
NULL,NULL,NULL,NULL,NULL,NULL,&apos;MIDCLNT200&apos;)">
<f n="LocationName" v=" (com.sap.tc.mobile.cfs.pers.PersistenceManagerImpl:execute)"/>
<f n="ThreadName" v="Thread-12"/>
</r>

The rejected row is removed from my client.

This is the code that checks for the rejection. I am calling it in the wdInit() method of my initial screen. It always returns "count: 0":


	/**
	 * Method [getRejections].
	 */
	 	public void getRejections() {
//@@begin getRejections()
 	       Rewe1_scModel model = (Rewe1_scModel) OcaRoot.getInstance().getModel(Rewe1_scModel.class);
	       SyncManager syncMgr = OcaRoot.getInstance().getSyncManager();
	       RejectionRepository rejrep = syncMgr.getRejectionRepository();
	       Collection rejections = rejrep.getRejections( (OcaModel) model ) ;

	       logger.debug( this.getClass(), "AGE: getRejections count: " + rejections.size());

	       Iterator rejIter = rejections.iterator();
	       while (rejIter.hasNext()) {
	           Rejection rej = (Rejection) rejIter.next();
	           Iterator rejInfoIter = rej.getRejectionInfos();
	           while (rejInfoIter.hasNext()) {
	               RejectionInfo rejInfo = (RejectionInfo) rejInfoIter.next();
	               logger.debug( this.getClass(), "AGE: getRejections MessageText: " + rejInfo.getMessageText());
	           }
	       }
	       
//@@end
	}

What's wrong here?

Cheers, Andre

Accepted Solutions (1)

Accepted Solutions (1)

stefan_henke
Contributor
0 Kudos

Hi Andre,

did you setup the client again and synced the data again? If you just rebuild the components and deploy them, the new DO metadata (changes in conflict handling) is not registered. Only if you specify to "Reset the client DB". Could you doublecheck this? If the issue still persists, could you create an OSS message? This will help us to track it as an issue and provide you official help.

Regards,

Stefan

Answers (5)

Answers (5)

Former Member
0 Kudos

Here is a little bit of (dirty) code that might help to develop rejection handling logic ...


	/**
	 * Method [getRejections].
	 */
	 	public java.lang.String getRejections() {
//@@begin getRejections()
	 	    String messages = "";
	 	    String msg;
	 	    
	 	   Rewe1_scModel model = (Rewe1_scModel) OcaRoot.getInstance().getModel(Rewe1_scModel.class);
	       SyncManager syncMgr = OcaRoot.getInstance().getSyncManager();
	       RejectionRepository rejrep = syncMgr.getRejectionRepository();
	       Collection rejections = rejrep.getRejections( (OcaModel) model ) ;
	       logger.debug( this.getClass(), "AGE: getRejections count: " + rejections.size());
	       Iterator rejIter = rejections.iterator();
	       while (rejIter.hasNext()) {
	           msg = "";
	           Rejection rej = (Rejection) rejIter.next();
	           logger.debug( this.getClass(), "AGE: getRejections State: " + rej.getRejectionState());
	           Iterator rejInfoIter = rej.getRejectionInfos();
	           while (rejInfoIter.hasNext()) {
	               RejectionInfo rejInfo = (RejectionInfo) rejInfoIter.next();
	               logger.debug( this.getClass(), "AGE: getRejections getMessageText: " + rejInfo.getMessageText());
	               logger.debug( this.getClass(), "AGE: getRejections getErrorId: " + rejInfo.getErrorId());
	               logger.debug( this.getClass(), "AGE: getRejections getMessageNumber: " + rejInfo.getMessageNumber());
	               logger.debug( this.getClass(), "AGE: getRejections getMessageType: " + rejInfo.getMessageType());
	               logger.debug( this.getClass(), "AGE: getRejections getMessageVariable1: " + rejInfo.getMessageVariable1());
	               logger.debug( this.getClass(), "AGE: getRejections getParameterName: " + rejInfo.getParameterName());
	               msg = msg.concat( rejInfo.getMessageText() + ": ");
	               
	           }
	           Iterator rejNodesIter = rej.getRejectedNodes();
	           while (rejNodesIter.hasNext()) {
	               RejectedNode rejNode = (RejectedNode) rejNodesIter.next();
	               logger.debug( this.getClass(), "AGE: getRejections Node: " + rejNode.getClass());
	               logger.debug( this.getClass(), "AGE: getRejections ClientVersion: " + rejNode.getClientVersion().getClass());
	               if (rejNode.getClientVersion() instanceof EquipEquip  ) {
	                   logger.debug( this.getClass(), "AGE: getRejections !! EquipEquip !! ");
	                   EquipEquip rejEquip = (EquipEquip) rejNode.getClientVersion();
	                   logger.debug( this.getClass(), "AGE: getRejections Equip: " + rejEquip.getMarketNr() + "/" + rejEquip.getEquipNr());
	                   msg = msg.concat( rejEquip.getMarketNr() + "/" + rejEquip.getEquipNr() );
	               }
	           }
	           
               if( rej.getRejectionState().equals( RejectionState.INITIAL) ) {
    	           // we always take the client version, so that the user can fix it
    	           //rej.acceptClientVersion();
               }
               logger.debug( this.getClass(), "AGE: getRejections msg: " + msg);
	           messages = messages.concat( "\n" + msg );
	       }
	       logger.debug( this.getClass(), "AGE: getRejections messages: " + messages);
	       return messages;
//@@end
	}

Former Member
0 Kudos

typo ... that DID it

Former Member
0 Kudos

and the Oscar goes to ... Stefan

Thanks, that die it. I got the Rejection from the Repository and it returns exactly the right message text.

The incorrect row is still there.

Perfect.

Thanks, Andre

Former Member
0 Kudos

Hi Stefan,

very very good information, but it dod not solve the problem so far.

I changed the column "Conflict Resolution" to manual for the Data Node, where I want to do my own handling and rebuilt the client.

Still the same behaviour. Maybe I am calling my handler at the wrong time (too late)?

in the debug log I can see the following records with the same PSYNCHkey=FE872B1D067429B00000011B4F6B06D8:


<r id="1216808158955" t="12:15:58" d="2008-07-23" s="D" c="000" u="ZKIAGE" g="en" 
m="INSERT INTO CFS_REJECTED_NODE VALUES (&apos;FE872B1D067429B00000011B4F6B06D8&apos;,&apos;7D19150F487AC54C0000011B4F6B06E8&apos;,
&apos;605C3DDB2A2A5F3D0000011B4F67233D&apos;,
&apos;EQUIP$EQUIP&apos;,&apos;FEF5000000000000&apos;)">
<f n="LocationName" v=" (com.sap.tc.mobile.cfs.pers.PersistenceManagerImpl:execute)"/>
<f n="ThreadName" v="Thread-12"/>
</r>
<r id="1216808158968" t="12:15:58" d="2008-07-23" s="D" c="000" u="ZKIAGE" g="en" 
m="INSERT INTO CFS_ERROR_SEGMENT VALUES (&apos;FE872B1D067429B00000011B4F6B06D8&apos;,&apos;34835BD748F9E1EA0000011B4F6B06F8&apos;,
&apos;000C293640701DED9694034D5FA5951C&apos;,
&apos;1216808056&apos;,&apos;E&apos;,&apos;BGMSG&apos;,NULL,&apos;I:BGMSG:000 Equip already exists.&apos;,
NULL,NULL,&apos;Equip already exists.&apos;,
NULL,NULL,NULL,NULL,NULL,NULL,&apos;MIDCLNT200&apos;)">
<f n="LocationName" v=" (com.sap.tc.mobile.cfs.pers.PersistenceManagerImpl:execute)"/>
<f n="ThreadName" v="Thread-12"/>
</r>
<r id="1216808158969" t="12:15:58" d="2008-07-23" s="D" c="000" u="ZKIAGE" g="en" 
m="SELECT * FROM CFS_REJECTED_NODE WHERE PSYNCKEY=&apos;FE872B1D067429B00000011B4F6B06D8&apos;">
<f n="LocationName" v=" (com.sap.tc.mobile.cfs.pers.PersistenceManagerImpl:execute)"/>
<f n="ThreadName" v="Thread-12"/>
</r>
...
<r id="1216808158988" t="12:15:58" d="2008-07-23" s="D" c="000" u="ZKIAGE" g="en" m="DELETE FROM CFS_REJECTED_NODE WHERE PSYNCKEY=&apos;FE872B1D067429B00000011B4F6B06D8&apos;">
<f n="LocationName" v=" (com.sap.tc.mobile.cfs.pers.PersistenceManagerImpl:execute)"/>
<f n="ThreadName" v="Thread-12"/>
</r>
...
<r id="1216808158990" t="12:15:58" d="2008-07-23" s="D" c="000" u="ZKIAGE" g="en" m="DELETE FROM CFS_REJECTED_NODE WHERE PSYNCKEY=&apos;FE872B1D067429B00000011B4F6B06D8&apos;">
<f n="LocationName" v=" (com.sap.tc.mobile.cfs.pers.PersistenceManagerImpl:execute)"/>
<f n="ThreadName" v="Thread-12"/>
</r>
<r id="1216808158991" t="12:15:58" d="2008-07-23" s="D" c="000" u="ZKIAGE" g="en" m="DELETE FROM CFS_ERROR_SEGMENT WHERE PSYNCKEY=&apos;FE872B1D067429B00000011B4F6B06D8&apos;">
<f n="LocationName" v=" (com.sap.tc.mobile.cfs.pers.PersistenceManagerImpl:execute)"/>
<f n="ThreadName" v="Thread-12"/>
</r>
<r id="1216808158992" t="12:15:58" d="2008-07-23" s="D" c="000" u="ZKIAGE" g="en" m="DELETE FROM CFS_REJECTION WHERE SYNCKEY=&apos;FE872B1D067429B00000011B4F6B06D8&apos;">
<f n="LocationName" v=" (com.sap.tc.mobile.cfs.pers.PersistenceManagerImpl:execute)"/>
<f n="ThreadName" v="Thread-12"/>
</r>

There is an insert at the sync time and then some error handling which deletes the rows again.

This is definitely not done by my code, which is called much much later.

I will do some more research, but it would be great to know the best time to call the error handler. From the training I seem to remember that I have to register a Listener, but I cannot find any APIs for that in the docs.

Cheers, Andre

stefan_henke
Contributor
0 Kudos

Hi Andre,

did you specified manual rejection handling for the DO nodes ? This has to be done in the DO editor in order to get the confilcts when browsing the repository. The column is called "Conflict handling". If it is set to "automatic", you will always get a count of 0. Maybe this is the missing piece for you.

Please set the handling to "manual" and check it again.

Regards,

Stefan