on 2012 Nov 08 2:35 PM
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:
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
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The solution for current thread problem was suggested by Arnaud Liotta:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
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
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.