cancel
Showing results for 
Search instead for 
Did you mean: 

Browser interaction: read Data from Browser using Runner

Former Member
0 Kudos

Greetings,

I am trying to find my way through MII. I suceeded in creating transactions and now I am about to make my first steps towards User interaction. I googled around and found some pages (like ) that i used to create the following code inside a HTML.

I inserted a button and a container. The transaction I created is returning some integer value as output. I just want to dispaly that figuer in the container. As I understood, runner is returning an XML that can be parsed.

To do so, I used the following code to print runner XML but somehow I cannot manage to get the result....How can I call that runner?!

When I paste URL created by fnCrtRunner into my browser, I get below result - so Runner is working.

Can somebody assist me? That would be awesome!

Call XML

      <button type="button" onclick="fnCallRunner();">Run Transaction</button>

      <div id="result">empty</div>

      <script type="text/javascript">

     

     function fnCrtRunner()

         {

                

          var URL = "http://XXXX/XMII/Runner?Transaction=TEST/Browser GUI/getTargetQuantity&OutputParameter=DailyQuantity";

                     URL +="&Content-Type=text/xml&IsBinary=true";

          return URL;

         }

      

         function fnCallRunner()

           {

         var runner = fnCrtRunner();

         var x = new XMLHttpRequest();

         x.open("GET", runner, true);

         document.getElementById("result").innerHTML = x.responseXML;

         }

Runner Result:

<?xml version="1.0" encoding="UTF-8"?>
<Rowsets DateCreated="2014-12-08T01:51:26" EndDate="2014-12-08T01:51:26" StartDate="2014-12-08T01:51:26" Version="14.0 SP5 Patch 3 (May 19, 2014)" TransactionID="-1">
  
<Rowset TrxID="-1">
     
<Columns>
        
<Column Description="" MaxRange="0.0" MinRange="0.0" Name="DailyQuantity" SQLDataType="-5" SourceColumn="DailyQuantity" />
     
</Columns>
     
<Row>
        
<DailyQuantity>15</DailyQuantity>
     
</Row>
  
</Rowset>
</Rowsets>

Accepted Solutions (1)

Accepted Solutions (1)

swaroop_anasane
Active Contributor
0 Kudos

Hi Marco,

Why do you want to call the runner service? You can use a simpler approach of getting applets on your page using scripting assistant.

Still, if you insist to use runner service, then below code might help you:

$.ajax({

  url: "/XMII/Runner?Transaction=<TramsactionPATH>&Content-Type=text/xml",

  success: function(result) {

  }

  });

 

"result" contains the xml returned by the trasaction, that you can modify/manipulate in success clock.

Hope this helps.

Thanks,

Swaroop

Former Member
0 Kudos

Hi Swaroop, thanks for your answer!! The reason why I want to use the runner service is because I don't know better, yet .

I have to dig into the MII subject on my own and am currently trying to find my way through it...

So I already managed to crate transactions and now want to dig into user interaction - that is run a transaction with paremters given in a IE-Weppage-GUI. I found some information on that runner service and wanted to try it as first attempt.

I do not know about scripting assistant yet...

If you could draft me a simpler way, I really would be happy to dig deeper into that one!

Anyway, I tried your approach (it is jQuery I think?...I don't much about it), but I did not manage to get things done. Wanted to use an alert to show result. I implemented as follows.

<BODY>

      <button type="button" onclick="bla()">Run Transaction</button>
      <div id="r">empty</div>
      <script type="text/javascript">

function bla(){

$.ajax({
  url: "/XMII/Runner?Transaction=http://SERVER/XMII/Runner?Transaction=TEST/Browser GUI/getTargetQuantity&Content-Type=text/xml",
  success: function(result) {
        alert(result);
  }

  });
}
</script>

</BODY>

But it is not working. Then I tried to move result to some local variable called z and tried to display thet one as alert and got an  "undefined" pop up. I thought by myself it might be due to XML format. So I googled and found a post dealing with that topic:

javascript - jQuery getJSON save result into variable - Stack Overflow

So i ended up here - bu still not working:

<button type="button" onclick="bla()">Run Transaction</button>
<div id="r">empty</div>
<script type="text/javascript">

function bla(){
var z;
$.ajax({
  url: "/XMII/Runner?Transaction=http://SERVER/XMII/Runner?Transaction=TEST/Browser GUI/getTargetQuantity&Content-Type=text/xml",
  success: function(result) {
z = result;
  }
  });

var xmlText = new XMLSerializer().serializeToString(z);
var xmlTextNode = document.createTextNode(xmlText);
var parentDiv = document.getElementById("r");
parentDiv.appendChild(xmlTextNode);
}

</script>

Maybe one more hint?

swaroop_anasane
Active Contributor
0 Kudos

Hi Marco,

Try this one in the alert,

result.getElementsByTagName("Id")[1]

Where Id is one of the variable in transaction's output.

Warm Regards,

Swaroop

Former Member
0 Kudos

Swaroop, getElementsByTagName was the clue I needed, thank you very much. Now that I knew what to look for, I figured out it needs to be "result.getElementsByTagName("Id")[0].childNodes[0].nodeValue"

So that one is working...now I'll have a look at the script assistant you proposed. I already had a look at it but it seems to be a different story 😉

In case you have some example to share with me or if you know some good website about that topic, I will grateful accept whatever is out there 😉

swaroop_anasane
Active Contributor
0 Kudos

Hi Marco,

That's great....but i think you marked the other one as correct!

About script assistant, you can refer below doc:

SAP Manufacturing Integration and Intelligence 14.0 – SAP Help Portal Page

Warm Regards,

Swaroop

Answers (0)