Purpose
Display a processing message

For particular InputScripts we know that they can take a while to finish the process. It is then desirable to give the user some kind of feedback during this waiting time, indicating that the system is still working.

Solution

  • Implement a suitable "Please wait" HTML page
  • Display the HTML page during the InputScript processing via Control
  • Keep the popup window informed about the current step and the percentage of work already done

Video

 

HTML "processing.html"

<html>  

<head>
<title>Processing...</title>
<script type="text/javascript">
 
// GuiXT object
var guixt;
 
// called by connectHTML, passes GuiXT object
function guixt_initialize(obj)
{
  guixt = obj;
};

// variable to stop the InputScript 
var stop = "";

  function set_step_info(s, p)
  {
  
    // add line 
    var d =  document.getElementById('content');
    d.innerHTML += "<li>" + s + "</li>"; 
    
    // scroll to bottom so that new line is visible
    d.scrollTop = d.scrollHeight;
        
    // set percentage
    if (p)
    {
       document.getElementById('progressbar').style.width = p + "%";
       document.getElementById('percentage').innerHTML = p + "%";
    };

    // make new content visible
    guixt.doEvents(); 
    
    return stop;
  };
  

</script>

</head>

<body>
<table style="padding:2px;">
 <tr>
  <td style="vertical-align:top; text-align: center;">
    <img  alt="processing" src="processing.gif" 
             style="margin:10px;" height="100" width="119"  >
	<br >
	<br >
	
	<div style="width:100%; background-color: #ddd">
	  <div style="width:1%; background-color: #4CAF50" 
                                   id="progressbar">
	   &nbsp;
	  </div>
	</div>  
	<div id="percentage" 
	 style="margin-top:10px; font-family:Tahoma; 
                    font-size:50px; font-weight:bold; color:#808080;">
       0%
    </div>
 
	<br >
	<br >
		<img title="Stop processing" alt="Stop"
		    style="cursor:pointer; height:60px; width:60px;" 
                     src="stopbutton.png" 
      onclick="if(confirm('Do you really want to stop?')) stop = 'X';" >
  </td>

  <td style="vertical-align:top; width:500px;">

   <ul id="content" 
     style="font-family: Arial; font-size: 10pt; 
              max-height: 380px; width:480px;overflow:auto;">
   </ul>
  </td>
 </tr>
</table>

</body>
</html>


JavaScript
to communicate between HTML page and InputScript
// insert new line s into processing message window
// optionally: new percentage p beween 0 and 100
function set_step_info(ie, s, p) {

    if (ie && ie.document && ie.document.parentWindow) {
        return ie.document.parentWindow.set_step_info(s, p);
    };

    // User has closed the processing message window
    return "";   // or "X" = stop processing

};

InputScript (relevant parts)

Enter "/niw37n"

// display processing popup
Control
(5,20) (30,126) _
   
progID="file://processing.html" _
    title=
"Loading notifications, please wait..." _
    name=
"processingPopup" _
    -floating

// use "ConnectHTML" to pass the GuiXT object to JavaScript
ConnectHTML
name="processingPopup"

// indicator variable to stop the InputScript
Clear
V[stopProcessing]

Screen RI_ORDER_OPERATION_LIST.1000

Title "Loading notifications, please wait..."

// set parameters
Set F[Period] ...
Set F[Period to] ...
...

CallJS stopProcessing = set_step_info "&V[processingPopup]" "Selecting notifications" 
  // stopped by user ?
  if V[stopProcessing]
      goto stop
  endif

Enter "/8"

// Grid control
Screen
SAPLSLVC_FULLSCREEN.0500
 
Title "Loading notifications, please wait..."

CallJS stopProcessing = set_step_info "&V[processingPopup]" "Reading notifications"
  // stopped by user ?
  if V[stopProcessing]
      goto stop
  endif

// load all notifications into grid
GetGridValues -prepare

// select all notifications
Enter "/5"

Screen SAPLSLVC_FULLSCREEN.0500
  Title
"Loading notifications, please wait..."

// grid values into GUiXT variables
GetGridValues selectedCells="notification" selectedrowCount="rv"

// process all notifications
Set
V[k]
1

label next_step
if V[notification.&V[k].2]

  // calculate percentage

  Set V[percentage] &V[k]
* 100
  Set
V[percentage] &V[percentage] / &V[rv] decimals=
0

  // processing message with new percentage
  CallJS
stopProcessing = set_step_info _
 
  "&V[processingPopup]" _
   
"&V[k]: &V[notification.&V[k].2] &V[notification.&V[k].4] &V[notification.&V[k].5]"
_
    "&V[percentage]"

  // stopped by user ?
  if V[stopProcessing]
      goto stop
  endif

  // do something with notification
  // ....

  // next one
  Set V[k] &V[k] + 1
  goto
next_step

endif

CloseControl name="processingPopup"
Message "S: Processing complete" -statusline
Enter "/N"
Leave

 

label stop
CloseControl name="processingPopup"
Message "E: Processing stopped by user" -statusline
Enter "/N"
Leave

 

 

 

Components
InputAssistant+Controls