When creating an OBN link, you can specify that the navigation target that is selected at runtime be from the same role that contains the source iView.
For more information about creating an OBN link, see Creating an OBN LInk.
When creating the IOBNMetadata object for creating an OBN link, add a parameter that specifies that you want to navigate only within the current role, that is, the role that contains the iView that contains the OBN link.
// Create the OBN factory
IOBNService obnService = (IOBNService) WDPortalUtils
.getServiceReference(IOBNService.KEY);
OBNFactory obnFactory = obnService.getObjectsFactory();
// Create an OBN metadata object (this example is for Web Dynpro)
IOBNMetadata obnMetaData = obnFactory
.createOBNMetadata("myBO","","myOp",
WDClientUser.getCurrentUser().getSAPUser());
// Create an OBN parameter for source role navigation
String navModeName = com.sap.portal.obn.service.IOBNConstants.IOBNUrl
.IParameters.NAVIGATION_PARAM_NAVIGATE_MODE;
String navModeValue = com.sap.portal.obn.service.IOBNConstants.IOBNUrl
.IParameters.IParametersValues.NAVIGATE_MODE_SOURCE_ROLE;
IOBNParameterData sourceNavModeParam = myOBNFactory
.createOBNParameterData(navModeValue);
// Add parameter to OBN metadata
myMetaData.setParameter(navModeName , sourceNavModeParam);