Sample Program: Start at Switch to Operating Mode (JOB_CLOSE)

Use

* Start job when a particular SAP operation mode becomes active. 
* Operation modes are defined in the Computing Center Management 
* System (CCMS, transaction SRZL).
*
* Note that internally opmode jobs are handled as "start on event" 
* jobs.  This means, for example, that after BP_START_DATE_EDITOR,
* TBTCSTRT-STDTTYP is set to BTC_STDT_EVENT when a user selects an 
* opmode start.  
*
  CALL FUNCTION 'JOB_CLOSE'                                 
   EXPORTING                                            
     JOBCOUNT            = JOBNUMBER         
     JOBNAME             = JOBNAME           
     AT_OPMODE           = 'NIGHTS' " Job is eligible to
                                    " start when this
                                    " operation mode becomes
                                    " active.
     AT_OPMODE_PERIODIC  = 'X'      " Set this field to X to
                                    " start job each time
                                    " that the op mode
                                    " becomes active.       
   IMPORTING                                            
     JOB_WAS_RELEASED    = JOB_RELEASED   " Check: was job  
                                          " released?   
   EXCEPTIONS                                           
     INVALID_STARTDATE   = 1                 
     JOBNAME_MISSING     = 2                 
     JOB_CLOSE_FAILED    = 3                
     JOB_NOSTEPS         = 4                 
     JOB_NOTEX           = 5                 
     LOCK_FAILED         = 6                 
     OTHERS              = 99.