on 04-30-2008 2:27 PM
Hi folks,
I am developing a webdynpro java programm that communicate with R/3 through a RFC.
In an especif condition the ABAP program raises an "NO_DATA_FOUND" exception.
Unfortunatelly I can't catch this exception raised by ABAP.
Do you may help me?
Best wishes,
Nelson Duarte
Hi nelson,
Are you trying to retrieve any data from DB? If so you can use the structure that having the standard parameter types:
Follow the Structure BAPIRET2.
Regards
Vinod V
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vinodi V,
thank you for your answer.
No, I am not retrieving any data from DB, I got some data from R/3 using one Remote Functin Call. This RFC raises two exceptions, one called "NO_DATA_FOUND" and another called "INVALID_DATA". I have written one try-catch block in my java code but they don't "catch" those exception.
I couldn't understand what you mean with "Follow the Structure BAPIRET2", would you explain it in more basic steps?
Best wishes,
Nelson.
Hi Nelson,
You will get the error "NO_DATA_FOUND" in the back end when there are no records and you will get "INVALID_DATA" when you pass an invalid input.
BAPIRET2 structure return the error/warning/success messages if there are in the in the backend. If they are returning any messages for the above errors then you can print those messages by accessing the BAPIRET2 structure.
You can print different error/warning/success using the return structure (if they are returning any)with the following code.
IWDMessageManager msgmgr = wdComponentAPI.getMessageManager();
String msgtype = new String();
try{
// If the RFc is returning any error messages the display those messages
if(wdContext.currentReturn_outElement().getMessage()!=null){
for(int i=0; i<wdContext.node<Return_out()>.size();i++)
{
msgtype = wdContext.nodeReturn_out().getElementAt(i).getAttributeValue("Type").toString();
if(msgtype.equals("W"))
{
msgmgr.reportWarning(wdContext.currentReturn_outElement().getMessage());
}
else if(msgtype.equals("E"))
{
msgmgr.reportException(wdContext.currentReturn_outElement().getMessage(),true);
}
else
{
msgmgr.reportSuccess(wdContext.currentReturn_outElement().getMessage());
}
}
}
}catch(Exception e){
}
Or
int size = wdContext.node<Return_out()>.size();
if(size ==0){
//here you can print your own message
}
Thanks n Regards,
Jhansi Miryala
Hi Nelson,
I have tried the way you want; but unfortunately, i don't find anyway to get the abap Exception in WebDynpro in direct way.
Look at the steps that i followed:
In Function Module:
Create a structure
ZSS_RETURN_STRUC with elements
TYPE BAPI_MTYPE
MSG_NUMBER SYMSGNO
MESSAGE ZTST_CHAR100
Create a TableType ZSS_RETURN_STRUC and assign structure to it.
In Function Module Create a Export paramter name P_RETURN of associate type ZSS_RETURN_STRUC.
in source code
IF P_CUSTOMER_DATA EQ 'NO_DATA_FOUND'.
P_RETURN-ID = '001'.
P_RETURN-TEXT = 'NO_DATA_FOUND'.
* RAISE NODATA_FOUND. comment
ELSEIF P_CUSTOMER_DATA EQ 'INVALID'.
P_RETURN-ID = '002'.
P_RETURN-TEXT = 'INVALID_DATA'.
* RAISE INVALID_DATA. comment
ELSE.
MAXNO = 'EXECUTING'.
ENDIF.
In Java WD
You can import the model and the get the error message type over there with error id.
Regards
Vinod V
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.