JOB_CLOSE (exception: invalid_startdate)

Hi,
     I'm trying to run two jobs. One after the other. For this i do the following:
JOB_OPEN (with: jobname)
JOB_SUBMIT (with:authcknam, jobcount, jobname, language, report and variant)
JOB_CLOSE (with: jobcount, jobname and strtimmed = X)
JOB_OPEN (with: jobname)
SUBMIT program x...
JOB_CLOSE (with jobcount , jobname, predjob_checkstat = X, pred_jobcount and pred_jobname)
But the second time that i call fonction JOB_CLOSE, it return code sy-subrc = 2. (invalid_startdate).
This happened only in the quality environment (In the developing  environment works ok).
Thank for your help!

Hi,
Run the second job after completion of first job.So,get the status of first job with the following code.
    CALL FUNCTION 'SHOW_JOBSTATE'
      EXPORTING
        jobcount         = l_jobnumber
        jobname          = l_jobname
      IMPORTING
        aborted          = l_aborted
        finished         = l_finished
      EXCEPTIONS
        jobcount_missing = 1
        jobname_missing  = 2
        job_notex        = 3
        OTHERS           = 4.
    IF l_aborted = 'X'(106) OR l_finished = 'X'(106).
    <Write the code to run second job>
    ELSE.
      WAIT UP TO 5 SECONDS.
    ENDIF.
Thanks.
Ramya.

Similar Messages

  • Problem with job_close Exception INVALID_STARTDATE = 2

    Following is the test program.
    My requirement is to split the program execution in to multiple jobs which should run sequentially - one by one, I have populated prev job name and jobcount. As of now for the below code .. i am getting invalid_startdate exception.
    Can any one please let me know, where i am wrong.
    I am working on ECC 6.0.
    To test the below program, copy the below program as it is in to one test program and create a ZTESTV7 program with simple write statement, that can create a spool.
    Thanks,
    Shilpa.
    data : v_jobcount TYPE TBTCJOB-JOBCOUNT,
           v_jobname  TYPE TBTCJOB-JOBNAME,
           v_pjobcount TYPE TBTCJOB-JOBCOUNT,
           v_start type char1,
           v_PCHECK type char1,
           v_pjobname  TYPE TBTCJOB-JOBNAME.
    START-OF-SELECTION.
    v_jobname = 'TEST'.
    do 5 times.
      if sy-index = 1.
        v_start = 'X'.
        V_pcheck = '' .
        else.
          v_start = SPACE.
          v_PCHECK = 'X'.
      endif.
    CALL FUNCTION 'JOB_OPEN'
      EXPORTING
        jobname                           = v_jobname
    IMPORTING
       JOBCOUNT               = v_jobcount
    SUBMIT ZTESTV7 VIA JOB V_JOBNAME NUMBER V_JOBCOUNT AND RETURN.
    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount                          = v_jobcount
        jobname                           = v_jobname
       PREDJOB_CHECKSTAT                 = v_PCHECK
       PRED_JOBCOUNT                     = v_pjobcount
       PRED_JOBNAME                      = v_pjobname
       STRTIMMED                         = V_START
    EXCEPTIONS
       CANT_START_IMMEDIATE              = 1
       INVALID_STARTDATE                 = 2
       JOBNAME_MISSING                   = 3
       JOB_CLOSE_FAILED                  = 4
       JOB_NOSTEPS                       = 5
       JOB_NOTEX                         = 6
       LOCK_FAILED                       = 7
       INVALID_TARGET                    = 8
       OTHERS                            = 9
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    leave  list-processing.
    ENDIF.
    v_pjobcount = v_jobcount.
    v_pjobname = v_jobname.
    enddo.

    This reply is already late to this question however just for future reference. I actually have the same requirement and the same error when executing FM JOB_CLOSE. Fortunately I solved the issue. You don't need to pass the job count for PRED_JOBCOUNT parameter of the FM as this causing the error. You only need the PRED_JOBNAME, which should be unique and STRTIMMED which should be marked with u2018Xu2019 always.
    Itu2019s kind a weird because when I executed my program via debugging mode, it shows that this job name has this job number after calling JOB_OPEN however this job number is already assigned to the job of the previous execution of the loop. So, when JOB_CLOSE is called, it throws EXCEPTION 2. I also check SM36/37 there were jobs I created with the same job number. It seemed to me, SAP change the job number during actual execution of the job.

  • Job_close with exception INVALID_STARTDATE

    hi all,
    when the program call the function module Job_close, it run tun with the sy-subrc 3 INVALID_STARTDATE , can someone tell why this happan? is this releate to any configuration since previously the program wokrs fine.
    thanks

    Hi.
    check with the sy-datum on the server system ..
    it might be possibly set wrong ...
    or before the job_open...
    Ask your basis team
    Regards
    Renu

  • Batch job failing with INVALID_STARTDATE exception

    Hello Experts,
    our batch  job  runs 17th minute of every hour on daily basis.It is running successfully from 00:17 AM to 20:17 PM and gets completed within 1 hour for every run.
    But when it is starting 21:17PM, it keeps on running for next 5-6 hours and then gets cancelled with error "Invalid_startdate"
    Currently it is posting all the idocs.Idoc status is 53. But the problem is  closing the job Function module JOB_CLOSE is throwing an exception "INVALID_STARTDATE" and gets cancelled.
    Could anyone please provide us any help on this.

    Usually this message is raised because of:
    Unsupported combinations of specifications, such as periodic repetition of jobs that were scheduled to wait for a predecessor job
    Incomplete or incorrect specifications, such as an incomplete start date.
    but..is your SAP in a time zone 3 hours different from yours?
    e.g. New York has already a new day when you have 9PM in LA

  • Schedule a daily job using JOB_CLOSE

    Hello,
    I want to schedule a daily job using job_open, job_submit & job_close.
    This job should run everyday at 22:00 hrs.
    What are the parameters I need to set for the FM JOB_CLOSE?
    Thanks,
    A Pothuneedi

    Look at this sample provided by SAP : <a href="http://help.sap.com/saphelp_sm32/helpdata/en/fa/096d8e543b11d1898e0000e8322d00/content.htm">Sample Program: Start-Time Window with JOB_CLOSE</a>
    Sample Program: Start-Time Window with JOB_CLOSE Locate the document in its SAP
    <b>Library structure</b>
    * Submit job: start-time window defined, with periodic repeat and
    * with target system upon which the job is to run.
    * In this case, you must provide start date settings. You can
    * have the job started immediately with a JOB_CLOSE parameter,
    * set the start date yourself, or ask the user with
    * BP_START_DATE_EDITOR.
    * Example: Provide start-date specifications yourself.
    STARTDATE = '19970101'.
    STARTTIME = '160000'.
    LASTSTARTDATE = '19970101'.
    LASTSTARTTIME = '180000'.
    CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
    JOBCOUNT = JOBNUMBER " Job identification: number
    JOBNAME = JOBNAME " and name.
    SDLSTRTDT = STARTDATE " Start of start-time...
    SDLSTRTTM = STARTTIME " window
    LASTSTRTDT = LASTSTARTDATE " Optional: end of...
    LASTSTRTTM = LASTSTARTTIME " start-time window
    PRDMONTHS = '1' " Restart at intervals of
    PRDWEEKS = '1' " the sum of the PRD*
    PRDDAYS = '1' " parameters
    PRDHOURS = '1'
    PRDMINS = '1'
    STARTDATE_RESTRICTION = BTC_DONT_PROCESS_ON_HOLIDAY
    " Restrict job start to work
    " days; don't start job if
    " scheduled on holiday.
    " Other values:
    " BTC_PROCESS_BEFORE_HOLIDAY
    " BTC_PROCESS_AFTER_HOLIDAY
    CALENDAR_ID = '01' " ID of R/3 factory calendar
    " for determining workdays
    TARGETSYSTEM = 'hs0011' " Optional: name of the host
    " system on which the job is
    " to run. Set only if
    " absolutely required.
    " Example: A required tape
    " drive is accessible only
    " from a single host system.
    IMPORTING
    JOB_WAS_RELEASED = JOB_RELEASED " If user has authorization
    " to release jobs to run, job
    " is automatically released
    " when it is scheduled. This
    " field is set to 'x' if the
    " job has been released.
    " Otherwise, the job is sche-
    " duled but must be released
    " by an administrator before
    " it can be started.
    EXCEPTIONS
    INVALID_STARTDATE = 01
    JOBNAME_MISSING = 02
    JOB_CLOSE_FAILED = 03
    JOB_NOSTEPS = 04
    JOB_NOTEX = 05
    LOCK_FAILED = 06
    OTHERS = 99.
    IF SY-SUBRC > 0.
    <Error processing>
    ENDIF.
    Regards

  • Submit and Wait ?

    Hi,
    I am using JOB_OPEN , SUBMIT and JOB_CLOSE for program to create a spool.
    My problem is after the JOB_CLOSE i am calling another report  to send output of first report from the spool.
    My problem is after submitting the program report1 system calls the job_close and tried to send report1 output as mail. But still the submit report1 is still running .
    My question how to use submit statement wait for submit report1 is finished and then only call JOB_CLOSE.
        call function 'JOB_OPEN'
          exporting
            jobname          = v_jobname
          importing
            jobcount         = v_jobcount
          exceptions
            cant_create_job  = 01
            invalid_job_data = 02
            jobname_missing  = 03
            others           = 99.
        submit report1
                        via job v_jobname
                        number v_jobcount
                        to sap-spool without spool dynpro
                        spool parameters wa_params
                        and return.
        call function 'JOB_CLOSE'
          exporting
            jobcount          = v_jobcount
            jobname           = v_jobname
            strtimmed         = 'X'
          importing
            job_was_released  = v_job_released
          exceptions
            invalid_startdate = 01
            jobname_missing   = 02
            job_close_failed  = 03
            job_nosteps       = 04
            job_notex         = 05
            lock_failed       = 06
            others            = 99.
      submit report2 with spool = v_spool. " For mailing
    Sa_R

    Thanks Mike.
    Your solution work well
        call function 'JOB_OPEN'
          exporting
            jobname          = v_jobname
          importing
            jobcount         = v_jobcount
          exceptions
            cant_create_job  = 01
            invalid_job_data = 02
            jobname_missing  = 03
            others           = 99.
        submit ygenr001
                        via job v_jobname
                        number v_jobcount
                        to sap-spool without spool dynpro
                        spool parameters wa_params
                        and return.
    " Simply call the JOB_SUBMIT with extpgm_wait_for_termination = 'X'
    " that will wait for step to complete.
          call function 'JOB_SUBMIT'
            exporting
              authcknam                   = sy-uname
              extpgm_wait_for_termination = 'X'
              jobcount                    = v_jobcount
              jobname                     = v_jobname
            exceptions
              bad_priparams               = 1
              bad_xpgflags                = 2
              invalid_jobdata             = 3
              jobname_missing             = 4
              job_notex                   = 5
              job_submit_failed           = 6
              lock_failed                 = 7
              program_missing             = 8
              prog_abap_and_extpg_set     = 9
              others                      = 10.
        call function 'JOB_CLOSE'
          exporting
            jobcount          = v_jobcount
            jobname           = v_jobname
            strtimmed         = 'X'
          importing
            job_was_released  = v_job_released
          exceptions
            invalid_startdate = 01
            jobname_missing   = 02
            job_close_failed  = 03
            job_nosteps       = 04
            job_notex         = 05
            lock_failed       = 06
            others            = 99.
      perfrom send_mail using v_spool_no.
    Sa_R

  • Job Error Message "There is a job that has not yet ended"

    Hi.
    I have an Report that must starts with an Job. The Reports calls the report RFBIBL00.
    I create an entry in the Transaction OBDU and then i define a job.
    At the first run, all is ok. But when the job must run a second time, i get the error  message BD 077. There is a job that has not yet ended....
    What must I do? The both job have the status "finished"...
    Thanks
    Marcus
    Edited by: Marcus Ventur on Jun 26, 2009 11:26 AM

    Hi,
    Use this code, it may help you.
    FORM BACK_GROUND_JOB.
      W_JOBNAME = 'JOB1'.
      CALL FUNCTION 'JOB_OPEN'
           EXPORTING
                JOBNAME          = W_JOBNAME
           IMPORTING
                JOBCOUNT         = W_JOBCOUNT
           EXCEPTIONS
                CANT_CREATE_JOB  = 1
                INVALID_JOB_DATA = 2
                JOBNAME_MISSING  = 3
                OTHERS           = 4.
      IF SY-SUBRC NE 0.
        MESSAGE S368(00) WITH 'Error Creating Job'
        SY-SUBRC.
        EXIT.
      ENDIF.
      SUBMIT Prgoram
          VIA JOB W_JOBNAME
          NUMBER W_JOBCOUNT
          AND RETURN.
      CALL FUNCTION 'JOB_CLOSE'
           EXPORTING
                JOBCOUNT          = W_JOBCOUNT
                JOBNAME           = W_JOBNAME
                STRTIMMED         = 'X'  " Immediate
           EXCEPTIONS
                INVALID_STARTDATE = 1
                JOBNAME_MISSING   = 2
                JOB_CLOSE_FAILED  = 3
                JOB_NOSTEPS       = 4
                JOB_NOTEX         = 5
                LOCK_FAILED       = 6
                OTHERS            = 7.
      IF SY-SUBRC > 0.
        MESSAGE S368(00) WITH 'Closing Job Failed'
        SY-SUBRC.
        EXIT.
      ENDIF.
    ENDFORM.                    " BACK_GROUND_JOB
    Thanks
    Ravi Kanth

  • Can a FM be scheduled like a job?

    Hi All,
    Can we schedule a FM or RFC FM, the way we schedule a job?
    If yes, how can we do it?
    Thanks and Regards,
    Ankit

    Hi,
    yes we can schedule using the following Function module
    JOB_OPEN
    JOB_SUBMIT
    JOB_CLOSE
    please check out the following program for JOB_OPEN
    JOBNAME = 'Freely selectable name for the job(s) you create'.
    CALL FUNCTION 'JOB_OPEN'
    EXPORTING
    JOBNAME = JOBNAME
    IMPORTING
    JOBCOUNT = JOBNUMBER
    EXCEPTIONS
    CANT_CREATE_JOB = 01
    INVALID_JOB_DATA = 02
    JOBNAME_MISSING = 03
    OTHERS = 99.
    IF SY-SUBRC > 0.
    <Error processing>
    ENDIF.
    Check out the following program for JOB_CLOSE
    STARTDATE = '19970101'.
    STARTTIME = '160000'.
    LASTSTARTDATE = '19970101'.
    LASTSTARTTIME = '180000'.
    CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
    JOBCOUNT = JOBNUMBER " Job identification: number
    JOBNAME = JOBNAME " and name.
    SDLSTRTDT = STARTDATE " Start of start-time...
    SDLSTRTTM = STARTTIME " window
    LASTSTRTDT = LASTSTARTDATE " Optional: end of...
    LASTSTRTTM = LASTSTARTTIME " start-time window
    PRDMONTHS = '1' " Restart at intervals of
    PRDWEEKS = '1' " the sum of the PRD*
    PRDDAYS = '1' " parameters
    PRDHOURS = '1'
    PRDMINS = '1'
    STARTDATE_RESTRICTION = BTC_DONT_PROCESS_ON_HOLIDAY
    " Restrict job start to work
    " days; don't start job if
    " scheduled on holiday.
    " Other values:
    " BTC_PROCESS_BEFORE_HOLIDAY
    " BTC_PROCESS_AFTER_HOLIDAY
    CALENDAR_ID = '01' " ID of R/3 factory calendar
    " for determining workdays
    TARGETSYSTEM = 'hs0011' " Optional: name of the host
    " system on which the job is
    " to run. Set only if
    " absolutely required.
    " Example: A required tape
    " drive is accessible only
    " from a single host system.
    IMPORTING
    JOB_WAS_RELEASED = JOB_RELEASED " If user has authorization
    " to release jobs to run, job
    " is automatically released
    " when it is scheduled. This
    " field is set to 'x' if the
    " job has been released.
    " Otherwise, the job is sche-
    " duled but must be released
    " by an administrator before
    " it can be started.
    EXCEPTIONS
    INVALID_STARTDATE = 01
    JOBNAME_MISSING = 02
    JOB_CLOSE_FAILED = 03
    JOB_NOSTEPS = 04
    JOB_NOTEX = 05
    LOCK_FAILED = 06
    OTHERS = 99.
    IF SY-SUBRC > 0.
    <Error processing>
    ENDIF.
    check out the sample program which uses all the three modules at the same time
    REPORT ZMAILSPOOL.
    INCLUDE LBTCHDEF.
    Include the Business Object Repository object
    INCLUDE <CNTN01>.
    DATA ABAPNM LIKE SY-REPID.
    DATA BEGIN OF LOCAL_JOB.
    INCLUDE STRUCTURE TBTCJOB.
    DATA END OF LOCAL_JOB.
    DATA BEGIN OF LOCAL_STEP_TBL OCCURS 10.
    INCLUDE STRUCTURE TBTCSTEP.
    DATA END OF LOCAL_STEP_TBL.
    Data declarations for the mail recipient
    DATA RECIPIENT TYPE SWC_OBJECT.
    DATA RECIPIENT_OBJ LIKE SWOTOBJID.
    SWC_CONTAINER CONTAINER.
    Data declarations for the background job
    PARAMETERS ABAPNAME(20) DEFAULT 'ZTEST1'.
    PARAMETERS EMPFNAME LIKE SY-UNAME DEFAULT SY-UNAME.
    ABAPNM = ABAPNAME.
    LOCAL_JOB-JOBNAME = ABAPNAME.
    Generate recipient object (see report RSSOKIF1 for an example)
    1. Create the recipient:
    IF EMPFNAME <> SPACE.
    "** 1.1 Generate an object reference to a recipient object
    SWC_CREATE_OBJECT RECIPIENT 'RECIPIENT' SPACE.
    "** 1.2 Write the import parameters for method
    "** recipient.createaddress into the container
    "** and empty the container
    SWC_CLEAR_CONTAINER CONTAINER.
    "** Set address element (internal user 'JSMITH')
    SWC_SET_ELEMENT CONTAINER 'AddressString' EMPFNAME.
    "** Set address type (internal user)
    SWC_SET_ELEMENT CONTAINER 'TypeId' 'B'.
    "** 1.3 Call the method recipient.createaddress
    SWC_CALL_METHOD RECIPIENT 'CreateAddress' CONTAINER.
    "** Issue any error message generated by a method exception
    IF SY-SUBRC NE 0.
    MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO.
    ENDIF.
    SWC_CALL_METHOD RECIPIENT 'Save' CONTAINER.
    SWC_OBJECT_TO_PERSISTENT RECIPIENT RECIPIENT_OBJ.
    ENDIF.
    Recipient has been generated and is ready for use in a
    background job
    CALL FUNCTION 'JOB_OPEN'
         exporting
         DELANFREP              = ' '
         JOBGROUP               = ' '
           jobname                = LOCAL_JOB-JOBNAME
         SDLSTRTDT              = NO_DATE
         SDLSTRTTM              = NO_TIME
         IMPORTING
           JOBCOUNT               = LOCAL_JOB-JOBCOUNT
         EXCEPTIONS
           CANT_CREATE_JOB        = 1
           INVALID_JOB_DATA       = 2
           JOBNAME_MISSING        = 3
           OTHERS                 = 4
       if sy-subrc <> 0.
          WRITE: / 'JOB_OPEN PROBLEM ', SY-SUBRC.
       ELSE.
          WRITE: / 'JOB OPEN SUCCESS',
                                      LOCAL_JOB-JOBNAME, LOCAL_JOB-JOBCOUNT.
       endif.
    CALL FUNCTION 'JOB_SUBMIT'
         exporting
         ARCPARAMS                         =
           authcknam                         = SY-UNAME
         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                          = LOCAL_JOB-JOBCOUNT
           jobname                           = LOCAL_JOB-JOBNAME
         LANGUAGE                          = SY-LANGU
         PRIPARAMS                         = ' '
           REPORT                            = ABAPNM
         REPORT                            = 'ZTEST1'
         VARIANT                           = ' '
       IMPORTING
         STEP_NUMBER                       = LOCAL_JOB-STEPCOUNT
         EXCEPTIONS
           BAD_PRIPARAMS                     = 1
           BAD_XPGFLAGS                      = 2
           INVALID_JOBDATA                   = 3
           JOBNAME_MISSING                   = 4
           JOB_NOTEX                         = 5
           JOB_SUBMIT_FAILED                 = 6
           LOCK_FAILED                       = 7
           PROGRAM_MISSING                   = 8
           PROG_ABAP_AND_EXTPG_SET           = 9
           OTHERS                            = 10
       if sy-subrc <> 0.
          WRITE: / 'JOB_SUBMIT PROBLEM ', LOCAL_JOB-JOBCOUNT,
                   LOCAL_JOB-JOBNAME, ABAPNAME, SY-SUBRC.
       endif.
    IF EMPFNAME <> SPACE.
    CALL FUNCTION 'JOB_CLOSE'
      exporting
      AT_OPMODE                         = ' '
      AT_OPMODE_PERIODIC                = ' '
      CALENDAR_ID                       = ' '
      EVENT_ID                          = ' '
      EVENT_PARAM                       = ' '
      EVENT_PERIODIC                    = ' '
        jobcount                          = LOCAL_JOB-JOBCOUNT
        jobname                           = LOCAL_JOB-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                         = 'X'
      TARGETSYSTEM                      = ' '
      START_ON_WORKDAY_NOT_BEFORE       = SY-DATUM
      START_ON_WORKDAY_NR               = 0
      WORKDAY_COUNT_DIRECTION           = 0
        RECIPIENT_OBJ                     = RECIPIENT_OBJ
      TARGETSERVER                      = ' '
      DONT_RELEASE                      = ' '
    IMPORTING
      JOB_WAS_RELEASED                  = '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 ).
      WRITE: / 'Job_Close Problem:', ABAPNAME, SY-SUBRC.
    ELSE.
      WRITE: / 'Job_Close done'.
    ENDIF.
    ELSE. "no empfname
    ENDIF.
    **************please reward points if the information is helpful to you******************

  • Function module JOB_CLOSE throwing exception

    Hello,
    We have a batch job which has 2 steps:
    1) Step 1 uses job_open, job_submit and job_close and immediately schedules batch job A/P_ACCOUNTS which in turn creates batch input sessions A/P_ACCOUNTS.
    2) Step 2 Processes A/P_ACCOUNTS sessions created yesterday or today.
    In few cases, job_close is throwing exception job_close_failed. I believe that error is coming due to non availability of work processes. Job A/P_Accounts is defined as a class C batch job. There is a check in the FM job_close which does the following check:
    - if the class of a batch job is B or C, it calculates the number of free work processes. If there are no work processes available then JOB_CLOSE throws JOB_CLOSE_FAILED exception. 
    - If the class is u2018Au2019, it skips this check.
    We have an option of changing the class of batch job to A but there are some system critical jobs that are running as class A.
    My question is:
    In the code, JOB_CLOSE has been called for scheduling the job A/P_ACCOUNTS with parameter start immediately. Can anyone please let me know what will happen if function JOB_CLOSE is not called with start immediately option? Will the batch job A/P_ACCOUNTS wait till the time work processes are available?
    Or, can anything else be done to solve the issue?
    Regards,
    Siddharth

    HI,
    This is my experience with job_close..
    when i was working in zprograms then i was able to scedule it any time i wanted..
    but in my standard program when i tried it didn't worked....
    so i have to use that option of starting it immediately..
    and then it is working fine..
    now if i schedule 5 jobs... one after another..
    its get queued up...and once the processor is free...its working..
    my code of job close
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = job_count
          jobname              = job_name
          strtimmed            = yes " yes = 'X'
        IMPORTING
          job_was_released     = job_released
        EXCEPTIONS
          cant_start_immediate = 1
          invalid_startdate    = 2
          jobname_missing      = 3
          job_close_failed     = 4
          job_nosteps          = 5
          job_notex            = 6
          lock_failed          = 7
          invalid_target       = 8
          OTHERS               = 9.
    regards,
    Yadesh

  • How we will use these Job_open and Job_submit job_close??

    Hi Experts,
    i am new in Developement, i need one help here my problem is
    I have one issue which is a report here i am getting the data into internal table, that data fetching i want to schedule it in background job..
    can any body tell me how can i use the JOB_OPEN and JOB_SUBMIT function modules....
    plz provide any example..
    Thanks in Advance,
    Venkat N

    Hi,
    Here is the sample program
    *Submit report as job(i.e. in background) 
    data: jobname like tbtcjob-jobname value
                                 ' TRANSFER TRANSLATION'.
    data: jobcount like tbtcjob-jobcount,
          host like msxxlist-host.
    data: begin of starttime.
            include structure tbtcstrt.
    data: end of starttime.
    data: starttimeimmediate like btch0000-char1.
    Job open
      call function 'JOB_OPEN'
           exporting
                delanfrep        = ' '
                jobgroup         = ' '
                jobname          = jobname
                sdlstrtdt        = sy-datum
                sdlstrttm        = sy-uzeit
           importing
                jobcount         = jobcount
           exceptions
                cant_create_job  = 01
                invalid_job_data = 02
                jobname_missing  = 03.
      if sy-subrc ne 0.
                                           "error processing
      endif.
    Insert process into job
    SUBMIT zreport and return
                    with p_param1 = 'value'
                    with p_param2 = 'value'
                    user sy-uname
                    via job jobname
                    number jobcount.
      if sy-subrc > 0.
                                           "error processing
      endif.
    Close job
      starttime-sdlstrtdt = sy-datum + 1.
      starttime-sdlstrttm = '220000'.
      call function 'JOB_CLOSE'
           exporting
                event_id             = starttime-eventid
                event_param          = starttime-eventparm
                event_periodic       = starttime-periodic
                jobcount             = jobcount
                jobname              = jobname
                laststrtdt           = starttime-laststrtdt
                laststrttm           = starttime-laststrttm
                prddays              = 1
                prdhours             = 0
                prdmins              = 0
                prdmonths            = 0
                prdweeks             = 0
                sdlstrtdt            = starttime-sdlstrtdt
                sdlstrttm            = starttime-sdlstrttm
                strtimmed            = starttimeimmediate
                targetsystem         = host
           exceptions
                cant_start_immediate = 01
                invalid_startdate    = 02
                jobname_missing      = 03
                job_close_failed     = 04
                job_nosteps          = 05
                job_notex            = 06
                lock_failed          = 07
                others               = 99.
      if sy-subrc eq 0.
                                           "error processing
      endif.
    Regards
    Sudheer

  • How to send spool to Distribution List using JOB_CLOSE

    Please help on sending Distribution list when job defined using JOB_OPEN, JOB_Submit and JOB_CLOSE
    Thanks.

    Hi, this is code:
    DATA  WA_RECIPIENT LIKE swotobjid.
    CONSTANTS:  gc_objname  TYPE oj_name    VALUE 'RECIPIENT'.
    PERFORM get_distribucion_list USING    'NAME_LIST'   " name of List of distribution
                                  CHANGING WA_RECIPIENT.
    CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
          jobcount                          = l_jobcount
          jobname                           = l_jobname
          strtimmed                         = 'X'
        recipient_obj                     = wa_recipient
    IMPORTING
       job_was_released                  = l_libero
    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.
    FORM get_distribucion_list USING    p_objnam       TYPE so_obj_nam
                               CHANGING p_wa_recipient LIKE swotobjid.
      DATA: it_tab LIKE STANDARD TABLE OF soxdl
                   INITIAL SIZE 0 WITH HEADER LINE.
      CHECK NOT p_objnam IS INITIAL.
      CALL FUNCTION 'SO_DLI_LIST_READ_XDL'
        EXPORTING
          dli_generic_name            = p_objnam
          public                      = 'X'
          subscript                   = 'X'
        TABLES
          dli_display_tab             = it_tab
        EXCEPTIONS
          communication_failure       = 1
          dl_list_no_entries          = 2
          owner_not_exist             = 3
          system_failure              = 4
          x_error                     = 5
          parameter_error             = 6
          OTHERS                      = 7
      IF sy-subrc = 0.
        READ TABLE it_tab INDEX 1.
        IF sy-subrc = 0.
          CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
            IMPORTING
              own_logical_system             = p_wa_recipient-logsys
            EXCEPTIONS
              own_logical_system_not_defined = 1
              OTHERS                         = 2.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
          MOVE gc_objname TO p_wa_recipient-objtype.
          CONCATENATE it_tab-dlitp it_tab-dliyr it_tab-dlino
                      INTO p_wa_recipient-objkey.
        ENDIF.
      ELSE.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.

  • JOB_OPEN - SUBMIT - JOB_CLOSE - User Name for the Job

    Hi,
    I have a code like that:
    CALL FUNCTION 'JOB_OPEN'
        EXPORTING
          jobname          = lv_jobname
        IMPORTING
          jobcount         = lv_jobcount
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 4.
    * Call Update PO from Sales Order
      SUBMIT zpcc_mm_upo3
        WITH p_vbeln = puv_vbeln
        USER lc_uname
        VIA JOB lv_jobname NUMBER lv_jobcount
        AND RETURN.
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = lv_jobcount
          jobname              = lv_jobname
          strtimmed            = lc_true
        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.
    In this code as you see I can run the SUBMIT program with a specified user. But the creator of the job always becomes SY-UNAME. So is there a way to specify the user name for a job creator? I don't want to use SY-UNAME.
    Thanks,

    Hio try this way...
    CALL FUNCTION 'JOB_OPEN'
         EXPORTING
           jobname          = lv_jobname
         IMPORTING
           jobcount         = lv_jobcount
         EXCEPTIONS
           cant_create_job  = 1
           invalid_job_data = 2
           jobname_missing  = 3
           OTHERS           = 4.
    "Comment this
    * Call Update PO from Sales Order
       SUBMIT zpcc_mm_upo3
         WITH p_vbeln = puv_vbeln
         USER lc_uname
         VIA JOB lv_jobname NUMBER lv_jobcount
         AND RETURN.
    "Comment end
    * Call function to submit the job
      CALL FUNCTION 'JOB_SUBMIT'
           EXPORTING
                authcknam                   = wa_authchknam        "Pass the Other User name you want
                jobcount                    =  lv_jobcount
                jobname                     = lv_jobname
                REPORT                      = 'zpcc_mm_upo3'
                VARIANT                     = jobs-variant  "Create Varaqint
                PRIPARAMS                   = wa_PRI_PARAMS
          EXCEPTIONS
               BAD_PRIPARAMS               = 1
               BAD_XPGFLAGS                = 2
               INVALID_JOBDATA             = 3
               JOBNAME_MISSING             = 4
               JOB_NOTEX                   = 5
               JOB_SUBMIT_FAILED           = 6
               LOCK_FAILED                 = 7
               PROGRAM_MISSING             = 8
               PROG_ABAP_AND_EXTPG_SET     = 9
               OTHERS                      = 10
       CALL FUNCTION 'JOB_CLOSE'
         EXPORTING
           jobcount             = lv_jobcount
           jobname              = lv_jobname
           strtimmed            = lc_true
         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.
    Prabhudas

  • Job_open,job_close

    hello
    plz let me know how to use job_open,jib_sumbit,job_close,
    and the function modules related to it
    thanks
    aafaq husain

    Hi aafaqhusain,
    1. we can use like this
    2.
    report abc.
    BREAK-POINT.
    DATA  : JN(32) TYPE C.
    JN  = 'JOB001'.
    BREAK-POINT.
    DATA : J(8) TYPE C.
    CALL FUNCTION 'JOB_OPEN'
      EXPORTING
      DELANFREP              = ' '
      JOBGROUP               = ' '
        jobname                = JN
      SDLSTRTDT              = NO_DATE
      SDLSTRTTM              = NO_TIME
      JOBCLASS               =
    IMPORTING
       JOBCOUNT               = J
    CHANGING
      RET                    =
    EXCEPTIONS
      CANT_CREATE_JOB        = 1
      INVALID_JOB_DATA       = 2
      JOBNAME_MISSING        = 3
      OTHERS                 = 4
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    DATA : P TYPE PRI_PARAMS.
    P-PDEST = 'PRINTER'.
    P-PDEST = 'LOCL'.
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
           EXPORTING  NO_DIALOG             = 'X'
                      MODE                  = 'CURRENT'
                     NEW_LIST_ID           = $PRNEW
           IMPORTING  OUT_PARAMETERS       =  P.
    CALL FUNCTION 'JOB_SUBMIT'
      EXPORTING
      ARCPARAMS                         =
        authcknam                         = 'MAMIT'
      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                          = J
        jobname                           = JN
      LANGUAGE                          = SY-LANGU
       PRIPARAMS                         = P
       REPORT                            = 'HINCF160'
       VARIANT                           = 'A'
    IMPORTING
      STEP_NUMBER                       =
    EXCEPTIONS
       BAD_PRIPARAMS                     = 1
      BAD_XPGFLAGS                      = 2
      INVALID_JOBDATA                   = 3
      JOBNAME_MISSING                   = 4
      JOB_NOTEX                         = 5
      JOB_SUBMIT_FAILED                 = 6
      LOCK_FAILED                       = 7
      PROGRAM_MISSING                   = 8
      PROG_ABAP_AND_EXTPG_SET           = 9
       OTHERS                            = 10
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
      AT_OPMODE                         = ' '
      AT_OPMODE_PERIODIC                = ' '
      CALENDAR_ID                       = ' '
      EVENT_ID                          = ' '
      EVENT_PARAM                       = ' '
      EVENT_PERIODIC                    = ' '
        jobcount                          = J
        jobname                           = JN
      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                         = 'X'
      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                      =
    IMPORTING
      JOB_WAS_RELEASED                  =
    CHANGING
      RET                               =
    EXCEPTIONS
      CANT_START_IMMEDIATE              = 1
      INVALID_STARTDATE                 = 2
      JOBNAME_MISSING                   = 3
      JOB_CLOSE_FAILED                  = 4
      JOB_NOSTEPS                       = 5
      JOB_NOTEX                         = 6
      LOCK_FAILED                       = 7
      INVALID_TARGET                    = 8
      OTHERS                            = 9
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    BREAK-POINT.
    regards,
    amit m.

  • JOB_OPEN JOB_SUBMIT JOB_CLOSE

    Hello Experts,
    I have a requirement where I want to execute a portion of my code in the background inorder to reduce the performance issue.
    This can be done through JOB_OPEN JOB_SUBMIT JOB_CLOSE command which generates a new JOB in the  background mode.
    JOB_OPEN
    JOB_SUBMIT
    JOB_CLOSE
    Question : How can I pass the internal table with the values through JOB_SUBMIT??
    Thanking you all in advance,
    Warm Regards,
    gayatri.

    Hi,
    * Get Print Parameters
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING
          no_dialog      = 'X'
        IMPORTING
          valid          = g_valid
          out_parameters = gs_params.
    * Open Job
    *  g_stim = '185800'.
      CONDENSE g_var6.
      CONCATENATE g_var8+6(2)
                  g_var8+3(2)
                  g_var8(2)
              INTO g_stim.
      g_sdat = sy-datum .
      CALL FUNCTION 'JOB_OPEN'
        EXPORTING
          jobname          = g_job
          sdlstrtdt        = sy-datum
          sdlstrttm        = g_stim
        IMPORTING
          jobcount         = g_jobcount
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 4.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CONDENSE : g_var1,
                 g_var2,
                 g_var3,
                 g_var4,
                 g_var5,
                 g_var6,
                 g_var7,
                 g_var8.
      gs_rspar-selname = 'P_USER'.
      gs_rspar-kind = 'P'.
      gs_rspar-low  = g_var1.
      APPEND gs_rspar TO gt_rspar.
      gs_rspar-selname = 'P_PWD'.
      gs_rspar-kind = 'P'.
      gs_rspar-low  = g_var2.
      APPEND gs_rspar TO gt_rspar.
      gs_rspar-selname = 'P_HOST'.
      gs_rspar-kind = 'P'.
      gs_rspar-low  = g_var3.
      APPEND gs_rspar TO gt_rspar.
      gs_rspar-selname = 'P_FILE'.
      gs_rspar-kind = 'P'.
      gs_rspar-low  = g_var4+2.
      APPEND gs_rspar TO gt_rspar.
      gs_rspar-selname = 'P_FNAME'.
      gs_rspar-kind = 'P'.
      gs_rspar-low  = g_var5.
      APPEND gs_rspar TO gt_rspar.
      gs_rspar-selname = 'P_FILE1'.
      gs_rspar-kind = 'P'.
      gs_rspar-low  = g_var6.
      APPEND gs_rspar TO gt_rspar.
      gs_rspar-selname = 'P_FILE2'.
      gs_rspar-kind = 'P'.
      gs_rspar-low  = g_var7.
      APPEND gs_rspar TO gt_rspar.
      gs_rspar-selname = 'P_DEST'.
      gs_rspar-kind = 'P'.
      gs_rspar-low  = 'SAPFTPA'.
      APPEND gs_rspar TO gt_rspar.
      gs_rspar-selname = 'P_COMP'.    <----- This are Parameter value to be passed in background Program
      gs_rspar-kind = 'P'.
      gs_rspar-low  = 'N'.
      APPEND gs_rspar TO gt_rspar.
      SUBMIT ztest123 VIA JOB  g_job
           NUMBER  g_jobcount
    *                  USING SELECTION-SCREEN
                      WITH SELECTION-TABLE gt_rspar
                      TO SAP-SPOOL WITHOUT SPOOL DYNPRO
           SPOOL PARAMETERS gs_params
                      AND RETURN.
      CALL FUNCTION 'JOB_CLOSE'
          EXPORTING
            jobcount                          = g_jobcount
            jobname                           = g_job
            sdlstrtdt                         = g_sdat
            sdlstrttm                         = g_stim
    *     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
            INVALID_TARGET                    = 8
            OTHERS                            = 9

  • How can I erase a job in SM35 using the job_open and job_close functions?

    Hi!
    I call and execute a job in the SM35 transaction with the functions below, but how can I erase the job from SM35. Because when the functions are executed in the JOB_CLOSE the variable jobrele return me an 'X' that means that the job is executed but I see that the job is not erased from the transaction.
    Thanks for the help.
      CALL FUNCTION 'JOB_OPEN'
        EXPORTING
          jobgroup         = bi
          jobname          = jname
        IMPORTING
          jobcount         = jnumb
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 99.
    CALL FUNCTION 'JOB_SUBMIT'
      EXPORTING
        authcknam                         = sy-uname
        jobcount                          = jnumb
        jobname                           = jname
        REPORT                            = sy-repid
    IMPORTING
       STEP_NUMBER                        = v_step_number.
    EXCEPTIONS
       BAD_PRIPARAMS                     = 1
       BAD_XPGFLAGS                      = 2
       INVALID_JOBDATA                   = 3
       JOBNAME_MISSING                   = 4
       JOB_NOTEX                         = 5
       JOB_SUBMIT_FAILED                 = 6
       LOCK_FAILED                       = 7
       PROGRAM_MISSING                   = 8
       PROG_ABAP_AND_EXTPG_SET           = 9
       OTHERS                            = 10
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount                   = jnumb
          jobname                    = jname
          strtimmed                  = 'X'
          targetsystem               = batchsys
        IMPORTING
          job_was_released           = jobrele
        EXCEPTIONS
          cant_start_immediate       = 1
          invalid_startdate          = 2
          jobname_missing            = 3
          job_close_failed           = 4
          job_nosteps                = 5
          job_notex                  = 6
          no_release_privilege_given = 7
          OTHERS                     = 99.

    hi
    try this FM
    <b>BP_JOB_DELETE</b>
    the same  FM is also called in
    <b>
    SCMA_DELETE_JOB</b>
    plz reward if useful

Maybe you are looking for

  • How to merge the contents of two rows in ALV for particular column data

    Hi Experts, I have a requirement to merge various rows in a ALV Grid with same data for particular columns. Kindly Suggest, Thanks and Best Regards, Sahil

  • CALL_FUNCTION_NOT_FOUND  with CX_SY_DYN_CALL_ILLEGAL_FUNC exception.

    The function module "ZPOPUP_WITH_TABLE_DISPLAY" was called, but cannot be found in the Function Library. An exception occurred. This exception is dealt with in more detail below . The exception, which is assigned to the class 'CX_SY_DYN_CALL_ILLEGAL_

  • Access database in a WAN

    Hello: I have to develop an application in Director that will use one Access Database in two LAN in different cities. So I will need to connect these LAN's via Internet. (10 users in every LAN with XP client) Do you think DatagripNet is OK for this p

  • Another HTML editor

    I am trying to find a cheap alternative to DW as I use DW for my job however my content writer needs an editor as our newsletter wysiwyg is very unstable and cannot hold complex tables. I suggested editing the newsletter in an editor and pasting the

  • ADF input label rendered but input value not

    I based my search page on SRDemo template. In the first panel where I enter search criteria I have the following: <af:panelBox> <af:panelForm> <af:inputText value="#{bindings.partialName.inputValue}" label="#{bindings.partialName.label}" required="#{