Sample Program: Job Start on Workday (JOB_CLOSE)

Use

* Start on particular workday of each month according to                
* factory calendar.                                                     
*                                                                       
* In this example, we hardwire the number of the workday and the 
* workday.  These specifications could also be collected from the 
* user with BP_START_DATE_EDITOR. 
*                                                                       
  CALL FUNCTION 'JOB_CLOSE'                                             
   EXPORTING                                                            
     CALENDAR_ID     = '01' " ID of SAP factory calendar                
                            " for determining workdays                  
     JOBCOUNT        = JOBNUMBER                                        
     JOBNAME         = JOBNAME                                          
     PRDMONTHS       = 1  " Specify whether job is to be repeated
                          " monthly, bi-monthly, etc.  You may not
                          " use other PRD* fields.  They are
                          " ignored.  
     START_ON_WORKDAY_NOT_BEFORE = SY-DATUM
                          " Start job not before the specified
                          " date (today's date)
     START_ON_WORKDAY_NR = '03'
                          " Start job on the third workday in the
                          " factory calendar, with respect to
                          " start or end of month, as specified in
                          " workday_count_direction.                     
     WORKDAY_COUNT_DIRECTION     = BTC_BEGINNING_OF_MONTH               
                          " Specify whether workday number is 
                          " relative to start or end of the month. 
                          " Permissible values:                                    
                          " - BTC_BEGINNING_OF_MONTH: Third 
                          "   workday after the start of the 
                          "   month.            
                          " - BTC_END_OF_MONTH: Third workday 
                          "   before the end of the month.                    
   IMPORTING                                                          
     JOB_WAS_RELEASED = JOB_RELEASED  " Check whether job was 
                                      " released.
   EXCEPTIONS                                                         
     INVALID_STARTDATE           = 2                               
     JOBNAME_MISSING             = 3                               
     JOB_CLOSE_FAILED            = 4                               
     JOB_NOSTEPS                 = 5                               
     JOB_NOTEX                   = 6                               
     LOCK_FAILED                 = 7                               
     OTHERS                      = 99.