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 processing of Program

Former Member
0 Likes
774

Hi all,

I have a requirement of background processing of a program which is called from another program.

Requirement : during execution of Program A, Program B is Submitted to run in background with two field values from Program A.

Is it possible ? I am able to explore it. Please help.

Regards,

Nibha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
732
DATA: number           TYPE tbtcjob-jobcount, 
      name             TYPE tbtcjob-jobname VALUE 'JOB_TEST', 
      print_parameters TYPE pri_params. 

... 

CALL FUNCTION 'JOB_OPEN' 
  EXPORTING 
    jobname          = name 
  IMPORTING 
    jobcount         = number 
  EXCEPTIONS 
    cant_create_job  = 1 
    invalid_job_data = 2 
    jobname_missing  = 3 
    OTHERS           = 4. 
IF sy-subrc = 0. 
  SUBMIT submitable TO SAP-SPOOL 
                    SPOOL PARAMETERS print_parameters 
                    WITHOUT SPOOL DYNPRO 
                    VIA JOB name NUMBER number 
                    AND RETURN. 
  IF sy-subrc = 0. 
    CALL FUNCTION 'JOB_CLOSE' 
      EXPORTING 
        jobcount             = number 
        jobname              = 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 
        OTHERS               = 8. 
    IF sy-subrc <> 0. 
      ... 
    ENDIF. 
  ENDIF. 
ENDIF.

System fields

sy-subrc Meaning

0 Background task scheduled successfully.

4 Scheduling cancelled by user on the selection screen.

8 Error during scheduling, i.e. when accessing JOB_SUBMIT internally.

12 Error in internal number assignment.

4 REPLIES 4
Read only

Former Member
0 Likes
732

This message was moderated.

Read only

Former Member
0 Likes
732

Hi,

Your options are very different depending on if program B is a SAP standard program or a customer program.

If you can change program B add the fields as parameters of the program and pass them using SUBMIT.

Regards,

Nick

Read only

Former Member
0 Likes
733
DATA: number           TYPE tbtcjob-jobcount, 
      name             TYPE tbtcjob-jobname VALUE 'JOB_TEST', 
      print_parameters TYPE pri_params. 

... 

CALL FUNCTION 'JOB_OPEN' 
  EXPORTING 
    jobname          = name 
  IMPORTING 
    jobcount         = number 
  EXCEPTIONS 
    cant_create_job  = 1 
    invalid_job_data = 2 
    jobname_missing  = 3 
    OTHERS           = 4. 
IF sy-subrc = 0. 
  SUBMIT submitable TO SAP-SPOOL 
                    SPOOL PARAMETERS print_parameters 
                    WITHOUT SPOOL DYNPRO 
                    VIA JOB name NUMBER number 
                    AND RETURN. 
  IF sy-subrc = 0. 
    CALL FUNCTION 'JOB_CLOSE' 
      EXPORTING 
        jobcount             = number 
        jobname              = 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 
        OTHERS               = 8. 
    IF sy-subrc <> 0. 
      ... 
    ENDIF. 
  ENDIF. 
ENDIF.

System fields

sy-subrc Meaning

0 Background task scheduled successfully.

4 Scheduling cancelled by user on the selection screen.

8 Error during scheduling, i.e. when accessing JOB_SUBMIT internally.

12 Error in internal number assignment.

Read only

0 Likes
732

Hi,

Thanks for Reply. Its Helpful. Please tell what print parameters should be passed to it. Also what if I have to pass parameters to the program. Do I need to use below data type .

DATA: it_selcr TYPE STANDARD TABLE OF rsparams.

DATA: wa_selcr TYPE rsparams.

syntax - Submit ...... WITH SELECTION-TABLE it_selcr.... and return.

Edited by: NIBHA Priya on Jan 17, 2009 5:47 AM