Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Variant based job schedule

Former Member
0 Likes
1,461

Hello,

I want to schedule a background job using Function module.

I have searched on SDN forums for the same, n got some function modules but they are not variant based.

I am providing job name, report name, date , time & variant name to the code.

I want a function module for the same.

Please if anyone can help me out with this?

Regards,

Krutika

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
1,402

Hi, Try these steps. The details are enough to follow the below step. <li>JOB_OPEN function module is used to create a background job <li>JOB_SUBMIT function module is used to add a job step to a background job that you have opened with JOB_OPEN <li>JOB_CLOSE function module is used to submit a background job to the background processing system for execution Thanks Venkat.O

Hello,

I want to schedule a background job using Function module.

I have searched on SDN forums for the same, n got some function modules but they are not variant based.

I am providing job name, report name, date , time & variant name to the code.

I want a function module for the same.

Please if anyone can help me out with this?

Regards,

Krutika

9 REPLIES 9
Read only

Former Member
0 Likes
1,402

Hi,

Check FM JOB_SUBMIT.

You can give variant in this FM.

Regards,

Dhan

Read only

0 Likes
1,402

There are no date or time relevent fields in this FM where start date and time can be defined hence it will run immediately by default.

Regards,

Krutika

Read only

0 Likes
1,402

Hello Krutika,

You need to use JOB_OPEN, JOB_SUBMIT & JOB_CLOSE.

Also, you can use RS_CREATE_VARIANT for creating dynamic variants.

In JOB_CLOSE you can use following parameters:


CALL FUNCTION 'JOB_CLOSE'
  EXPORTING
*   AT_OPMODE                         = ' '
*   AT_OPMODE_PERIODIC                = ' '
*   CALENDAR_ID                       = ' '
*   EVENT_ID                          = ' '
*   EVENT_PARAM                       = ' '
*   EVENT_PERIODIC                    = ' '
    jobcount                          =
    jobname                           =
*   LASTSTRTDT                        = NO_DATE
*   LASTSTRTTM                        = NO_TIME
*   PRDDAYS                           = 0
*   PRDHOURS                          = 0
*   PRDMINS                           = 0
*   PRDMONTHS                         = 0
*   PRDWEEKS                          = 0
*   PREDJOB_CHECKSTAT                 = ' '
*   PRED_JOBCOUNT                     = ' '
*   PRED_JOBNAME                      = ' '
*   SDLSTRTDT                         = NO_DATE
*   SDLSTRTTM                         = NO_TIME
*   STARTDATE_RESTRICTION             = BTC_PROCESS_ALWAYS
*   STRTIMMED                         = ' '
*   TARGETSYSTEM                      = ' '
*   START_ON_WORKDAY_NOT_BEFORE       = SY-DATUM
*   START_ON_WORKDAY_NR               = 0
*   WORKDAY_COUNT_DIRECTION           = 0
*   RECIPIENT_OBJ                     =
*   TARGETSERVER                      = ' '
*   DONT_RELEASE                      = ' '
*   TARGETGROUP                       = ' '
*   DIRECT_START                      =

Hope this resolves your issue!

Thanks,

Augustin.

Read only

Former Member
0 Likes
1,402

HI ,

try with FM " BP_VARIANT_USED_IN_JOB

Read only

venkat_o
Active Contributor
0 Likes
1,403

Hi, Try these steps. The details are enough to follow the below step. <li>JOB_OPEN function module is used to create a background job <li>JOB_SUBMIT function module is used to add a job step to a background job that you have opened with JOB_OPEN <li>JOB_CLOSE function module is used to submit a background job to the background processing system for execution Thanks Venkat.O

Read only

Former Member
0 Likes
1,402

Dear all,

The problem that i am facing is not of background job scheduling, but that the function module which i am using is not considering the variant name.

As my requirement is scheduling a job with the program variant as given by the user.

The FM that i am using is SUBST_SCHEDULE_BATCHJOB which has a option of variant name. But when the job is scheduled the variant name is not considered.

Kindly help me with the same .....

regards

Krutika

Read only

Former Member
0 Likes
1,402

Hello Krutika,

In that case you can use JOB_SUBMIT.


CALL FUNCTION 'JOB_SUBMIT'
  EXPORTING
*   ARCPARAMS                         =
    authcknam                         =
*   COMMANDNAME                       = ' '
*   OPERATINGSYSTEM                   = ' '
*   EXTPGM_NAME                       = ' '
*   EXTPGM_PARAM                      = ' '
*   EXTPGM_SET_TRACE_ON               = ' '
*   EXTPGM_STDERR_IN_JOBLOG           = 'X'
*   EXTPGM_STDOUT_IN_JOBLOG           = 'X'
*   EXTPGM_SYSTEM                     = ' '
*   EXTPGM_RFCDEST                    = ' '
*   EXTPGM_WAIT_FOR_TERMINATION       = 'X'
    jobcount                          =
    jobname                           =
*   LANGUAGE                          = SY-LANGU
*   PRIPARAMS                         = ' '
*   REPORT                            = --------> Provide report name here
*   VARIANT                           = ---------> Provide variant name here
* IMPORTING
*   STEP_NUMBER                       =
* EXCEPTIONS
*   BAD_PRIPARAMS                     = 1
....
.......

I hope this will resolve issue.

Thanks,

Augustin.

Read only

Former Member
0 Likes
1,402

I traied with job_submit, bt its not accepting report name and varient. the job is scheduled with some else report name.

Kindly help.

Is there any other function module?

Regards,

Krutika

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,402

Try this



DATA: number           TYPE tbtcjob-jobcount, 
      name             TYPE tbtcjob-jobname VALUE 'JOB_TEST', 
      print_parameters TYPE pri_params. 

CALL FUNCTION 'JOB_OPEN' 
  EXPORTING 
    jobname          = name 
  IMPORTING 
    jobcount         = number 
  EXCEPTIONS 
    cant_create_job  = 1 
    invalid_job_data = 2 
    jobname_missing  = 3 
    OTHERS           = 4. 
IF sy-subrc = 0. 
  
  SUBMIT YKRTEST2 TO SAP-SPOOL 
                    SPOOL PARAMETERS print_parameters 
                    WITHOUT SPOOL DYNPRO 
                    USING SELECTION-SET variant  "<---Variant
                    VIA JOB name NUMBER number 
                    AND RETURN. 
  
  IF sy-subrc = 0. 
    
    CALL FUNCTION 'JOB_CLOSE' 
      EXPORTING 
        jobcount             = number 
        jobname              = name 
        strtimmed            = 'X' 
      EXCEPTIONS 
        cant_start_immediate = 1 
        invalid_startdate    = 2 
        jobname_missing      = 3 
        job_close_failed     = 4 
        job_nosteps          = 5 
        job_notex            = 6 
        lock_failed          = 7 
        OTHERS               = 8. 
    IF sy-subrc <> 0. 
      
    ENDIF. 
  ENDIF. 
ENDIF.