/**********************************************************************/


JRN_MAIN:
      /* return command in upper case                      */
   command=word(1,'u');

      /* look at first 3 chars                             */
   command=substr(command,1,3);
   if lastcode='AD' then addflag=1;
   lastcode=' ';
   select(command);

      /* user deleted record                               */
   when('DEL')
     code='D';
     /* update the JOURNAL data set                        */
     link WRITEJRN;
     
     /* more program lines */

return;

JRN_TERM:
     
     /* more program lines */

WRITEJRN:
      /* create the JOURNAL observation if necessary       */
   datetime=datetime();

   if code='D' then do;
      rc=delobs(dsid_chg);

         /* set changes obs to all missing                 */
      rc=append(dsid_chg,'noset');
   end;
   else

         /* update with current screen values              */
     rc=update(dsid_chg);
     
     /* more program lines */

return;


/**********************************************************************/


JRN_TERM:
   if _status_='C' then do;  /* cancel command entered:    */
      addflag=0;             /* reset add flag             */
      return;                /* stop processing section.   */
   end;

   if addflag then do;       /* indicates add in progress  */
      addflag=0;             /* reset add flag             */
      if command='DEL'       /* similar to cancel.         */
      then return;
      else code='AD';        /* else ready to process add  */
   end;
WRITEJRN:
     
     /* more program lines */

return;


/**********************************************************************/