Customizing STACK TRACE for XSS Components
I came across these requirements for couple of implementations and seem to be common. In this blog I have tried to consolidate all information.
Possible ways depending upon your requirements:
-
Disabling the stack trace
-
Collapsing the stack trace
-
Customized message
Disabling the stack trace: Login to Visual Admin: Services ->”Configuration Adapter” -> “webdynpro” -> “sap.com” -> tc~wd~dispwda” ->”Propertysheet default” -> “DevelopmentMode”, make it “False”, verbose error messages will not be shown.
Property:
Result:
Collapsing the stack trace: This is useful as it also contains the information of the user who has locked the service in the tray header. Here we simply collapse the tray, so the stack trace still remains intact which can be used for identifying production issues. User will see the stack trace only if he expands the tray.
Prerequisite:
Add SAPPCUI_GP SC as Software component for development (versions should match your landscape), this requires:
1. CAF EU 7.00
2. DI BUILD TOOL 7.00
3. EP BUILD TOOL 7.00
4. PORTAL 7.00
5. PORTAL CORE SERVICES 7.00
6. PORTAL FRAMEWORK 7.00
7. PORTAL WEB DYNPRO 7.00
8. SAP J2EE ENGINE 7.00
9. SAP JAVA TECH SERVICES 7.00
There is a central component to display the messages:
sap.com/pcui_gp/xssutils – component: VcDebugInfo – View: DebugInfo:
UI elements “containerStack (Tray)”: set expanded=false, then the Java stack trace will be collapsed initially, but still the tray header will have the USER information.
Result:
Customized Messages: I am taking the example of most common error scenario in XSS “Service is locked (Pernr getting locked)”. Here we have to modify BLC & VAC. I thank Anil M for helping in this.
Below are two basic scenarios:
Scenario 1: Administrator (AA) trying to process the record of the user XX. At the same time, user trying to access the same component. He will get the message as “Please try again after some time, HR Administrator in process of your records.
Logged on user: XX
Admin: AA (User logged in R/3 processing the record of XX (user))
Scenario 2: One session is already active. If user trying to open the another session, we have to show up the message “Please close all active browser sessions and try again”
Logged on user: XX
User again trying to open another session of the same component.
———————————————————————————–
Code:
Changes in Address Component:
// In Component controller add this code in the readRecord () method
public void readRecord ( )
{//@@begin readRecord ()
try {
//GetInfotypeList
wdContext.nodeReadInfotype().bind((Hrxss_Per_Read_P0006_Us_Input) model.createModelObject(Hrxss_Per_Read_P0006_Us_Input.class));
wdContext.currentReadInfotypeElement().setInfty(“0006”);
wdContext.currentReadInfotypeElement().modelObject().execute();
//Custom code: added the code to display the message when the service is locked
IWDNode messageNode=wdContext.nodeReadMessages();
for (int i = 0; i<messageNode.size(); i++) {
IWDNodeElement element = messageNode.getElementAt(i);
switch (element.getAttributeValue(“Type”).toString().charAt(0)) {
case ‘I’ :
case ‘S’ :
case ‘W’ :
// ignore all warnings
break;
case ‘E’ :
case ‘A’ :
case ‘X’ :
default:
// Id PBAS_SERVICE
// Number=001: key for pernr locked error, similarly they have other keys
if (element.getAttributeValue(“Id”).equals(“PBAS_SERVICE”) && element.getAttributeValue(“Number”).equals(“001”)) {
IPublicFcPerAddressUS.IZServiceLockedElement ele= wdContext.nodeZServiceLocked().createZServiceLockedElement();
//Move the data from Business Logic Component (BLC) to Visual Application Component (VAC) through the interface controller context and then show the custom message
// create context attributes and set them
ele.setLockedFlag(“true”);// Flag if the record is locked
// existing logged on user Name through r/3
ele.setRecProcUser((String)element.getAttributeValue(“Message_V3”));
//existing logged on user ID through r/3
ele.setJcoLoggedonUser((String)element.getAttributeValue(“Message_V1”));
wdContext.nodeZServiceLocked().bind(ele);
fpm.getMessageManager().reportMessage(wdThis.wdGetAPI(),element);
}else{
IPublicFcPerAddressUS.IZServiceLockedElement ele= wdContext.nodeZServiceLocked().createZServiceLockedElement();
ele.setLockedFlag(“false”);
wdContext.nodeZServiceLocked().bind(ele);
MessageHelper.raiseException(fpm, wdThis.wdGetAPI(), wdContext.nodeReadMessages());
}
}
}
} catch (Exception ex) {
fpm.getMessageManager().raiseException(wdThis.wdGetAPI().getComponent(), ex); }
——————————————————————————————–
In the VcPerAddressUSOverview component, BIzCardView add custome code init()
public void wdDoInit()
{
//@@begin wdDoInit()
try{
//valero: get the JCo loging user
String sapUser = // get SAP Portal Logged on User for comparison with R/3 user.
String lockedUser = // User logged in thru R/3, you can pass this from BAC “Message_V3”
if((wdContext.currentZServiceLockedElement().getLockedFlag().equalsIgnoreCase(“true”))){
// If the flag for record locked it true
if(sapUser.equalsIgnoreCase(wdContext.currentZServiceLockedElement().getJcoLoggedonUser())){
// if the Portal logged in user & R/3 logged in user are same
String userlockmsg = “Please close your all your active browser sessions”;
//Create Confirmation Window
IWDConfirmationDialog confirm =wdThis.wdGetVcPerAddressUSOverviewController().wdGetAPI().getWindowManager().createConfirmationWindow(userlockmsg,wdThis.wdGetAPI().getViewInfo().getViewController().findInEventHandlers(“onActionclose”),”OK”);
confirm.setTitle(lockedUser+” session is active, Service locked”);
confirm.show();
}else{
// If the users are different
String adminlockmsg = “Please try again after some time, HR Administrator in process of your records”;
String lockedUser= wdContext.currentZServiceLockedElement().getRecProcUser();
confirm =wdThis.wdGetVcPerAddressUSOverviewController().wdGetAPI().getWindowManager().createConfirmationWindow(adminlockmsg,wdThis.wdGetAPI().getViewInfo().getViewController().findInEventHandlers(“onActionclose”),”OK”);
confirm.setTitle(lockedUser+” locked your access”);
confirm.show();
}
}catch(Exception e){ }
//@@end
}






Thanks for this useful blog. Thanks for putting togather all options..
Good Job.
Shobhan