cancel
Showing results for 
Search instead for 
Did you mean: 

SUBMIT AND RETURN USER VIA JOB with different user name other than sy-uname

kjyothiraditya
Participant
0 Kudos

Hi Experts,

I am enclosing SUBMIT z-report WITH SELECTION-TABLE AND RETURN USER VIA JOB in between JOB_OPEN and JOB_CLOSE where in for USER parameter, i am giving a different user name. But it is always taking the SY-UNAME. I have checked some blogs wherein SELECTION SET was used and also was suggested to use BJ_JOB_MODIFY. But i am not using variant and passing the parameters on the fly as above.

So can u let me know how to make the program to consider the user provided as part of the SUBMIT command.

CALL FUNCTION 'JOB_OPEN'.

SUBMIT z-report WITH SELECTION-TABLE lt_params

TO SAP-SPOOL SPOOL PARAMETERS ls_pri_params

WITHOUT SPOOL DYNPRO

USER 'BATCH_XXX'

VIA JOB lv_name NUMBER lv_number

AND RETURN.

CALL FUNCTION 'JOB_CLOSE'.

SAP component version: SAP_AP - SAPKNA7025

SAP_BASIS - SAPKB70210

Regards,

Aditya

Sandra_Rossi
Active Contributor
0 Kudos

It should work. Make sure that the user exists, that there is no space before the name...

Maybe you're not authorized to use BATCH_XXX? (cf ABAP doc)

You should check SY-SUBRC after SUBMIT ... VIA JOB ... (note that you must not check it if you use SUBMIT without VIA JOB)

kjyothiraditya
Participant
0 Kudos

Hi Sandra,

Thanks for your reply. One more clarification please. The doc says the user specified in USER should have s_btch_nam. This has added more confusion.

should the user(sy-uname) also have the rights to delegate the job execution to other common user ?

I basically want this program to run from some common generic user instead of being it dependant on user executing it.

Sandra_Rossi
Active Contributor

It means that the user who runs the program with SUBMIT VIA JOB ... USER 'BATCH_XXX' must have an authorization such a way that AUTHORITY-CHECK OBJECT 'S_BTCH_NAM' ID 'BTCUNAME' VALUE 'BATCH_XXX' is successful (i.e. having an authorization for object S_BTCH_NAM with BTCUNAME = '*' is fine).

I'm not sure but I think that if you're not authorized, SUBMIT VIA JOB should return SY-SUBRC = 8.

kjyothiraditya
Participant
0 Kudos

Also, now should sy-uname have the right to schedule job as it may be in planned but not released or BATCH_XXX have the rights to schedule ?

Sandra_Rossi
Active Contributor

That's another question. Yes the job remains in status planned if the user who creates the job (not related to the user assigned to each job step) doesn't have the right to release jobs.

So that the job is automatically released, the user who creates the job needs the authorization S_BTCH_JOB with RELE value, or the "super" authorization S_BTCH_ADM with Y value.

Accepted Solutions (0)

Answers (0)