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

Executing program in parallel

Former Member
0 Likes
3,187

Hi, I want execute a program with SUBMIT statement, but i need execute it for example 6 times at the same time. The 6 processes must run in parallel.

How can i do it?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,868

Hi Naimesh, can you show me an example code?

6 REPLIES 6
Read only

ThomasZloch
Active Contributor
0 Likes
1,868

SUBMIT will keep your process busy until the called program is finished. For parallel processing you would need to look at asynchronous RFC.

Greetings

Thomas

Read only

naimesh_patel
Active Contributor
0 Likes
1,868

You can create a JOB and than submit your program with that job.

Use FM JOB_OPEN, SUBMIT.. using JOBNUMBER , FM JOB_CLOSE to schedule your job and run the programs in parallel.

Regards

Naimesh Patel

Read only

Former Member
0 Likes
1,869

Hi Naimesh, can you show me an example code?

Read only

0 Likes
1,868

Idea is:

You need to call the JOB_OPEN ... JOB_CLOSE FMs inside the Loop, which can get you multiple jobs at a time.

The execution of the jobs will be based on the avaliable JOB PROCESSes.

Have a look at the attached code:



DATA: W_COUNT LIKE TBTCJOB-JOBCOUNT,
      W_CLASS LIKE TBTCJOB-JOBCLASS.
DATA: W_UNAME LIKE TBTCJOB-AUTHCKNAM.

PARAMETERS:  W_NAME  LIKE TBTCJOB-JOBNAME DEFAULT 'PARALLEL'.
* the selection parameters which you need to pass to FM
PARAMETERS: FLD1 TYPE CHAR10.



START-OF-SELECTION.

  W_CLASS = 'A'.

  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
*     DELANFREP              = ' '
      JOBGROUP               = 'TEST'
      JOBNAME                = W_NAME
*     SDLSTRTDT              = NO_DATE
*     SDLSTRTTM              = NO_TIME
*      JOBCLASS               = w_class
    IMPORTING
      JOBCOUNT               = W_COUNT
*   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.

* Submit program via jobname and jobcount
  SUBMIT ZTEST_NP1 WITH P_CHAR = FLD1            
                   VIA JOB W_NAME NUMBER W_COUNT
                    AND RETURN.


  CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
*     AT_OPMODE                         = ' '
*     AT_OPMODE_PERIODIC                = ' '
*     CALENDAR_ID                       = ' '
*     EVENT_ID                          = ' '
*     EVENT_PARAM                       = ' '
*     EVENT_PERIODIC                    = ' '
      JOBCOUNT                          = W_COUNT
      JOBNAME                           = W_NAME
*     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                      = 'X'
*   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.
    WRITE: 'Job is ready'.
  ENDIF.

Read only

Former Member
0 Likes
1,868

Hi,

Hope below code snippet helps!


*Submit report as job(i.e. in background)  
data: lv_tem_job like tbtcjob-jobname value
                             ' TRANSFER TRANSLATION'.
data: lv_jobcount     like tbtcjob-jobcount.
    
 
* Job open 
  call function 'JOB_OPEN'
       exporting
            jobname          = lv_tem_job
            jobclass         = 'C'
       importing
            jobcount         = lv_jobcount
       exceptions
            cant_create_job  = 1
            invalid_job_data = 2
            jobname_missing  = 3
            others           = 4.
  if sy-subrc <> 0.
    message id sy-msgid type 'A' number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.
 
*Submit job
 SUBMIT zreport and return 
                with p_param1 = 'value'
                with p_param2 = 'value'
                user sy-uname
               via  job       lv_tem_job
                       number    lv_jobcount

  if sy-subrc > 0.
                                       "error processing
  endif.
 
* Close job
  call function 'JOB_CLOSE'
       exporting
            jobcount             = lv_jobcount
            jobname              = lv_tem_job
            strtimmed            = 'X'
            direct_start         = 'X'
       importing
            job_was_released     = lv_job_rel
       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.
    message id sy-msgid type 'A' number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

Edited by: Vikram Jalali on Jun 2, 2008 11:59 AM

Read only

Former Member
0 Likes
1,868

Thanks to everyone for the anwers.