Submitting background jobs using an excecutable program

Hi all
Would anyone give an example program to submit jobs in background using job_open, job_submit, job_close F.M's,
please dont give complex coded program,  easily understandable code with some useful comments will be apprecieated.
Thanks

Create a job using job_open
Create your job with JOB_OPEN. The module returns a unique job
number. Together with the jobname, this number identifies the
job. Other parameters are available, but are not required.
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.
Adding job step
Add a job step: ABAP program
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
AUTHCKNAM = SY-UNAME " Runtime authorizations
" user
JOBCOUNT = JOBNUMBER " Value from JOB_OPEN
JOBNAME = JOBNAME " Value from JOB_OPEN
REPORT = 'REPORT' " Report to be run
VARIANT = 'VARIANT' " Variant to use with
" report
PRIPARAMS = USER_PRINT_PARAMS " User printing options
ARCPARAMS = USER_ARC_PARAMS " User archiving options
" Both sets of options
" come from
" GET_PRINT_PARAMETERS
EXCEPTIONS
BAD_PRIPARAMS = 01
INVALID_JOBDATA = 02
JOBNAME_MISSING = 03
JOB_NOTEX = 04
JOB_SUBMIT_FAILED = 05
LOCK_FAILED = 06
PROGRAM_MISSING = 07
PROG_ABAP_AND_EXTPG_SET = 08
OTHERS = 99.
IF SY-SUBRC > 0.
<Error processing>
ENDIF.
**Closing job
Submit job for processing: immediate start
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = JOBNUMBER " Job identification: number
JOBNAME = JOBNAME " and name.
STRTIMMED = 'X' " Schedules the job for
" immediate start. The job
" is started immediately
" only if the user has the
" RELE authorization to
" release a job to run.
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
CANT_START_IMMEDIATE No longer used. Replaced by IMPORTING
parameter JOB_WAS_RELEASED.
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.
*Please note it's not my original code..I have done what you could do!! Just visited help.sap.com and typed Background jobs and got sample codes..

Similar Messages

  • Schedule Background job using transaction CATM

    Hi all,
    Since we cannot schedule a background job using transaction CATM, I have created a program calling the CATM transaction through batch-input.
    I have done a recording and entered the coding in a Z-program. For a vendor, I have recorded time in CAT2 for multiple purchase orders.
    After entering the vendor number in CATM, all the purchase orders showed up. I have clicked 'select all' and posted.
    When I run the program in the background, it posts only for one purchase order.
    When I  run the program in the foreground, using the Select All-button it only proceeds with the first line in my list of PO's.
    How to read the whole stack and post the whole stack of purchase orders? 
    Please help me out with this.
    Thanks
    Regards
    Srinivasan Desingh
    408 368 3837

    Hi,
    When I run the program in the background, it posts only for one purchase order.
    When I  run the program in the foreground, using the Select All-button it only proceeds with the first line in my list of PO's.
    See..it's a Z-program so Its difficult to answer without checking the program. But I think, you should check your BDC again from Debugging, with the help of your abaper. You will find, why its is processing only one entry.
    Regards
    Shishir

  • Simultaneous background jobs using the same BAPI issue

    I scheduled 2 simultaneous background jobs on a custom program using the same BAPI (closing PM orders).
    Run 1 to CLSD orders created on year 2001
    Run 2 to CLSD orders created on year 2000
    What happened was while run 1 was still active, run 2 encountered a dump and was cancelled.
    Upon checking in ST22, dump was generated in CO_ZV_CONSISTENCY_CHECK.
    Also, Run 2's dump happened when it encountered a data inconsistency for an order number being processed for Run 1.
    Since the BAPI is being accessed at the same time by the two jobs, Is it possible that the commit work on run 1 could affect the processing for the Run 2, hence the data inconsistency?
    Is this a buffer issue?
    Additionally, no dump is encountered when Run 1 or Run 2 is run by itself.
    I also encountered this issue before for creating Project and WBS using BAPI, but the solution we came up with was not to do parallel runs to avoid the error as this was a one time upload only.

    If the second job is dependent on the 1st job, then use following logic which will let you know the status of 1st job. Once 1st job is completed, call JOB_OPEN of 2nd job.
    ENDLESS loop till 1st job is completed
    DO.
    CALL FUNCTION 'BP_JOB_READ'
        EXPORTING
          job_read_jobcount     = w_jobcount
          job_read_jobname      = w_jobname
          job_read_opcode       = '20'
        IMPORTING
          job_read_jobhead      = wa_jobhead
        TABLES
          job_read_steplist     = i_jobsteplist
        EXCEPTIONS
          invalid_opcode        = 1
          job_doesnt_exist      = 2
          job_doesnt_have_steps = 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.
    To Display the status text as per the status type
      CASE wa_jobhead-status.
        WHEN 'S'. WRITE: / text-006. "'Scheduled'.
        WHEN 'R'. WRITE: / text-007. "'Released'.
        WHEN 'F'. WRITE: / text-008. "'Completed'.
        WHEN 'A'. WRITE: / text-009. "'Cancelled'.
        WHEN OTHERS.
      ENDCASE.
    IF wa_jobhead-status = 'F'.
    exit.
    ENDIF.
    ENDDO.
    PERFORM OPEN_2nd_JOb.

  • Schedule background job using system variant

    Dear gurus,
    We're planning to schedule background job using system variant, for example, current fiscal year and current posting period (transaction AFAB). Is it possible? So for example, for this month, "Posting Period" value will be 6, and then next month will be 7.
    Can you tell me how to do this, if I want to set up the schedule only once?
    Thanks for your help.
    Best Regards,

    done using abap

  • How to schedule the background job using current selection screen field val

    Hello Friends,
    How to schedule the background job using current selection screen field values.
    after completion of the job the spool should be sent as a mail to SAP Inbox.
    Is there any way to create the variant dynamically by reading the current selection screen values.
    Thanks,
    Ravi

    Hi,
    To get the variant details you can use teh following FM.
    'RS_VARIANT_CONTENTS'.
    Regards,
    Ankur Parab

  • How to find Background job which is running program RSWUWFML2

    Hi Experts, i am trying to find which background job is running standard program 'RSWUWFML2', anyone can help on this?

    Go to SM37. Put * in the Job name and user name. The enter the program name in the last field.
    this should give you the job scheduled or running.

  • Problem in Submiting Background Job

    Hi,
    I am submitting a Program in Background  by using JOB_OPEN and SUBMIT Program and JOB_CLOSE.
    After submiting Job was terminated with following log.
    04/07/2009 11:34:05 Job started                                                                                00           516          S
    04/07/2009 11:34:05 Step 001 started (program YSDU_CUSTOMER_DUP_CHECK, variant &0000000000002, user ID JAGASEK)      00           550          S
    04/07/2009 11:34:05 Cannot perform frontend function in batch input mode                                             FES          002          E
    04/07/2009 11:34:05 Job cancelled after system exception ERROR_MESSAGE                                               00           564          A
    Please help me.
    Thanks,
    Sekhar.J

    Hi sekhar J,
    It looks to me like you may be calling a function from SFES (SAP FrontEnd Services) e.g. FM GUI_UPLOAD, these cannot be used in background mode for obvious reasons.  If the program is reading/writing a local file you will need to use a dataset on the application server instead.  If ths is the case there are plenty of posts cocerning datasets on sdn.
    Regards,
    Simon

  • Creating a Step for Background Job from within ABAP Program

    Step-1: I have a Report in ECC, which is scheduled as Background Job, which writes the file to the Application Server(UNIX)
    Step-2:  Trigger a Unix Command to ftp the file to other server.
    Both Step-1 & Step-2 can be done from SM36. 
    Another Scenario:
    Users can run the report in background from SE38 or using the transaction code for the report, In this case we want to call the external command.
    Instead of calling the External Command as below in the report, I want to create a Step from within the program when it is scheduled in background mode.
    CALL 'SYSTEM' ID 'COMMAND' FIELD lc_unixcom.    [ Here lc_unixcom has the External Command ].
    Any ideas??? Appreciate help.

    Hi,
    For submitting a report step, you may use either SUBMIT ... VIA JOB ... or JOB_SUBMIT function module.
    For external commands, this should be done only by calling JOB_SUBMIT function module.
    Sandra

  • How to cancel the background job processing in ABAP programming?

    Hi,
    I have a requirement where i need to cancel the job depending on some constraint. My code is something like this:
    Select some data from the table.
    if sy-subrc = 0.
    Do nothing.
    Else
    Cancel the job
    call function 'BP_JOB_ABORT'
      exporting
       jobcount                         = number
        jobname                          = name
    EXCEPTIONS
       CHECKING_OF_JOB_HAS_FAILED       = 1
       JOB_ABORT_HAS_FAILED             = 2
       JOB_DOES_NOT_EXIST               = 3
       JOB_IS_NOT_ACTIVE                = 4
       NO_ABORT_PRIVILEGE_GIVEN         = 5
       OTHERS                           = 6
    The above code is cancelling the job but it is throwing an exception called CX_SY_DYN_CALL_PARAM_MISSING because i dint pass job count. How can we find the job count of next job that is going to run? Or How to handle the exception which it is throwing. Even if i try to handle that exception something like this:
    TRY
    call function 'BP_JOB_ABORT'
      exporting
       jobcount                         = number
        jobname                          = name
    EXCEPTIONS
       CHECKING_OF_JOB_HAS_FAILED       = 1
       JOB_ABORT_HAS_FAILED             = 2
       JOB_DOES_NOT_EXIST               = 3
       JOB_IS_NOT_ACTIVE                = 4
       NO_ABORT_PRIVILEGE_GIVEN         = 5
       OTHERS                           = 6
    RAISE EXCEPTION TYPE CX_SY_DYN_CALL_PARAM_MISSING.
    CATCH
    CX_SY_DYN_CALL_PARAM_MISSING.
    ENDTRY.
    It avoids the exception but it doesnt cancel the job.  I even tried with function modules like JOB_OPEN
    JOB_SUBMIT,BP_JOB_SELECT,BP_JOB_ABORT and tried to build some logic using status overview table (TBTCO) and TBTCP (Jobstep overview table).
    Can someone suggest me the right way to write this program ?
    Thanks in advance.
    Rashmi

    Hi,
    Problem is solved.
    Create an background job with 2 steps. The first step in the background job calls the program ZBACKJOB_STEP1.  In the variant we have a wrong material number
    If the material number is not found in Mara, the next step in the job should not get executed and the job should get cancelled..
    In the above posts i had asked how do I get the job count of the job that is currently triggering the program at the runtimeu2026..If u see the below code uu2019ll get to know.. We have to use the standard structure TBTCM which captures the properties/characteristics of the job.
    REPORT ZBACKJOB_STEP1.
    TABLES: MARA,TBTCM.
    PARAMETERS : MATNR TYPE MATNR.
    START-OF-SELECTION.
      SELECT SINGLE * FROM MARA WHERE MATNR = MATNR.
      IF SY-SUBRC IS INITIAL.
        WRITE / : 'This is the material selected on the selection-screen' , MARA-MATNR.
    ELSE.
            CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
          IMPORTING
            EVENTID                                    = TBTCM-EVENTID
            EVENTPARM                             = TBTCM-EVENTPARM
            EXTERNAL_PROGRAM_ACTIVE = TBTCM-XPGACTIVE
            JOBCOUNT                                = TBTCM-JOBCOUNT
            JOBNAME                                  = TBTCM-JOBNAME
            STEPCOUNT                              = TBTCM-STEPCOUNT
          EXCEPTIONS
            NO_RUNTIME_INFO                    = 1
            OTHERS                                     = 2.
        IF SY-SUBRC = 0.
          CALL FUNCTION 'BP_JOB_ABORT'
            EXPORTING
              JOBCOUNT                                     = TBTCM-JOBCOUNT
              JOBNAME                                       = TBTCM-JOBNAME
            EXCEPTIONS
              CHECKING_OF_JOB_HAS_FAILED  = 1
              JOB_ABORT_HAS_FAILED              = 2
              JOB_DOES_NOT_EXIST                   = 3
              JOB_IS_NOT_ACTIVE                      = 4
              NO_ABORT_PRIVILEGE_GIVEN       = 5
              OTHERS                                         = 6.
          IF SY-SUBRC <> 0.
          ENDIF.
        ENDIF.
      ENDIF.
    Regards,
    Rashmi

  • Problem with background job using SUBMIT under different user

    Hi All,
    I am submitting a background job under different user name. I am submitting this job by using JOB_OPEN , SUBMIT report and JOB_CLOSE. But submit statement is returning sy-subrc 8, becuase of this the job_close is failed. Can you please help me to solve this problem.
    Thanks in advance.
    Tjgupta

    Hi,
    The user is having all authorizations. is there any difference with user types?
    This user is having  user type " as communication data".
    Thanks,
    Tjgupta

  • How to schedule a background job using the Event concept..?

    Hi Folks,
    I have a requirement that, I need a schedule a background job.
    Once after the previous job successful only, new job should get triggered. How to go ahead with this..?
    For Eg, I am scheduling a job called ZTEST periodically for 1 minute. If the job is not get completing with in 1 minute, I dont want to start my new job. Only after the success of my old job, I want my new job to run.
    Waiting for ur replies.
    Regards,
    Savi.

    Hi,
    You can use events that have already been defined, or you can create new events for scheduling background jobs.
    If you wish to use new events, do the following to implement the event scheduling:
    Define and transport the event as a user event with transaction SM62.
    You must define only event IDs; event arguments are not defined in the R/3 System. Instead, you specify event arguments when you schedule a job to wait for an event and when you trigger the event.
    If you define a new event, you must also transport it to your production systems. The event transaction does not have a connection to the transport system. Instead, you must create a transport request for the event yourself.
    Do this to transport an event:
    Create a transport request.
    Start the editor in the transport request and enter the following:
    R3TR TABU <table name> where table name is BTCSEV for a system event ID, BTCUEV for a user event ID.
    Press F2 with the cursor on the table name to call up the screen for specifying the table entries to transport. In this screen, enter the event ID’s that you have created.
    Save and release the transport request. Ensure that it is imported into your production system(s).
    To trigger an event, add:
    – the function module BP_EVENT_RAISE to your ABAP program, or
    – the program SAPEVT to your external script, batch file, or program.
    When your programs execute these keywords, an event will be triggered in the R/3 background processing system. The event-based scheduler is started immediately. It in turn starts all jobs that were waiting upon the event, subject to normal background processing restrictions, such as the requirement that the job has been released to start.
    Schedule the jobs that are to run when your events are triggered.
    You can schedule jobs for one-time start or to be started whenever an event is triggered.
    Regards,
    Raj.

  • Background Job call from a program

    Hi all,
    We have a program which runs for max of 5 minutes (say).
    It is scheduled to run every minute in SM36 so that it keeps continuing to run.
    But sometimes even when the previous job is running the one starts up, thereby creating inconsistent results.
    So we need to call the job from the running program itself.
    How should we go abt this ? Is there any other way available to solve this ?
    Thanks in Advance,
    Regards,
    Vivek K

    Hi,
    Managing Jobs from the Job Overview
    Use
    The Job Overview, or Job Maintenance, screen is the single, central area for completing a wide range of tasks related to monitoring and managing jobs, including defining jobs; scheduling, rescheduling, and copying existing jobs; rescheduling and editing jobs and job steps; repeating a job; debugging an active job; reviewing information about a job; canceling a job's release status; canceling and deleting jobs; comparing the specifications of several jobs; checking the status of jobs; reviewing job logs; and releasing a job so it can run.
    Procedures
    Specifying Jobs
    To display the Job Overview screen, choose CCMS ® Jobs ® Maintenance or call Transaction SM37. Before entering the Job Overview screen, the system first displays the Select Background Jobs screen, where you must select the criteria for the jobs you want to manage. These criteria include:
    Job name (which can contain a wildcard (*) to select jobs with related names oru2014by using the wildcard aloneu2014any job). Required.
    Name of the user who scheduled the job (the wildcard is allowed here as well). Required.
    Job status
    Planned or actual start time of the job.
    Job start condition or event linked to the start condition
    Job step
    When and how often the job runs, or " periodicity"
    You can also choose Extended Job Selection, where you can more precisely define the specific criteria that determine which jobs to select. If you have administrator Authorizations for Background Processing, you can display jobs in all clients. Without this authorization, only jobs in the client that you are logged on to will be displayed.
    Once you have set the criteria for you job selection, choose Execute.
    Managing and Monitoring Jobs
    Once you have called the Job Overview screen (Transaction SM37 or CCMS ® Jobs ® Maintenance) and selected which jobs you want to manage as described above, you can choose from a wide range of management tasks.
    To copy a single existing job, choose Job ® Copy.
    To reschedule or edit job steps or attributes of a single job, choose Job ® Change. A job step is an independent unit of work within a background job. Each job step can execute an ABAP or external program. Other variants or authorizations may be used for each job step. The system allows you to display ABAP programs and variants. You can scan a program for syntax errors. You can also display the authorizations for an authorized user of an ABAP job step.
    To repeat a single job, choose Job ® Repeat scheduling.
    To debug an active job, choose Job ® Capture: active job. Only a single selection is allowed. If an active job seems to be running incorrectly (e.g., running for an excessively long time), you can interrupt and analyze it in debugging mode in a background process, and then either release it again or stop it altogether.
    You will be able to capture a background job only if you are logged on to the SAP server on which the job is running. To find server information in the Job Overview, select and mark the job, then choose Job ® Job details.
    To review information about a job, choose Job ® Job details. Details displayed can include:
    current job status
    periodicity, or the repetition interval
    other jobs linked to the current job, either as previous or subsequent jobs
    defined job steps
    spool requests generated by the current job
    To cancel a job's "Released" status, select the job or jobs from the Job Overview list and choose Job ® Release -> Scheduled.
    To cancel a job from running but keep the job definition available, select the job or jobs from the Job Overview list and choose Job ® Cancel active job.
    To delete a job entirely, select the job or jobs from the Job Overview list and choose Job ® Delete. Jobs with the status of Ready or Running cannot be deleted.
    To compare the specifications of more than one job, select the jobs from the Job Overview list and choose Job ® Compare jobs.
    To check the status of jobs, select the job or jobs from the Overview Job list and choose Job ® Check status. This allows you to either change the job status back to Planned or cancel the job altogether. This is especially useful when a job has malfunctioned.
    To review job logs, select a job or jobs with the status Completed or Canceled from the Job Overview list and choose Goto ® Job log.
    To release a job so it can run, select a job from the Job Overview list and choose Goto ® Release.
    Regards,
    Jagadish

  • Scheduling a background job using Job_Submit and Job_Close FM

    Hi Guys,
                  I am calling a report in background using Job_Submit and Job_Close FM's.
    I am not providing start time and date in the Job_close FM, in this case, when the job will be scheduled to start.
    Even after an hour, job status is still scheduled.
    I am not exporting variant, since I am using memory ID.
    Thanks
    Edited by: sapgeek007 on May 11, 2009 4:11 AM

    In Job_close fm use the parameter 'STRTIMMED'
    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount                          = LV_NUMBER
        jobname                           = LV_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
       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.
    That would start the background job immediately.
    Regards,
    Deepak

  • Find background job ID (BTCJOBCNT) within program at runtime.

    Hello,
    Can a program find out what background job ID is has been assigned? Keeping in mind that multiple jobs can be released and active at the same time.
    Thanks!
    Andre

    Thanks but that FM gives me all jobs that have that program. In my scenario, there could be multiple jobs running at the same time. I want/need to find the respective job ID for the program.
    Here is the big picture: This program needs to run in exclusivity. Job scheduling is automated and out my control. Because of execution delays, some job may start at the same time. In that case BP_FIND_JOBS_WITH_PROGRAM will tell me another job is active and I will stop the processing of the current job. However, this logic will apply for the second (and third) job and they will also be stopped. I'm hoping to get the Job Id so I can keep the earliest job (or other criteria) running.
    Thanks,
    Andre

  • Background Job using JOB_OPEN & JOB_CLOSE

    Experts,
    I have coded a program in SE38 which calls other program to be scheduled in background using JOB_OPEN , SUBMIT, & JOB_CLOSE. Now my requirement is to send an email to the person who runs (schedules)  a job in background by Email (SAP Inbox or office email-ID) of completion of the job. how do i do that?
    Kindly send me your solutions.
    Thanks.

    Here is some code that will determine when a job has completed.  We use this daily.
    Bruce
    start-of-selection.                                        
      perform 1000_submit_program.
      perform 2000_send_email.
    end-of-selection.
    *>>>>>>>>> S T A R T   O F   F O R M S <<<<<<<
    *&      Form  1000_SUBMIT_Program
    form 1000_submit_program.
      concatenate 'Program' p_pgm 'finished.'
                            into w_subject separated by ' '.
    *>> concatenate "Submit Program " and the first 17 characters
    *>> of the program into the job name parameter
    *>> eg "Submit Program ZFAPR061         "
      concatenate p_jobnam(15) p_pgm(17) into p_jobnam separated by ' '.
      call function 'JOB_OPEN'
        exporting
          jobname          = p_jobnam
        importing
          jobcount         = w_jobcount
        exceptions
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          others           = 4.
      if sy-subrc <> 0.
        case sy-subrc.
          when 1.
            w_code = 'cant_create_job'.
          when 2.
            w_code = 'invalid_job_data'.
          when 3.
            w_code = 'jobname_missing'.
          when 4.
            w_code = 'others'.
        endcase.
        message i000 with 'JOB_OPEN Error   ' w_code  '  Program aborted'.
        format color  col_negative.
        skip 2.
        write: / 'Program aborted.'.
        write: / 'Function JOB_OPEN Error  ', w_code.
        stop.
      endif.        " sy-subrc ne 0
      format color  col_normal.
      translate p_pgm to upper case.
      get time  field w_start .                 " program started
      submit (p_pgm)
             to sap-spool
                destination p_prtr
                immediately ' '
                keep in spool 'X'
                without spool dynpro
             user sy-uname via job p_jobnam  number w_jobcount
             using selection-set p_var
             using selection-sets of program p_pgm
             and return.
      skip 2.
      write: / ' SUBMIT parameters after submit:'.
      write: /4 'user       ', sy-uname.
      write: /4 'job        ',  p_jobnam.
      write: /4 'jobcount   ', w_jobcount.
      write: /4 'program    ', p_pgm.
      write: /4 'variant    ', p_var.
      call function 'JOB_CLOSE'
        exporting
          jobname              = p_jobnam
          jobcount             = w_jobcount
          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.
        case sy-subrc.
          when 1.
            w_code = 'cant_start_immediate'.
          when 2.
            w_code = 'invalid_startdate'.
          when 3.
            w_code = 'jobname_missing'.
          when 4.
            w_code = 'job_close_failed'.
          when 5.
            w_code = 'job_nosteps'.
          when 6.
            w_code = 'job_notex'.
          when 7.
            w_code = 'lock_failed'.
          when 8.
            w_code = 'others'.
        endcase.
        message i000 with 'JOB_CLOSE Error  ' w_code  '  Program aborted'.
        skip 2.
        format color  col_negative.
        write: / 'Program aborted.'.
        write: / 'Function JOB_CLOSE Error  ', w_code.
        stop.
      endif.
      format color  col_normal.
      skip 2.
      write: / ' JOB_CLOSE values after call:'.
      write: /4 'jobname    ', p_jobnam.
      write: /4 'jobcount   ', w_jobcount.
    w_jobhead-status possible values
        btc_running       like tbtco-status value 'R',
        btc_ready         like tbtco-status value 'Y',
        btc_scheduled     like tbtco-status value 'P',
        btc_released      like tbtco-status value 'S',
        btc_aborted       like tbtco-status value 'A',
        btc_finished      like tbtco-status value 'F',
        btc_put_active    like tbtco-status value 'Z',
        btc_unknown_state like tbtco-status value 'X'.
    Wait for a while so job can finish
      while ( not w_jobhead-status = 'F' ) and
            ( not w_jobhead-status = 'A' ).
        call function 'BP_JOB_READ'
          exporting
            job_read_jobcount     = w_jobcount
            job_read_jobname      = p_jobnam
            job_read_opcode       = '20'
          importing
            job_read_jobhead      = w_jobhead
          tables
            job_read_steplist     = i_int_job_read_steplist
          exceptions
            invalid_opcode        = 1
            job_doesnt_exist      = 2
            job_doesnt_have_steps = 3
            others                = 4.
        if w_jobhead-status =  'F'.            " F = Finished
          exit.
        elseif w_jobhead-status = 'A'.         " A = Aborted
          message e935 with 'BP_JOB_READ function Aborted.'
                            'Status is '
                            w_jobhead-status
        else.
        wait up to 300 seconds.
          wait up to p_wait seconds.
        endif.
      endwhile.
      if w_jobhead-status <> 'F'.
        write: / 'status', w_jobhead-status.
        message e935 with
            'BP_JOB_READ function did not complete successfully'
                    w_jobhead-status.
      endif.
      get time.              " program finished
      skip 2.
      format color off.
    endform.                    " 1000_SUBMIT_Program

Maybe you are looking for

  • Business Rules Instance disappeard in projects folder in Shared Services

    Hi all, I have this strange thing happend to me today morning. when i logged into the Shared Services i can find the Business Rules folder but i couldnt find the instance for it.Is there any way i can reconfigure it so that i can see the instance bac

  • HT1386 How can i get all my songs transfered onto the computer from Ipod classic so that my new ipod and my spouse can get the songs??

    Hello How can I transfer my songs off my old Ipod classic to the computer so that I can pick them up with my new Ipod 4.  Also I want to transfere some songs to my spouses Ipod 5.  Please let me know what I can do... Thank you.. Alexandra

  • Does iMovie 08 actually work at all?

    Long story short, I was trying to make a dvd of some old movies of our family for my daughter's upcoming wedding. The movies are in .mpg format. iMovie won't import them as .mpg. After reading some articles and forum posts I googled, I've used MPEG S

  • Need to order hard drive

    I need a hard drive for a HP Pavillion dv2620us and possibly new OS disc I can't get any of my recovery disc to work, did a hard drive test and it failed. I had vista can it be upgraded to 7 ? Why is it so hard to find what you need on this site. I'v

  • Create Link in ESS Portal

    hi people, im trying to integrate an external link in our ess portal. how do i do that? i startet with creating a ressource with a url to a picture somewhere in the internet. then i createt a new service and a new sub-area. i linked the ressource to