cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Need to Popup error in HTML from BLT

Former Member
0 Kudos
317

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

Accepted Solutions (1)

Accepted Solutions (1)

abesh
Contributor
0 Kudos

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 !

Former Member
0 Kudos

thanks,

It was really helpful. But i can you please give little more idea on how to get value from Xcute query to HTML.

if i am using <b>String getValue(int ColID, int RowID)</b> , wht can be ColID and Row here?

i am using IGRID. Do i need to use icoomand instead?

Thanks in advance

Muzammil

abesh
Contributor
0 Kudos

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

Answers (2)

Answers (2)

jamie_cawley
Product and Topic Expert
Product and Topic Expert
0 Kudos

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.

Former Member
0 Kudos

Jamie,

Assigning to IllumDoc in BLT is fine. but how can i display it in my HTML using IGRID?

please clarify

Thanks in advance

Muzammil

jamie_cawley
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

}

Former Member
0 Kudos

Hi,

I am using Xacute Query.

document.MyApplet.<b>executeCommand</b>() wont work for Xacute Query rite?

more help will really be appreciated

thanks in advance

Muzammil