You are probably familiar with screen scripts containing a vHandle_ARRIVE function that is executed when a 5250 screen arrives.
Any screen script can also, optionally, contain a vHandle_DEPART function.
If it exists it will be invoked when a screen is being departed from, which is usually caused by a SENDKEY operation.
If you need to use one, add it to your screen's script like this example:
 
   vHandle_DEPART: function()
   {
      var bReturn = true;
 
      //  your departure logic goes here
 
      return(bReturn); /* ß Remember to return a Boolean success/fail value */
 
   },  /* ß Remember to separate this function from the others with a comma */
 
There are some things you should know about using vHandle_DEPART functions: