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.

Similar Messages

  • Purpose of JOB_OPEN, JOB_CLOSE..?

    Hi All,
    What is the exact purpose of the below FMu2019s..?
    JOB_OPEN
    JOB_CLOSE
    Puppy.

    Hello,
    We ever u want to create the session in ths SM37 transation u have to use these FMs.
    JOB_OPEN
    Use JOB_OPEN to create a background job
    The function module returns the unique ID number which, together with the job name, is required for identifying the job.
    Once you have "opened" a job, you can add job steps to it with JOB_SUBMIT and submit the job for processing with JOB_CLOSE.
    JOB_CLOSE
    This is used to close the job which is opened.
    JOB_SUBMIT is used to submit the job.
    Example Programs.
    You will know how to use this FMs
    RSMODWRD

  • 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

  • Background jobs

    Hi,
            We can schedule the programs or transactions in background through SM36 and we can see the status through SM37.Then what is the use of FM's JOb_open,Job_submit and Job_close.When we will use these FM's.
    Can anybody tell me the difference between these two methods for scheduling the jobs in background....with sample code if possible
    Thanks & Regards,
    Rakesh.

    hi,
    chk this,
    call funcatio.
    ****Open a job to submit the Post Program into
    call function 'JOB_OPEN'
    exporting
    jobname = jobname
    importing
    jobcount = jobcount
    exceptions
    cant_create_job = 1
    invalid_job_data = 2
    jobname_missing = 3
    others = 4.
    if sy-subrc 0.
    raise job_open_failed.
    endif.
    submit zefu_currency_load_callbak_ack
    via job jobname
    number jobcount
    with com_num = com_num
    with relay_nu = relay_num
    and return.
    if sy-subrc 0.
    raise job_step_failed.
    endif.
    ****Close the Job and start it immediately
    call function 'JOB_CLOSE'
    exporting
    jobcount = jobcount
    jobname = jobname
    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.
    raise job_close_failed.
    endif.
    Also,
    Create a Variant for the Program and
    Schedule JOB in background:
    Go to SM36 create a Job
    enter Program and Variant for that program in STEP..
    click on Start Condition
    Click on DATE and TIME enter date scheduled Start and END times
    click on Period Values
    Click on HOURLY/WEEKLY etc
    CLick on RESTRICTIONS also to use further criteria.
    so your job will be scheduled and run as per your requirement.
    and in SM37 Transaction check the status of that JOB
    Check this link for scheduling jobs..
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c4/3a7f87505211d189550000e829fbbd/content.htm
    You can also use the fun modules JOB_OPEN,JOB_CLOSE etc for job
    scheduling.
    hope this helps.
    regs,
    hema.

  • To delay a program submitted in background from another transaction.

    Hi All,
    There are 2 programs 'A' and 'B' . During execution of 'A' , 'B'  is called and submitted in background using FM Job_open & Job_close and submit query.
    My requirement is to Delay the Program 'B' by 2-3 mins without delaying Program 'A' .
    I tried using FM JOB_OPEN export condition sdlstrttm   = w_starttm but was of no help.
    I also tried using statement wait up to 120 seconds but this also makes wait to program 'A'.
    Please suggest solutions to this.
    Regards,
    Nibha

    Hi Prashant,
    I am not able to understand ur suggestion.
    My piece of code is
        call function 'JOB_OPEN'
          exporting
            jobname          = 'YI90C_BG'
           sdlstrtdt        = w_startdt
           sdlstrttm        = w_starttm
          importing
            jobcount         = job_count
          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.
        if sy-subrc = 0.
          submit ympic_source_list_contr_upload
          with selection-table it_selcr
          and return
          via job 'YI90C_BG'
          number job_count.
          if sy-subrc = 0.
            call function 'JOB_CLOSE'
              exporting
                jobcount             = job_count
                jobname              = 'YI90C_BG'
                strtimmed            = 'X'
              importing
                job_was_released     = w_status
              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.
          endif.
        endif.
    Please tell what changes should I make?
    Regards,
    Nibha

  • Write to job log

    Hi,
       I am running report in background have used job_open,job_close and submit statement.Actally in my scenario 2 report are running so 2 spool number is getting generate

    Hi,
    Use the following code :
    Afterthe SUBMIT stmt, read the joblog of the called program within the calling program and get the spool numbers.
        CALL FUNCTION 'BP_JOBLOG_READ'
          EXPORTING
            client                = sy-mandt
            jobcount              = g_jcount
            jobname               = g_jbname
          TABLES
            joblogtbl             = g_t_joblogtbl
          EXCEPTIONS
            cant_read_joblog      = 1
            jobcount_missing      = 2
            joblog_does_not_exist = 3
            joblog_is_empty       = 4
            joblog_name_missing   = 5
            jobname_missing       = 6
            job_does_not_exist    = 7
            OTHERS                = 8.
        IF sy-subrc EQ 0.
    * Looping at the internal table for the joblog the messages are reported
    * to build the joblog in calling program
          LOOP AT g_t_joblogtbl INTO g_wa_joblogtbl.
            MESSAGE g_wa_joblogtbl-text TYPE 'I'.
            FIND 'Spool request'(011) IN g_wa_joblogtbl-text.
            IF sy-subrc EQ 0.
    * Find for the spool numbers in the joblog table and append the numbers
    * in the internal table g_t_spool
              FIND '0' IN g_wa_joblogtbl-text MATCH OFFSET g_moff.
              g_wa_spool-listident = g_wa_joblogtbl-text+g_moff(10).
              APPEND g_wa_spool TO g_t_spool.
            ENDIF.
          ENDLOOP.

  • Issue in Foreground Report executing as background

    I have developed a Report in ABAP which has a selection screen and 2 radiobuttons
    Foreground
    Background
    The report basically reads a TXT file from Desktop and calls a standard BAPI.
    In foreground, I have no issues i.e. I browse the call from desktop and call GUI_UPLOAD and so on
    However, in background, I am confused how to proceed??
    Please note: Report is still running in foreground mode i.e. i am browsing the file. Its just that i have selected background Radiobutton
    Can anyone tell me how to proceed i.e. to execute in background.
    Do I need to submit the same program via JOB_OPEN JOB_CLOSE in background and then exit??
    Please advice

    Hi Razdan,
    If want to schedule the background job through the program, then you can try method explained in below links. Here you might have to create a separate program to submit.
       https://help.sap.com/abapdocu_70/en/ABAPSUBMIT_VIA_JOB.htm
       http://scn.sap.com/thread/590077
      Another approach would be like below
    Add an additional field apart from the radio button, say “ip_file” in the selection screen. This you can show while selecting the radio button “background”
    Suppose if you have updated the file in app. Server(AL11 ) , in a location , say ( “home/myfile/test.txt” ) .
    Save a variant with the radio button “background” selected and input field ip_file value as   “home/myfile/test.txt”.
    Now from the SM36 you can schedule the background job to run the report with the same variant.
    Please note that , here you need to upload the file separately to app. Server using , tcode - CG3Z or any other FM. And in the program you can use open dataset to access the file in the app. Server.

  • Regarding email generation with attachment

    Hi Experts,
    1)   Iam sending an email with excel attachment by using the FM "SO_NEW_DOCUMENT_ATT_SEND_API1".
       My problem is for example if i have 5 lines in the email table then these 5 lines are showing in single in the excel.
    How can i rectify this?
    2)  i need to submit the report in the back ground with variant and with out selection screen.How to do this?  
    Rgds,
    Krishna.

    Hi,
      Append each line of ur text seperately in an internal table for eg.  
       objtxt = text-007.
      APPEND objtxt.
      CLEAR objtxt.
      APPEND objtxt.
      objtxt = text-008.
      APPEND objtxt.
      CLEAR objtxt.
      APPEND objtxt.
    *Function module to send email with an attachment
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = docdata
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = objpack
          object_header              = objhead
          contents_bin               = objbin
          contents_txt               = objtxt
          receivers                  = reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        MESSAGE s899(m3) WITH 'Mail sent successfully!'.
      ENDIF.
    Then u  ll get the mail the way u designed.
    The answer of ur 2nd question is........
    Specify the selection screen in ur program
    and use FMs 'JOB_OPEN' ,  'JOB_CLOSE' & 'JOB_SUBMT' to schedule the job in the background..
    regards,
    ajit.

  • Submit a job in background

    Hi,
    We have a query regarding submission of Jobs in background. If we use JOB_OPEN,JOB_CLOSE in our executable program to submit a job to run this proram with a transaction code and also schedule this job in background using SM36 the what will be the effect?

    Hi pankaj,
    1. If the program only display some data,
      and does not update anything,
      then nothing will go wrong.
    2. Both programs will run independently of each other,
      in background.
    regards,
    amit m.

  • Background job

    Hi Folks,
    I would like to have some clarification on Back ground job scheduling.
    I found 2 kind of possibilities for scheduling a program to run in back ground
    1.programatically  ( job_open , job_close)
    2.thorugh sm36 ( defining a job & scheduling)
    what is the dif between them?Is it only GUI advantage for 2nd option over 1st one?
    <b>Is there is any particular context to use above things specifically</b>
    <b>please list out the actual advantages of each option so that i can use them for my applications appropriatly...</b>
    Thanks in advance
    Raja.

    Hi again,
    1. make it periodical job..can't we run the report again and again depending up on our need??
    If the SCHEDULE is periodical,
      the report will automatically run again and again.
      (but not on our need, it will run
       at the pre-destined stiuplated time,
      eg. every hour, every day at 10:00 clock etc)
    2. suppose there is a standard report
      which prints out purchase order.
      now we want to develope a z program,
      which will have selection screen
      for multiple POs and it should generate
      the report and send mail !
    3. Then in this case,
      we develop the z program,
      and write code
      to submit the orignal po program,
       ONE BY ONE,
       using background concept.
    (here i mean multiple times)
    regards,
    amit m.

  • No result  when I submit in background job a Z transaction

    Hi,
    I design a screen with the screen painters for my Z report instead of using SELECTION-SCREEN command to build my screen of selection. In the PAI process, I launch the same report in backgound with JOB_OPEN,SUBMIT, JOB_CLOSE and nothing happens. I go to SM50 and no job is found and SM37 confirm me thatt the job has been launch and terminate without error.
    My report, when the background checkbox is checked, launch it-self in background to insert rows in 2 Z tables. Theses 2 tasks take time and are not possible to process in foreground and the user can't wait after the result. That is why I Submit my report in background.
    I made it in another program with a selection screen built with SELECTION-SCREEN command and I never had this problem.
    It is possible to do a selection screen with the screenpainters and launchable in background or it is only possible with SELECTION-SCREEN command.

    JOB_OPEN,SUBMIT, JOB_CLOSE and nothing happens. I go
    to SM50 and no job is found and SM37 confirm me thatt
    the job has been launch and terminate without error.
    In SM50 you can see the jobs only while they are running. Since there is an entry in SM37, it means that the job has been initiated, so something did happen. Check the job log for the details (I strongly advise to add some messages in your program to track the progress).
    You might also want to take a look at the FM SUBST_START_REPORT_IN_BATCH. Here is a code example that I've just written recently to force the report execution in the background (a message is displayed to the user but the report runs in a backrgound job):
    PARAMETERS: p_vkorg TYPE tvko-vkorg OBLIGATORY MEMORY ID vko.
    DATA: rspar TYPE TABLE OF rsparams,
          wa_rspar LIKE LINE OF rspar.
    START-OF-SELECTION.
    IF sy-batch IS INITIAL.
      wa_rspar-selname = 'P_VKORG'.
      wa_rspar-kind = 'P'.
      wa_rspar-low  = p_vkorg.
      APPEND wa_rspar TO rspar.
      CALL FUNCTION 'SUBST_START_REPORT_IN_BATCH'
        EXPORTING
          iv_repname                          = sy-repid
        TABLES
          tt_reportparam                      = rspar
       EXCEPTIONS
         variant_exist_check_failed          = 1
         variant_update_failed               = 2
         variant_update_not_authorized       = 3
         variant_update_no_report            = 4
         variant_update_no_variant           = 5
         variant_update_variant_locked       = 6
         variant_insert_failed               = 7
         variant_insert_not_authorized       = 8
         variant_insert_no_report            = 9
         variant_insert_variant_exists       = 10
         variant_insert_variant_locked       = 11
         variant_write_failed                = 12
         no_batch_service                    = 13
         no_server_list                      = 14
         batch_scheduling_failed             = 15
         OTHERS                              = 16
      IF sy-subrc = 0.
        MESSAGE ‘Report started in background’ TYPE ‘I’.
      ELSE.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ELSE.
    <do stuff here>
    ENDIF.
    SUBST_START_REPORT_IN_BATCH actually calls JOB_OPEN, JOB_CLOSE but I just find it easier to use one FM instead of 2-3.

  • Scheduled function module in background job

    HI all,
    I have created a function module(RFC) & Now I need to schedule it in background job, i have used fm job_open ,job_close  But through there i can only scheduled Reports  so pls gide me how to scheduled fm .
    regards,
    Anuj

    Hi Anuj,
    Check this one:
    Re: can i scheddule a function module(rfc)  in background
    Regards,
    Chandra Sekhar

  • How to schedule job to execute after 5 seconds gap using the program

    Hi ALL,
    How to schedule the program to run after 5 seconds to execute using JOB_OPEN,JOB_CLOSE,SUB_SUBMIT function modules in which parameter I should give this 5 secnods?
    Regards
    mahesh

    Hi,
    You can use the import parameters of function module JOB_CLOSE
    SDLSTRTDT & SDLSTRTTM
    to pass the required start date and time (respectively) of your background job. That is, if you want the job to be scheduled and start at a fixed time (as in your case 5 seconds in the future), you can determine the start date and time as 5 seconds ahead of sy-uzeit and pass the resultant values to the mentioned importing parameters.
    Cheers,
    Aditya

  • Run report in Backround and Save it automatic as Excel File

    I've created a report program that uses the alv grid. I run it in background, then i want to save it automatic as an excel file.
    can y help me
    Thanks

    Hi,
      When you run a report in background, irespective of the type of report, let it be Normal or ALV report, we have to use JOB FM's, such as JOB_OPEN, JOB_CLOSE. When you run a report in background, the data to be displayed is stored in the spool. So firt, you need to hold the spool data into an internal table, and then pass that internal table to GUI_DOWNLOAD, by hardcoding a path in the local system to download.
    Use this FM to hold the spool output in a internal table , RSPO_RETURN_SPOOLJOB.
    Hope this is helpful to you. If you need further information, revert back.
    Reward all the helpful answers.
    Regards
    Nagaraj T

  • How to create a Background Job?

    Hi All,
    A ABAP List report is taking too long to run. It takes nearly 5 mints sometimes it is halted by a timeout. I would like to run this report as a background job. What's the transaction I should use & could U give me the steps. Also is it possible to schedule the Job to run on 1st of every month.
    Thanks,
    Kishan

    1.programatically ( job_open , job_close)
    2.thorugh sm36 ( defining a job & scheduling)
    doing something programmatically certainly has an advantage of automation... there may be cases wherein depending on certain conditions u need to run different programs in the background.. so this can be incorporated in the program itself using if/else or other condition commands..
    there may be numerous other differences too.
    SM36 option is more of static one and programmitaclly is more on the fly scheduling a job.
    Using SM36, it not a one time thing. If you want program to run at a specific frequency, say every 24 hrs, that also can be done.
    1)data: sdate type sy-datum,
    stime type sy-uzeit,
    l_valid,
    ls_params like pri_params,
    l_jobcount like tbtcjob-jobcount,
    l_jobname like tbtcjob-jobname.
    start-of-selection.
    Get Print Parameters
    call function 'GET_PRINT_PARAMETERS'
    exporting
    no_dialog = 'X'
    importing
    valid = l_valid
    out_parameters = ls_params.
    Open Job
    l_jobname = 'ZRICH_0005'.
    call function 'JOB_OPEN'
    exporting
    jobname = l_jobname
    importing
    jobcount = l_jobcount.
    Submit report to job
    submit zrich_0005
    via job l_jobname
    number l_jobcount
    to sap-spool without spool dynpro
    spool parameters ls_params
    and return.
    Kick job off 30 seconds from now.
    sdate = sy-datum.
    stime = sy-uzeit + 30.
    Schedule and close job.
    call function 'JOB_CLOSE'
    exporting
    jobcount = l_jobcount
    jobname = l_jobname
    sdlstrtdt = sdate
    2)Use transaction SM36.
    http://help.sap.com/saphelp_bw30b/helpdata/en/c4/3a7f87505211d189550000e829fbbd/content.htm
    sdlstrttm = stime
    strtimmed = 'X'
    Please use T/code SM36> enter your Job name Starts with Z or Y Ex: ZTEST> STEP>ABAP Program> Define your Report /Variant--> Save.
    Start condition--> Press Date and Time > Enter your start date and time> Save
    Then Use SM37--To execute ur job
    Lanka

Maybe you are looking for

  • Create link when retreive from database

    Hi, I created database called "Homepage", and i created table called "homenews" inside of "homepage" database. I also created two column which is "News_Name" and "News_URL". I use dreamweaver and is works great when i retreive from databse, but i wan

  • Documents in BI

    Hi: Is there a way to load the attachment of a document in R/3 ( for example, the attachment of an invoice ) into BW? Thanks. Eric

  • Any ideas for when the ipod touch will come out? Thanks!:)

    Any ideas for when the ipod touch will come out? Thanks!:)

  • Error while moving to another tab

    Hi, i am facing the below error when creating new record. pressed create insert and entered some fields in pb3 and navigating to pb1 which is in tab showDetailItem 2. then i am getting the below error. Messages for this page are listed below. Attribu

  • Random menus appear after waking from sleep mode

    Everytime I wake my phone from sleep, slide the slider over, it often randomly chooses not to show the home page with all the icons but instead random chooses some other app menu. For example, it just showed me the photo library page. It often will s