cancel
Showing results for 
Search instead for 
Did you mean: 

Message manager report an exception without any words, where it comes from?

Former Member
0 Kudos

Hi guys,

A very weird exception showed in the message area, the exception has no exception, just an red icon. And I can't figure out where the exception comes from.

To locate the weird exception, I did some trace work and shows:(every line is print my IWDMessageManager.reportException().

query view onactionchange()

query view firedPlugTochange <fire the plug to change view>

query view onactionchange() return

<This line is the weird exception line>

change view wddoinit()

change view onPlugfromQuery()

initchangeview()

change view wddomodifyview()

So the weird exception occured after the plug was fired and before the change view's wdInit(). Then what happened during this period?

Can anybody help me? Thank you very much!

Regards,

Xiaoming Yang

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi all,

I appreciated everybody's help on this topic. But maybe you guys understood this problem.

The problem is the exception icon comes from nowhere! I can't locate it. It is after the plug is fired and before the target view's wdInit().

Can anybody help me figure out the problem, thank you!

Regards,

Xiaoming Yang

Former Member
0 Kudos

Xiaoming,

Exception comes from action handler. The reason why target wdDoInit is not called is that you are using

manager.reportException("message",<b>true</b>);

"true" here means "cancel navigation", so target view is never reached and hence no call to wdDoInit performed.

VS

Former Member
0 Kudos

Hi valery,

Thank you for your reply. I understand the "true" in manager.reportException("message",true) means "cancel navigation", but this line is not executed, the exception from this line is not reported. Actually the target view is definitely executed, because I can see the view and the exceptions which I have listed in my this thread.

Regards,

Xiaoming Yang

Former Member
0 Kudos

Xiaoming,

Could you try

wdThis.wdFirePlugToChange();

manager.report<b>Warning</b>("query view firedPlugTochange");

instead of

wdThis.wdFirePlugToChange();

manager.report<b>Exception</b>("query view firedPlugTochange",false);

Also change reportException to reportWarning in wdDoInit of target view.

VS

Former Member
0 Kudos

Thanks Valery,

I will try this when i get into my office. thank you!

Regards,

Xiaoming Yang

Former Member
0 Kudos

Xiaoming,

As someone pointed out you hit some run-time exception. Java exceptions like NullPointerException or ClassCastException has no error message.

So wrap exception with function below before passing it to message manager:


private static WDNonFatalRuntimeException wd_exception(final Exception ex)
{
  if ( null == ex.getLocalizedMessage() )
  {
    if ( null == ex.getMessage() )
      return new WDNonFatalRuntimeException( ex.getClass().getName() );
    else
      return new WDNonFatalRuntimeException( ex );
  }
  else
    return new WDNonFatalRuntimeException( ex );
}

VS

Former Member
0 Kudos

Hi Yang,

I guess you are catching excption inside Try/catch block. Thats why red icon without message is coming on screen.

This exception is Null pointer exception. You are trying to use some object without initializing it. This object value has null, and you are trying to call some of the methods of such object.

Can you please give the code from the method where you are firing view and the code from WDinti of the view to which plug fires.

Regards,

Bhavik

Former Member
0 Kudos

Thanks Bhavik,

I put my code here:

The action fire the plug, in QueryView:

public void onActionChange(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionChange(ServerEvent)

IWDMessageManager manager = wdComponentAPI.getMessageManager();

manager.reportException("query view onactionchange()",false);

String curEmployNumber = null;

String tripNumber = null;

try {

curEmployNumber = wdContext.currentZbapi_Trip_Check_Status_InputElement().getEmployeenumber();

tripNumber = wdContext.currentTrips_AmountElement().getTripno();

//manager.reportSuccess("trip number is:" + tripNumber);

} catch (NullPointerException npe) {

manager.reportException("ȱÉÙÌõÄ¿",true);

return;

}

String approved = wdContext.currentTrips_AmountElement().getApproved();

String account = wdContext.currentTrips_AmountElement().getAccount();

if (("3".equals(approved) && "0".equals(account)) || ("2".equals(approved) && "1".equals(account))) {

wdThis.wdGetDetailCustController().wdGetContext().

currentZbapi_Trip_Get_Details_InputElement().setEmployeenumber(curEmployNumber);

wdThis.wdGetDetailCustController().wdGetContext().

currentZbapi_Trip_Get_Details_InputElement().setTripnumber(tripNumber);

wdThis.wdGetDetailCustController().wdGetContext().

currentZbapi_Trip_Get_Details_InputElement().setCalculate_Amounts("X");

wdThis.wdGetDetailCustController().execute_BAPI_TRIP_GET_DETAILS();

wdThis.wdFirePlugToChange();

manager.reportException("query view firedPlugTochange",false);

} else {

manager.reportException("¸Ã״̬ϲ»ÔÊÐí±»ÐÞ¸Ä",true);

}

manager.reportException("query view onactionchange() return",false);

//@@end

}

ChangeView:

public void wdDoInit()

{

//@@begin wdDoInit()

IWDMessageManager manager = wdThis.wdGetAPI().getComponent().getMessageManager();

manager.reportException("change view wddoinit()",false);

//@@end

}

The exception happened after the plug is fired and before the result view's init method, where indeed the exception comes from?

Thank you!

Xiaoming Yang

Former Member
0 Kudos

Hi Xiaoming Yang,

I guess the problem is here.

curEmployNumber = wdContext.currentZbapi_Trip_Check_Status_InputElement().getEmployeenumber();

Check whether currentZbapi_Trip_Check_Status_InputElement is null or not before accessing?

Try to print the exception using "npe.getMessage()"?

Thanks and regards

RK

Yashpal
Active Contributor
0 Kudos

Hi Yang,

put all your code in a try catch block......

trycatch(Exception e){

use message manager to print the object e......

}

using this u can find where exception is present and whats the message of exception...

Yash

Former Member
0 Kudos

Hi,

Put ur code in try and catch block.

try {

.....

.....

.....

} catch (Exception e){

wdComponentAPI.getMessageManager().reportException("Error: "+e.toString(),false);

}

This will print the exception.

Regards,

Piyush.