08-16-2010 4:45 PM
Hi,
I have a code like that:
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.
* Call Update PO from Sales Order
SUBMIT zpcc_mm_upo3
WITH p_vbeln = puv_vbeln
USER lc_uname
VIA JOB lv_jobname NUMBER lv_jobcount
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_jobcount
jobname = lv_jobname
strtimmed = lc_true
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.
In this code as you see I can run the SUBMIT program with a specified user. But the creator of the job always becomes SY-UNAME. So is there a way to specify the user name for a job creator? I don't want to use SY-UNAME.
Thanks,
08-18-2010 3:15 PM
Don't know why the userid doesn't change for you...this works fine for me in NetWeaver 7.01:
call function 'JOB_OPEN'
exporting
jobname = lc_name
importing
jobcount = lv_number
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
lv_sav_subrc = sy-subrc.
if lv_sav_subrc is not initial.
concatenate 'Job Open Error Code' lv_sav_subrc
into lv_msg separated by space.
message lv_msg type 'I' display like 'E'.
endif.
if lv_sav_subrc eq 0.
submit myprogramname
using selection-set lv_variant "needed for background job
with parameter eq internal_value
user lv_user "BATCH_USER in my case
via job lc_name number lv_number
and return.
call function 'JOB_CLOSE'
exporting
jobcount = lv_number
jobname = lc_name
strtimmed = gc_x
importing
job_was_released = lv_job_released
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.
lv_sav_subrc = sy-subrc.
if lv_sav_subrc is not initial.
concatenate 'Job Close Error Code' lv_sav_subrc
into lv_msg separated by space.
message lv_msg type 'I' display like 'E'.
endif.
if lv_sav_subrc ne 0.
gv_error = abap_true.
endif.
08-16-2010 4:56 PM
Hio try this way...
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.
"Comment this
* Call Update PO from Sales Order
SUBMIT zpcc_mm_upo3
WITH p_vbeln = puv_vbeln
USER lc_uname
VIA JOB lv_jobname NUMBER lv_jobcount
AND RETURN.
"Comment end
* Call function to submit the job
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
authcknam = wa_authchknam "Pass the Other User name you want
jobcount = lv_jobcount
jobname = lv_jobname
REPORT = 'zpcc_mm_upo3'
VARIANT = jobs-variant "Create Varaqint
PRIPARAMS = wa_PRI_PARAMS
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
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_jobcount
jobname = lv_jobname
strtimmed = lc_true
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.
Prabhudas
08-16-2010 9:02 PM
@Prabhu Das
This doesn't help. It does the same thing as in my code.
Even though we use JOB_SUBMIT function with a user name for authcknam parameter. The job creator becomes the user who runs the code aka SY-UNAME.
Any suggestion?
Thanks,
08-17-2010 1:34 AM
What release are you running? I remembered this issue from the past - have you seen OSS note 551809? This was a problem when the print parameters weren't specified.
08-17-2010 9:26 PM
@Brad Bohn
We use ECC 6.0 and it seems this note was already applied in our system.
Basically the user JOHN will run the code, but I want to specify ADMIN user the creator of the job and steps of the job.
I can specify ADMIN user for steps by giving USER parameter for SUBMIT statement as below:
SUBMIT zpcc_mm_upo3
WITH p_vbeln = puv_vbeln
USER lc_uname
VIA JOB lv_jobname NUMBER lv_jobcount
AND RETURN.
But the creator of the job becomes JOHN. There is no any parameter to specify the user for JOB_OPEN, JOB_CLOSE function modules. If JOHN user has no Job admin authorization, then job stays as scheduled although we specified start immediately. But if a user like ADMIN has Job admin authorization, then the job is released (start immediately).
In JOB_SUBMIT function module, parameter authcknam for the user name does the same thing as SUBMIT with USER parameter does.
Any suggestion, recommendation?
Thanks,
08-17-2010 9:39 PM
Yes, then while you are creating the job, you can use BP_JOB_READ then BP_JOB_MODIFY to adjust the job definition before you call JOB_CLOSE.
...
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = lv_jobcount
job_read_jobname = lv_jobname
job_read_opcode = '20'
IMPORTING
job_read_jobhead = ls_jobhead
TABLES
job_read_steplist = lt_steplist
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
OTHERS = 4.
ls_jobhead-sdluname = 'ADMINUSER'.
CALL FUNCTION 'BP_JOB_MODIFY'
EXPORTING
dialog = 'N'
jobcount = ls_jobhead-jobcount
jobname = ls_jobhead-jobname
new_jobhead = ls_jobhead
opcode = '16'
IMPORTING
modified_jobhead = ls_jobhead
TABLES
new_steplist = lt_steplist
EXCEPTIONS
...
CALL FUNCTION 'JOB_CLOSE'
Edited by: Brad Bohn on Aug 17, 2010 3:43 PM
08-18-2010 10:13 AM
Hi Tuncay,
Even if that was possible,
i.e. Under login of JOHN, the creator gets stored as ADMIN,
then it would be untrue and misleading.
In your case, if JOHN is scheduling the job, then JOHN will only get stored as CREATOR.
It should be ok, to provide JOHN the required authorisation so that he can SCHEDULE IMMEDIATELY the jobs.
Hope this helps.
Regards,
Amit Mittal.
08-18-2010 3:15 PM
Don't know why the userid doesn't change for you...this works fine for me in NetWeaver 7.01:
call function 'JOB_OPEN'
exporting
jobname = lc_name
importing
jobcount = lv_number
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
lv_sav_subrc = sy-subrc.
if lv_sav_subrc is not initial.
concatenate 'Job Open Error Code' lv_sav_subrc
into lv_msg separated by space.
message lv_msg type 'I' display like 'E'.
endif.
if lv_sav_subrc eq 0.
submit myprogramname
using selection-set lv_variant "needed for background job
with parameter eq internal_value
user lv_user "BATCH_USER in my case
via job lc_name number lv_number
and return.
call function 'JOB_CLOSE'
exporting
jobcount = lv_number
jobname = lc_name
strtimmed = gc_x
importing
job_was_released = lv_job_released
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.
lv_sav_subrc = sy-subrc.
if lv_sav_subrc is not initial.
concatenate 'Job Close Error Code' lv_sav_subrc
into lv_msg separated by space.
message lv_msg type 'I' display like 'E'.
endif.
if lv_sav_subrc ne 0.
gv_error = abap_true.
endif.
08-18-2010 9:12 PM
Right, works for me too. I think it does work for the poster as well but he/she wants to change the creator of the job not the step user ID, perhaps for search purposes. The only way to do it that I know of is by using BP_JOB_MODIFY before JOB_CLOSE.
09-16-2010 3:41 PM
@Brad Bohn
Using BP_JOB_MODIFY before JOB_CLOSE worked. Thank you so much.
02-09-2012 2:00 PM
Hi
How do I pass actual values to Varint? In submit report starement
SUBMIT z_idoc_create_process_order USER creator using selection-set lv_variant TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
WITH p_aufnr EQ it_header1-aufnr
WITH p_werks EQ it_header1-werks
WITH p_autyp EQ c_autyp
WITH p_auart EQ it_header1-auart
WITH p_dispo EQ it_header1-dispo
WITH p_opt EQ c_opt
WITH p_mestyp EQ c_mestyp
VIA JOB name NUMBER number
AND RETURN.
In this case I am getting a job created but now values in Variant.
04-09-2012 3:41 PM
You have to use USING SELECTION-SET variant option with SUBMIT.
If you specify this edition, the parameters and selection criteria for the selection screen are supplied with values from a variant. For variant, you must specify a character-like data object that contains the name of a variant for the program accessed when the statement is executed. If the variant does not exist, the system sends an error message. If the variant belongs to a different selection screen, it is ignored.