cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying no Records found in webdynpro side?

Former Member
0 Kudos

Hi All ,

How to display the error message coming from R/3 side.

If iam giving input from dynproside, if no Records found in R/3 side how can I display "No records Found"in Dynpro side.

Please help me for this.

Thanks

Nageswara.

Accepted Solutions (0)

Answers (1)

Answers (1)

chintan_virani
Active Contributor
0 Kudos

Hi BB,

If i understand your question correctly the BAPI already has error message when you execute the BAPI thru ABAP.If you just want to show the BAPI message in WD you can use the MessageManager class and check the below methods and incorporate the logic for the same in your code:-

wdThis.wdGetAPI().getComponent().getMessageManager().reportException();
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess();

For second part you can use the size method to check if the Value Node contains data or not and use the MessageManager class to display the message in WD.

wdContext.nodeXXXX.size()

Regards,

Chintan Virani.

Former Member
0 Kudos

hi Chintan

Thanks for your response.I am writing this on behalf of BHI BHI.

Yes the BAPI has already the error message and we want to display the error when there are no records found for a particular input.

Can you explain me more of where to implement the method

wdContext.nodeXXXX.size()

Is the implementation to be done in the execute method of the BAPI or somewhere esle.

Thanks and regards

kris

Former Member
0 Kudos

After the execute() + invalidate() call.

Armin

Former Member
0 Kudos

Hi BB

If u r calling a bapi, u might have a context that corresponds to the BAPI. the only thing you need to do is to set that error message to the messagemanager parameter after the execute and invalidate methods.

if(wdontext.current<ResultNode>Element() == null)

wdComponentAPI.getMessageManager().reportException(<u>wdContext.current<Bapinode>element.get<messageAtribute></u>);

/* wdComponentAPI.getMessageManager()... */

the message will be diplayed on the dynpro Screen at the bottom.If u wish to get the message at the top- create a message area in the UI.

Regards

DhanyaR Nair

Former Member
0 Kudos

hi DhanyaR Nair

Thanks for ur response.

Now what I require is that, if no records are found in the backend then the first screen should not go to the second screen and display the error in the same first screen.

can you help me in this.

thanks and regards

gopi

chintan_virani
Active Contributor
0 Kudos

Hi GK,

The error message will be displayed in the first screen itself.

Create your own init method and in that put a check as not to display the next button of the screen if the BAPI call returns no result.

Regards,

Chintan Virani.

Former Member
0 Kudos

hi

I am calling the BAPI on the action of the submit button only, So after clicking the submit button only I could know whether there are records or not.

So on Action submit only I should write the implementation for the message display" no records found" if no records are returned by the BAPI.

Can you suggest me as what has to be done in regard to do that.

thanks and regards

gopi krishna

Former Member
0 Kudos

hi Armin

Can you explain me more about the syntax for displaying the error messages" No records found" and "records found".

I have implemented the code in the execute method of the BAPI in the custom controller.

int i = wdContext.nodeOutput().size();

if(i <= 0)

{

wdThis.wdGetAPI().getComponent().getMessageManager().reportException("NO Records Found",false);

//wdThis.wdFirePlugToOrderStatusResults();

}

else

{

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Records Found");

}

But it is not working properly.

has anything esle to be added to the code.

Can you guide me how to do the changes in the code.

thanks and regards

gopi krishna

Former Member
0 Kudos

In the action handler of the button,

- call a (custom/component) controller method that calls the BAPI

- check the size of the result node and use a MessageManager method to write your message

Armin

Former Member
0 Kudos

hi Armin

Thanks for your fast response.

I am not able to get over that issue.

The code which I have sent earlier had been implemented in the ExecuteBAPI method and I have called that particular executeBAPI method on the action handler of the submit button. But still it is not working.

Can you have a look at the code I sent you and let me know if anything is wrong in the code.

Action Handler method I am calling this executeBAPI

wdThis.wdGetLHPOrderStatusCustController().executeZ_Vf_CustomerResults();

And in the custom controller I have implemented the executeBAPI method as:

int i = wdContext.nodeOutput().size();

// if(i <= 0)

// {

// wdThis.wdGetAPI().getComponent().getMessageManager().reportException("NO Records Found",false);

// //wdThis.wdFirePlugToOrderStatusResults();

// }

// else

// {

// wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Records Found");

// }

Can you please tell me the exact syntax to be implemented and where.

thanks and regards

gopi krishna

Former Member
0 Kudos

Do you call "invalidate()" on the output node after the "execute()"?

Armin

Former Member
0 Kudos

hi Armin

I am calling the invalidate methid after execute method:

wdContext.currentZ_Vf_Customer_Orderstatus_List_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

If you have any code sample for the displaying of the messages, it would be of great help if u can post me that.

thanks

gopi krishna

Former Member
0 Kudos

Can you add a message manager call after the invalidate() that prints the size of the output node?

Armin

Former Member
0 Kudos

hi Armin

I have implemented the following code as suggested by you but still it seems that I am not able to get the expected results.Even though there are no results in the BAPI it is firing to the next screen and displaying "records found" when there are no records displayed.

I am using the following code.

try

{

// Calls remote function module Customer OrderList

wdContext.currentZ_Vf_Customer_Orderstatus_List_InputElement().modelObject().execute();

// Synchronise the data in the context with the data in the model

wdContext.nodeOutput().invalidate();

//if(wdContext.currentOutputElement()== null)

//wdComponentAPI.getMessageManager().reportException(wdContext.currentZ_Vf_Customer_Order_Detail_InputElement().get<messageAtribute>);

int i = wdContext.nodeOutput().size();

if(i == 0)

{

wdThis.wdGetAPI().getComponent().getMessageManager().reportException("NO Records Found",false);

//wdThis.wdFirePlugToOrderStatusResults();

}

else

{

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Records Found");

}

}

catch (Exception ex)

{

// If an exception is thrown, then the stack trace will be printed

ex.printStackTrace();

}

Plase suggest me as to what has to be done.

thanks and regards

gopi krishna

Former Member
0 Kudos

Is wdContext.nodeOutput() really mapped to the BAPI output node?

Perhaps you are getting an exception which is silently caught and written to the log.

Try (temporarily) to add the following statement into the catch-block:

catch (Exception ex)
{
  throw new WDRuntimeException(ex);
}

Armin

Former Member
0 Kudos

hi Armin

Yes the wdcontext.nodeOutput() is mapped to the BAPI output node.

I tried to implement the code you have sent to me, but still it is not working.

I have implemented the code in the custom controller, is there anything wrong in this. where this has to be implemented

thanks and regards

gopi

Former Member
0 Kudos

hi Armin

I was able to display the error message if no data was found in the database, but the message is being displayed in the second screen and not on the first screen, when I am clicking on "submit"

I require to display the messages on the first screen itself if there is data available and it should not go to the second screen.

Can you guide me in this.

thanks

gopi krishna

Former Member
0 Kudos

IWDMessageManager methods like reportException() have a parameter "cancelNavigation". If you set this to true, no navigation is executed.

Armin