‎2013 Oct 21 12:35 PM
Hi
I have the requirement in which I have to run the background job from my user id But actually the modifications from that job like Posting of document should happen from background userid like A_BKG. Can this be achieved.
Regards
Nikhil Jain
‎2013 Oct 21 12:44 PM
Dear Nikhil,
Its Possible.
1. Goto SM37 and execute.
2. Select the Job (Tick Mark) and goto Menu Job -> Change
3. Click on Step Button
4. Click on the Program Name and click the Change Icon
5. Now here you can change the User Name.
Regards
Shaik
‎2013 Oct 21 12:56 PM
Hi Nikhil,
Please check the below link.. it may helpful to you.
http://scn.sap.com/thread/2130557
Regards,
Rajesh
‎2013 Oct 21 1:08 PM
Hi,
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = name
IMPORTING
jobcount = number.
Submit Progname with <Conditions>
USER <sy-uname> VIA JOB lf_jobname
NUMBER lf_jobnum
AND RETURN.
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.
pass the username you want in the place where i passed sy-uname.
Regards.
‎2013 Oct 21 1:44 PM
Try this code..
CLEAR : lv_count, lv_return.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = v_job
IMPORTING
jobcount = lv_count
CHANGING
ret = lv_return
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE s030.
LEAVE SCREEN.
ENDIF.
CHECK sy-subrc EQ 0.
*--- Schedule new Background Job..
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
authcknam = 'IM_USERNAME'
jobcount = lv_count
jobname = v_job
report = sy-cprog
variant = lx_varid-variant
EXCEPTIONS
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
OTHERS = 10.
IF sy-subrc NE 0.
MESSAGE s056.
LEAVE SCREEN.
ENDIF.
CHECK sy-subrc EQ 0.
*--- Schedule new Background Job..
CLEAR : lv_release.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_count
jobname = v_job
strtimmed = 'X'
IMPORTING
job_was_released = lv_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 EQ 0.
CALL SCREEN 500 STARTING AT 10 5
ENDING AT 58 9.
ELSE.
MESSAGE s057.
LEAVE SCREEN.
ENDIF.