cancel
Showing results for 
Search instead for 
Did you mean: 

executeBapi_Po_Create_Input( ) Return Code?

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

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();

}

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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