on 11-28-2006 7:26 PM
Hi,
I am using executeBapi_Po_Create_Input( ) Currently the signature is void. Is there any way to get a return code from this method so that I know the execution was successful? how can we tell if the execution was successful?
Thanks.
hi
Your Bapi model classes will have two nodes Bapi_input and Bapi_output,under
Bapi_input->output->return->message will be there
write this code in after executing the bapi
msg.reportSuccess(wdContext.nodeBapi_input.nodeOutput.nodereturn.currentreturnelement.getMessage);
Regards
Nidhideep
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks to all for the replies.
Here is the solution implemented showing how the fields I needed were obtained.
public void executeBapi_Po_Create_Input( )
{
wdContext.currentBapi_Po_Create_InputElement().modelObject().execute();
wdContext.nodeOutput().invalidate();
String sPoNumber = wdContext.currentOutputElement().getPurchaseorder();
String messageType = wdContext.currentReturnElement().getType();
}
When you do the context mapping between model and controller, map all the context structures in BAPI_PO_CREATE. one of the structures would be return. This is how you can access this node: <b>wdContext.nodeReturn()</b> assuming you have not renamed the return structure.
After your catch block you can have something like this
/** Check for errors while executing the BAPI*/
boolean flagChangeError = false;
String msg="";
for(int i=0;i < wdContext.nodeReturn().size();i++){
if(wdContext.nodeReturn().getElementAt(i).getAttributeAsText("Type").equalsIgnoreCase("E")){
msg = wdContext.nodeReturn().getElementAt(i).getAttributeAsText("Message")"\n";
flagChangeError = true;
}
}
/** If there were no errors commit the Changes*/
/** Display the BAPI output*/
if(!flagChangeError){
//successful
}else{
//unsuccessfull
}
Hope it helps
Peace
Message was edited by:
Firasath Riyaz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bapi_Po_Create returns a table (structure) of messages after the execution, loop through this table and check the type field in the table for a value "E". If any of the rows contain E as the type then you can conclude that there was some problem in the bapi execution, if not it was successful. Hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply Firasath. How do I get a handle to that table/structure? What type of reference variable?
Here is the complete method I am using:
public void executeBapi_Po_Create_Input( )
{
//@@begin executeBapi_Po_Create_Input()
try {
wdContext.currentBapi_Po_Create_InputElement().modelObject().execute();//?
wdContext.nodeOutput().invalidate();
} catch (Exception e) {
e.printStackTrace();
}
//@@end
}
Thanks.
Hi,
Try this:
public void executeBapi_Po_Create_Input( )
{
//@@begin executeBapi_Po_Create_Input()
IWDMessageManager msg = wdComponentAPI.getMessageManager();
try {
wdContext.currentBapi_Po_Create_InputElement().modelObject().execute();
if(wdContext.currentBapi_Po_Create_InputElement().nodeOutput().nodeReturn().currentReturnElement().getType() != null){
msg.reportWarning(wdContext.currentBapi_Po_Create_InputElement().nodeOutput().nodeReturn().currentReturnElement().getMessage());// displays either success or error message.
}
}
catch (Exception e) {
e.printStackTrace();
}
//@@end
}
Return data is in table format but u can display it without loop also
This may be helpful.
Regards,
Aparna .P
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.