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
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"> </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 progID="file://processing.html" _ title="Loading notifications, please wait..." _ name="processingPopup" _ -floating // use "ConnectHTML"
to pass the GuiXT object to JavaScript // indicator variable
to stop the InputScript Screen RI_ORDER_OPERATION_LIST.1000Title "Loading notifications, please wait..." // set parametersSet 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 Screen SAPLSLVC_FULLSCREEN.0500Title "Loading notifications, please wait..." // grid values into GUiXT variables GetGridValues selectedCells="notification" selectedrowCount="rv" // process all notificationsSet V[k] 1 label
next_step // processing
message with new percentage if V[stopProcessing] goto stop endif // do something
with notification Set V[k] &V[k] + 1 goto next_step endif CloseControl name="processingPopup"Message "S: Processing complete" -statusline Enter "/N" Leave
label stopCloseControl name="processingPopup" Message "E: Processing stopped by user" -statusline Enter "/N" Leave
Components
|