cancel
Showing results for 
Search instead for 
Did you mean: 

Stop Xacute-query on Web Page

Former Member
0 Kudos

Greetings!

I have created a web page to work with MII transactions via browser. One of web page components is iCommand applet which invokes transaction. Applet is using Xacute-query. "OnClick" event, generated by special button, starts the query.

There I have faced a problem: while the query is running any other actions on web page can not be executed. In most cases this sutuation is good, but sometimes the query must be stopped manually, for example if input data is incorrect.

Question: what event or function should I use to stop Xacute-query from a web page?

Thank you!

Best Regards,

Vitaliy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Vitaly, there is already quite a fair bit on asynchronous call to transaction:

http://scn.sap.com/message/8097641

though you can not stop it if you are using the aynchronous message service, the user will not be impacted.

Another method is also to call the transaction through an XMLHttpRequest.

You can do this call and call the transaction to be executed asynchronously by MII, after returning an ID which will enable you to track the transaction and also to stop it.

In order to do so you will have to do the following:

1. Run the transaction by calling the following URL, This returns a transaction ID that you can reuse in the URL after:
/XMII/Runner?Transaction=<MY-FOLDER>/LongRunningTransaction&IsAsync=true&LogType=Info

2. You can use the following URL which will give you details on the current Status of the Transaction
/XMII/Illuminator?Service=BLSManager&Mode=Details&ID=<ID Returned by the previous call>

3. Then you call this URL in order to Terminate the transaction:
/XMII/Illuminator?Service=BLSManager&Mode=Terminate&ID

=<ID Returned by the previous call>

For information on how to call url directly in Javascript look at the following website:

http://www.w3schools.com/xml/xml_dom.asp

Cheers,

Arnaud

Former Member
0 Kudos

Hello Arnaud!

Thank you a lot for your reply, it is very helpful! With the help of your approach I have successfuly run transaction via browser.

But can you please clerify the following: what is transaction ID and how can I get it to execute points 2 and 3 from your post?

Thank you for your time!

Regards,

Vitaliy

Former Member
0 Kudos

Hello Vitaliy, if you look at the xml returned when you run the transaction through the url, you will see an XML attribute named transaction ID. This is the unique identifyer of your transaction.

You can then use this id in the subsequent urls.

Regards,

Arnaud

Answers (1)

Answers (1)

Former Member
0 Kudos
Hello Vitaly, if you look at your other post : http://scn.sap.com/thread/3263860
you can add the following code at the end. This will enable you to retrieve the status of your transaction and to stop it.
Note that you will need to change 2 things in the initial code of the other post:
1. Make the call to the transaction asynchronous with IsAsync flag to true
2. Remove the part in the javascript which reads the resutl, not possible anyore and will actually have the javascript failing.
Cheers Arnaud
// Display info
function info(){
var serviceUrl = "/XMII/Illuminator?Service=BLSManager&Mode=Details&ID=" + currTrxId + "&Content-Type=text/XML";
var returnedXML = getXML(serviceUrl);
status = returnedXML.getElementsByTagName('STATUS')[0].text;
alert("Info : " + status);
}
// Function to Stop the Trx defined in the javascript Variable Transaction Id: currTrxId
function stopTrx(){
if(currTrxId != -1){
  var serviceUrl = "/XMII/Illuminator?Service=BLSManager&Mode=Terminate&ID=" + currTrxId + "&Content-Type=text/XML";
  var returnedXML = getXML(serviceUrl);
  alert("Request to terminate the transaction sent : " + returnedXML.xml);
}else{
  alert('no Running Transaction');
}
}
Former Member
0 Kudos

Hi Arnaud,

Thank you a lot for your help! I've gathered a lot of new knowledge while trying to implement the suggested method!

I've made some progress, so now I am able to do the following:

1. Run the TRX asynchronously with some input parameters;

2. Get the ID of currently running TRX.

But unfortunately, some points are still unclear for me.

The First. While I'm trying to get responseXML I can not receive anything. For example, executing  alert(returnedXML.xml) returns empty window, so I am not able to use any output parameter. I am using the code you listed. Maybe there is something wrong in TRX outputs configuration?

The Second. While trying to catch TRX ID I'm constantly receiving the next error:

'getElementsByTagName(...).0' -  is null or not an object 

In case I add the string alert("XML Doc: " + returnedXML.xml) before

currTrxId= returnedXML.getElementsByTagName('Rowsets')[0].getAttribute('TransactionID');

everything works fine, but there is an unwanted alert window.

Can you please help me to resolve listed issues?

Thank you for your time!

Best Regards,

Vitaliy

Former Member
0 Kudos

Hello Vitaliy, nice to hear that you are moving forward.

I'm thinking that this can be related to the fact that you are still trying to read the output parameter when you run the transaction asynchronously.

Try to call this function in your async scenario:

// Fuction to Call the Trx defined in the Javascript Variable at the end

function startTrxAsync(){

var url = "/XMII/Runner?Transaction=" + currTrxFullPath + "&Content-Type=text/XML&IsAsync=true&LogType=Info";

var returnedXML = getXML(url);

alert("XML Doc: " + returnedXML.xml); // Display the Full XML Element

currTrxId= returnedXML.getElementsByTagName('Rowsets')[0].getAttribute('TransactionID');

alert("Transaction ID: " + currTrxId); // Display the Transaction Id

}

This function also defines the content type to the MII Server,
though this was working fine for me, it could be browser dependent.

Cheers,

Arnaud

Former Member
0 Kudos

Hi Arnaud,

According to our corporate policies, we are using IE 8, IE 9. Can it cause some issues?

Best Regards,

Vitaliy

Former Member
0 Kudos

Vitaliy, normally this is not an issue, but can require some tweeking, specially compatibilty mode.

But, If you are using IE8 and IE9 you can press F12 when executing the code. Go in the script tab and click on start debugging. You can then set a break point or break at the next command and execute step by step. This will enable you to see the returned elements.

You can also check the network tab which will show you things like content-type and full message returned by the server.

Cheers,

Arnaud