on 2006 Dec 14 12:45 PM
Hi,
I need a help.
This is my scenario. I have a button in my HTML which calls Xacute Query which in turn calls a BLT and this BLT is calling a BAPI from R/3. There may be situations when R/3 server is down. If it is down and still i am trying to retrieve data through BAPI, i need to pop up a message in my HTML specifying the error.
Can someone help me out.
thanks in advance
Muzammil
Request clarification before answering.
When you call a BAPI through a SAP JCO Interface action bock, It returns fills in two parameters : <b>Success</b> and <b>LastErrorMessage</b>. Right click on the JCO action block and select Links to launch the link Editor. Switch to the outgoing tab and here you'll find them under the SAPJCOInterface node.
If the BAPI fails, <b>Success</b> will return a value of 0 (zero) and <b>LastErrorMessage</b> will store the error message. Create output parameters in the Transaction for both. In the QT for Xacute Query, choose * (star) in the <b>Outputs</b> tab and it should appear in the <b>Output Parameter</b> field as * (star).
Now when you run the Xacute Query through a iCommand dont call getOutputParameter but instead call the getValue method of the QueryObject to return you the messages. Use a Javascript Popup to display them if Success = 0 !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried doing it with an iCommand and it was successful. I have a SAPJCOInterface action block in a BLS transaction with which i was getting a list of Flighs using BAPI_FLIGHT_GETLIST. To simulate an error, i linked the value of the <b>SAPClient</b> parameter to a value "000" whereas my login info was for client "004". I have 2 output parameters, Success and ErrorMessage mapped to the <b>Success</b> and <b>LastErrorMessage</b> fields.
Now in Javascript I use :
document.iCommand.executeCommand();
alert("Success : " + document.iCommand.getValue(2,1));
alert("Error Message : " + document.iCommand.getValue(1,1));
and it works fine.
But beware, if you have a xMII XML document as one of your Output Parameters, choosing * (star) in the Query Template for the Output Parameters will not return it and therefore you'll need to execute the Query twice to get the return XML Document, which is not advisable.
In such a case or in all counts the method Jamie suggested is a more elegant one.
Just after the JCO Action block, add a Conditional Action Block which you'll find under the Logic tab, check for the Success field in the JCO Response, and if it's 0 (zero), add a Terminate Transaction Block and link the <b>LastErrorMessage</b> field of the JCO Response to the <b>TerminationMessage</b> field.
Now use the following code : (Borrowing from Jamie...)
if(document.MyApplet.executeCommand()){
document.grid.setQueryTemplate(document.iCommand.getQueryTemplate());
document.grid.refresh();
}else{
alert(document.iCommand.getLastError());
}
As you can very well understand, by the following line :
<b>document.grid.setQueryTemplate(document.iCommand.getQueryTemplate());</b>we're just populating the grid if the Query returns a success.
Don't forget to call <b>refresh()</b>.
I hope this helps
If using an iGrid, on the error branch of the transction use a Fatal Error action assigning it to your illumDoc. The iGrid will display this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In your transaction use the terminate transaction, which is under logic, action on the failed branch. When you call the iCommand with javascript use the following syntax
if(document.MyApplet.executeCommand())
{
alert("good");
}
else
{
alert(document.MyApplet.getLastError());
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.