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

Parallel execution of a program

Former Member
0 Likes
574

Hi guys,

I have a user exit where I need to launch a program, to make a kind of SUBMIT to a Zprogram, but I just want to launch the Zprogram and not wait for it to finish. I mean, if the Zprogram takes, let's say, an hour, I don't want to wait for an hour in my user exit, I just want to schedule the execution and go on with the rest of the process in the user exit.

Can you get what I mean?

Thanks in advance!

Kind regards,

Matias.

4 REPLIES 4
Read only

Former Member
0 Likes
537

Hi,

Then in this case you schedule the Program as a background right..


  DATA:    l_valid,
           ls_params LIKE pri_params,
           lv_jobname LIKE tbtcjob-jobname,
           lv_jobcount LIKE tbtcjob-jobcount.

*--Get Print Parameters
  CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING
      no_dialog      = 'X'
    IMPORTING
      valid          = l_valid
      out_parameters = ls_params.

  CLEAR : ls_params-primm, ls_params-prrel.

lv_jobname = 'ZJOBNAME'.
 *--Create the Background Job
  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.

*--Submit the Program as the Background step for the above job
  SUBMIT (Program Name)
               WITH p_ufile = v_ufile
              WITH SELECTION-TABLE it_selopt
              VIA JOB     lv_jobname
              NUMBER  lv_jobcount
             TO SAP-SPOOL WITHOUT SPOOL DYNPRO
            SPOOL PARAMETERS ls_params
            AND RETURN.

*--Schedule and close job.
  CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
      jobcount             = lv_jobcount
      jobname              = lv_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.

This will schedule the program as a background job which will not stop the execution of the transaction. Let me know if any.

Regards,

Srinivas

Read only

0 Likes
537

Hi Hari,

is it necessary to use the spool parameters?

Or do I get the same effect with:

JOB_OPEN

SUBMIT zprogram

VIA JOB 1111111

AND RETURN.

JOB_CLOSE

I don't understand why i'd need the spool stuff.

Thakns,

Matias.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
537

Hello,

If you're not interested in the spool output of the scheduled program you don't need the SPOOL PARAMETERS. Read the F1 documentation for further details.

BR,

Suhas

Read only

0 Likes
537

Hi,

If you don't want to pass the SPOOL PARAMETERS, Comment the SPOOL keywords it will work.


  SUBMIT (PROGRAM NAME)
         WITH p_ufile = v_ufile
         WITH SELECTION-TABLE it_selopt
         VIA JOB     lv_jobname
             NUMBER  lv_jobcount
*         TO SAP-SPOOL WITHOUT SPOOL DYNPRO
*            SPOOL PARAMETERS ls_params
            AND RETURN. 

Use the above statment it will work. Let know if any.

Regards,

Srinivas