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

Interacting with transactions through Web Page

Former Member
0 Likes
1,780

Greetings!

I need to create some kind of user interface for SAP MII transactions. As MII supports the usage of Web Pages, I assume that needed interface can be developed on HTML base. Basically, "Interface" means a web-page that will contain some blocks for transactions management:

  • entering transaction variables;
  • starting transaction;
  • applets for transaction results visualisation.

The main question is: How can web-page communicate with MII data?

With the help of HTML I can develop some forms where user will be able to enter transaction variables, but it's unclear for me how can I pass entered values into MII transaction variables? I am friendly with HTML and JavaScript, but can not find any solution. Maybe, I should use MII Applets for this purpose?

The second question: How can I start transaction execution on the web-page?

For examlpe, I can create button with "onClick" event, but still have no idea how to start a transaction by that event.

Can someone help me to find needed solutions? Any help, any advise and any reply will be gratly appreciated!

Best Regards,

Vitaliy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hi Vitaliy,

To answer both of your questions together, I would suggest that as you have mentioned that you can give a button and on-click of that button you can call a function which will call and execute a trx and at the same will pass variables to it.

Please see the example below:

function fnExample()

{

          var URL = "/XMII/Runner?Transaction=<full transaction path>&OutputParameter=<output variable defined in transaction>";

          URL += "&Var1=" + abc;

          URL += "&Var2=" + xyz;

          URL +="&Content-Type=<give your content type here>&IsBinary=true";

}

where Var1 & Var2 are the transaction variables and abc & xyz are the Javascript variables.

Hope this helps..

Regards,

Anuj

Former Member
0 Likes

Hi Anuj!

Thank you a lot for reply!

As I've understood, "Runner" is SAP MII servlet, wich can execute transactions and queries, developed in MII Workbench?

If that is correct, can you please show me the basic syntax of "Runner" call URL?

Thank you and please forgive my incompetence,

Best Regards,

Vitaliy

Former Member
0 Likes

Hi Vitaliy,

I am sorry but I didnt get your question exactly and if I understood it right, the syntax for the Runner is there in my example.

And yes, it can be used to execute transactions and queries developed in the MII Workbench.

Regards,

Anuj

Former Member
0 Likes

Hi Anuj,

Thank's a lot for your help! And please sorry, for unclear questions!

Best Regards,

Vitaliy

Former Member
0 Likes

Hi Anuj.

One more question: can I get the transaction output variables with the help of "Runner"? What syntax should be used for that purpose?

For example, after transaction is executed, I need to store it's result into JavaScript variable. What expression should be used to assign the transaction output value to my variable?

Thank you for your time!

Best Regards,

Vitaliy

Former Member
0 Likes

Hi Vitaliy,

To give a more detailed explanation,I am again using the example given above

var abc = "/XMII/Runner?Transaction=<full transaction path>&OutputParameter=<output variable defined in transaction>&Content-Type=xyz"

here OutputParameter  will be the variable of your transaction defined as output variable which can be String,Image,xml etc.

Now,Content-Type will decide the type of output you want to get in your display page.To list a few text/xml,image/png etc.

If you want to get the output param of the transaction,you can use text/plain as the content-type since you want to get a string variable.

so now abc = <some value>

after that you can use this js variable as you want,may be to assign to a text box or anything.

Hope it is more clear now..

Regards,

Anuj

Former Member
0 Likes

Hi Anuj,

Thanks you for being patient to me.

Does the your last reply means that variable "abc" will contain the transaction result value? It seams that var "abc" will only contain text of link "/XMII?Runner?... "

Best Regards,

Vitaliy

Former Member
0 Likes

Hi Vitaliy,

You are welcome,no worries 🙂

And yes,I myself checked for the above example and I wonder why its not working.

When I try to use Content-type as image/jpeg to display an image (which I have done several time before as well) from a transaction,it works absolutely fine.

But with text/plain even after specifying charset its not working.

I had used text/plain as well, let me see if I can find it out.

If someone who has recently worked on this, can suggest on this then will be of great help.


Regards,

Anuj

Answers (2)

Answers (2)

Former Member
0 Likes

Hello, here is a small piece of code which is displaying the following info:

- The Transaction Result as an XML from a Transaction Call

- The Transaction ID which you can then use in order to stop a transaction

- The Value of a field which is defined as an output in the Transaction.

Create a Simple button calling startTrx and define the javascript variables at the end and it is working.

Cheers,

Arnaud

<script>

// Function returning an XML from an MII Sterver

function getXML(_url){

// code for IE7+, Firefox, Chrome, Opera, Safari

if (window.XMLHttpRequest){

  xmlhttp=new XMLHttpRequest();

} else {// code for IE6, IE5

  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

}

xmlhttp.open("POST",_url,false);

xmlhttp.send();

xmlDoc=xmlhttp.responseXML;

return xmlDoc;

}

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

function startTrx(){

var url = "/XMII/Runner?Transaction=" + currTrxFullPath + "&OutputParameter=*";

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

alert("Transaction Field: " + returnedXML.getElementsByTagName(currTrxField)[0].text); // Display the Value Returned in the Field

}

// Javascript Variables;

var currTrxId = -1; // Currently Running Transaction Id

var currTrxFullPath = "<YOUR TRANSACTION PATH>"; // Full Path of the Transaction as in the WorkBench

var currTrxField = "<YOUR FIELD>"; // Field to be returnd

</script>

Former Member
0 Likes

Hi Arnaud,

Thanks for the additional inputs.I am getting the alert now 🙂 . Will have to do some more steps to get the required data.

Regards,

Anuj

Former Member
0 Likes

Hello Anuj,

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

returnedXML.getElementsByTagName(currTrxField)[0].text

and you're set,

Cheers,

Arnaud

Former Member
0 Likes

Hi Arnaud,

Thanks for the explanation.

Regards,

Anuj

Former Member
0 Likes

The solution for current thread problem was suggested by Arnaud Liotta:

http://scn.sap.com/thread/3275907

Former Member
0 Likes

Hi Vitaliy,

I went through the thread you mentioned, but it talks of asynchronous transaction call.

Getting the transaction output parameter other than image is still not clear.

Regards,

anuj

Former Member
0 Likes

Hi Ahuj,

The mentioned thread contains the information about calling transaction via link on a web-page.

To get transaction output parameters I would suggest the next approach:

  1. Mark the transaction parameters you want to get as "Output";
  2. Create Xacute-query to run the transaction you need;
  3. Insert "iCommand" Applet on a web page and set Xacute-query (created in p.2) as applets Query Template;
  4. On a web page create a JavaScript function which will contain the following:

         

          function GetTRXOutputs() {

                                                     ...

                                                      var TRXOutputValue;

                                                      document.AppletName.executeCommand();

                                                      TRXOutputValue = document.AppletName.getValue(int Col ID, int Row ID);

                                                      ...

                                                  }

Col ID and Row ID are needed value indexes in whole transaction results table.

I am successfuly using this approach. Please let me know if you need more detail inforamtion.

Best Regards,

Vitaliy

Former Member
0 Likes

Dear Vitaliy,

Getting the output of a transaction in web page using an applet (iCommand) is the conventional way we use all the time :-). The doubt was regarding directly using a transaction to get the output in web page.

Will have to search on that.

Anyways, thanks for your input!!

Regards,

Anuj

Former Member
0 Likes

Hello Anuj,

To give a bit more details on the thread; if you suppress the IsAsync paramter in the Url and put the Parameter OutputParameter=* at the end, the transaction then run synchronously and return all the information.

the url being then:

/XMII/Runner?Transaction=<MY-TRANSACITON FULLPATH>&LogType=Info&OutputParameter=*

Therefore enabling you to do the call of a syncrhonous transaction directly from javascript with the XMLHttpRequest. (http://www.w3schools.com/xml/xml_dom.asp for more info on that)

You can then use the result returned by the transaction directly in your javascript.

Regards,

Arnaud

Former Member
0 Likes

Hi Arnaud,

I tried giving 

"/XMII/Runner?Transaction=Test/Transactions/trx_TestImage&LogType=Info&OutputParameter=Output1" but it is also not giving the output and taking this complete thing as a string.

Initially also I had tried giving

"/XMII/Runner?Transaction=Test/Transactions/trx_TestImage&OutputParameter=Output1&Content-Type=text/plain" but it was also taken as a string.

the variable Output1 in my transaction has a value 'Hello'.

Please see the attached screenshot.On click of Submit button I should get 'Hello' but it displays me the complete string defined above.

Regards,

Anuj

Former Member
0 Likes

Hello Anuj, you should append: &Content-Type=text/XML

That will return you the xml,

Regards,

Arnaud

Former Member
0 Likes

Hi Arnaud,

But the output is not xml, its a string so text/plain should be fine for the Content-Type. Even then, I tried appending '&Content-Type=text/XML' but the output in web page is still the same.

Regards,

Anuj

Former Member
0 Likes

Hello Anuj, this is why you should use the star after the OutputParameter url parameter.

MII/Runner?Transaction=Test/Transactions/trx_TestImage&LogType=Info&OutputParameter=*&Content-Type=text/XML

should return you an XML

Regards,

Arnaud

Former Member
0 Likes

Hi Arnaud,

I tried that as well, but not getting the desired result.Please see the attachment.

Regards,

Anuj

Former Member
0 Likes
Can you try 2 things? First the url should be working in Internet Explorer with just the server name and the port added.  2nd thing. Is it it giving you any specific error ? You can press f12 in order to check that in Internet explorer. Cheers Arnaud