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

Starting Background Job from program...

Former Member
0 Likes
593

Hello I am using following to create a background job.


  DATA: number TYPE tbtcjob-jobcount,
        name TYPE tbtcjob-jobname VALUE 'METZ: INVOICING FROM SHIPMENT',
        print_parameters TYPE pri_params.
  data vari  LIKE varid-variant.
  data shipm    LIKE vttk-tknum.
  data use  LIKE   btch2170-username.
  vari = '3350_1' .
  shipm = p_shipment.
  use = 'K5_BATCH'.

  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 Z5L_START_INVOICING with p_shipm = shipm
                               with p_vari = vari
                               with p_submit = 'X'
                               USER use 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.

I am using the addition USER but the job gets started with user who is log on or who is using this trasaction.

It should start with user 'K5_BATCH' but it is not...........

Please help........

Edited by: Alvaro Tejada Galindo on Apr 7, 2008 1:00 PM

5 REPLIES 5
Read only

Former Member
0 Likes
556

Hi,

Question: Does the following userid 'K5_BATCH' existe on your system ad withcorrect authorizations ?

Regards

Read only

0 Likes
556

Yes

Read only

0 Likes
556

I found the following info:

Open Job Scheduling Without Dialog (Including COMMIT WORK)

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.

I think you will first have to use the JOB_SUBMIT statement like mentioned above

Read only

0 Likes
556

JOB_SUBMIT is done internally when you write Submit.....with....USER....VIA JOB....

Currently job is working fine but with Sy.uname and not with user i am specifying in SUBMIT statement.

Read only

0 Likes
556

Well if you think that everyting is ok. the last thing that you could do is to debug your application and see why your specific user id is not taken into account.

Good luck with debugging

Regards