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

background

Former Member
0 Likes
1,112

Hi,

.

How to schedule a Report in background using se38 ?

Thank you

Ashok kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
861

Hi

from the selection screen

menu

Program-> execute in Background

give Output device as LP01(default local printer)

then by default it goes to the Sm36

then set the parameters

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

<b>Reward points for useful Answers</b>

Regards

Anji

5 REPLIES 5
Read only

Former Member
0 Likes
862

Hi

from the selection screen

menu

Program-> execute in Background

give Output device as LP01(default local printer)

then by default it goes to the Sm36

then set the parameters

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

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
861

hi,

There are some standard function modules which will allow you to schedule programs in bakground - programatically.

Please refer the help documentation http://help.sap.com/saphelp_47x200/helpdata/en/fa/097720543b11d1898e0000e8322d00/frameset.htm

You can use the module BP_JOBVARIANT_SCHEDULE, which has limited control or JOB_OPEN, JOB_SUBMIT, and JOB_CLOSE for full fledged control.

You may have to create a wrapper report to accomodate these function modules.

Regards,

Sankar

Read only

Former Member
0 Likes
861

Hi Ashok,

Gotto se38, provide the program name. in the menu Program -> Execute -> Background.

Create the variant before executing the program. Provide this variant while executing the program in background. and also provide the schedule details.

Cheers,

Satish

Read only

Former Member
0 Likes
861

hi,

There are two ways for you to handle,

one manually setting up the job through SM36 which is better and convinient,

secondly through program using FM's JOB_OPEN, SUBMIT, JOB_CLOSE.

Find below steps in doing both:

Procedure 1:

1. Goto Trans -> SM36

2. Define a job with the program and variant if any

3. Click on start condition in application tool bar

4. In the pop-up window, click on Date/Time

5. Below you can see a check box "Periodic Job"

6. Next click on Period Values

7. Select "Other Period"

8. Now give '15' for Minutes

9. Save the job

In SM37 u can check the status of the jobs that u have assigned to background...

Here u mention the job name or the report name to check the status of the job...

After mentioning the job name or program name u just execute it.. ( without any name also u can execute then it gives u all the jobs set by your user name..

the status colud be released,active,finished etc..

Procedure 2 via Program:

Below is a sample code for the same. Note the ZTEMP2 is the program i am scheduling with 15mins frequency.

 
DATA: P_JOBCNT LIKE TBTCJOB-JOBCOUNT,
      L_RELEASE(1) TYPE c.
 
   CALL FUNCTION 'JOB_OPEN'
     EXPORTING
       JOBNAME                = 'ZTEMP2' 
    IMPORTING
      JOBCOUNT               = P_JOBCNT
    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.
 
   SUBMIT ZTEMP2 VIA JOB 'ZTEMP2' NUMBER P_JOBCNT
          TO SAP-SPOOL WITHOUT SPOOL DYNPRO 
          WITH DESTINATION = 'HPMISPRT'
          WITH IMMEDIATELY = SPACE
          WITH KEEP_IN_SPOOL = 'X' AND RETURN.
 
   CALL FUNCTION 'JOB_CLOSE'
     EXPORTING
       JOBCOUNT                          = P_JOBCNT
       JOBNAME                           = 'ZTEMP2' 
       STRTIMMED                         = 'X'
       PRDMINS                          = 15
    IMPORTING
      JOB_WAS_RELEASED                  = L_RELEASE
    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.

Hope the above helps you.

Regards

Reshma

Read only

former_member189059
Active Contributor
0 Likes
861

DATA: lv_job_name         LIKE tbtco-jobname,
lv_job_nr           LIKE tbtco-jobcount,
lv_job_released     TYPE c,
lv_job_start_sofort TYPE c,
lv_print_parameters TYPE pri_params.
lv_job_name = 'Z_BG_PROG_NAME'.


*part for background processing

  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
      jobname          = lv_job_name
    IMPORTING
      jobcount         = lv_job_nr
    EXCEPTIONS
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      OTHERS           = 4.
  IF syst-subrc = 0.
*submit job with all the selection screen params...
    SUBMIT (lv_job_name)
        WITH applfile = applfile
        WITH p_lines = p_lines
        WITH rfc_dest = rfcdest
        WITH p_selmtd = lv_selmtd
        WITH px_shsim = px_shsim
        WITH px_sherr = px_sherr
        USER syst-uname
       VIA JOB lv_job_name NUMBER lv_job_nr AND RETURN.
    IF sy-subrc = 0.
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = lv_job_nr
          jobname              = lv_job_name
          strtimmed            = 'X'
        IMPORTING
          job_was_released     = lv_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
          OTHERS               = 8.
      IF syst-subrc <> 0.
        MESSAGE i162(00) WITH
        'An error occured while closing the background job.'.
        STOP.
      ENDIF.
    ENDIF.
  ENDIF.
  SKIP 1.
  WRITE: / 'Background process', lv_job_name , 'called successfully' NO-GAP.
  WRITE: / 'You can check the job in transaction SM37'.