INIT:
        /* Open the data set for updating. */
     dsid=open('company.customer','u');
     call set(dsid);
     call notify('newname','_gray_');
  return;

  NAME:
         /*  Search for the observation with the  */
         /*  name entered by the user.            */
     sysrc=where(dsid,'NAME='|| quote(name));

        /*  Read the observation into the   */
        /*  SCL data vector.                */
     sysrc=fetch(dsid);

         /*  If an observation matches the WHERE clause, */
         /*  then allow the user to rename the customer. */
     if (sysrc ne %sysrc(_sweof)) and (sysrc <= 0) then
        call notify('newname','_ungray_');

         /*  Otherwise, do not allow the user to rename  */
         /*  the customer, and display a message.        */
     else
        do;
           custnum = ' ';
           state = ' ';
           zipcode = ' ';
           city = ' ';
           phone = ' ';
           ord1dte = .;
           call notify('newname','_gray_');
           _msg_='No customer found with that name.';
        end;
  return;

NEWNAME:

        /*  Keep the old name in case the update fails.  */
     oldname = name;

       /*  Attempt to update the record for this customer. */
     name=newname;
     sysrc = update(dsid);

        /*  If the update was not successful, then print an */
        /*  error message and reset the value of name.      */
     if sysrc then
        do;
           _msg_='The customer could not be updated at this time.';
           name = oldname;
        end;

        /*  After the attempt to rename the customer, clear  */
        /*  the current new name value.                      */
     newname = ' ';
  return;

  TERM:
        /*  Close the data set.  */
     sysrc=close(dsid);
  return;