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

Batch JOB create with specified username

Former Member
0 Likes
2,411

Hi Experts,

Im trying to create a Batch job which runs with specified username (who runs the report). Im using BP_JOB_CREATE with following parameters

DATA: BEGIN OF s_job.

INCLUDE STRUCTURE tbtcjob.

DATA: END OF s_job.

DATA: BEGIN OF s_step OCCURS 0.

INCLUDE STRUCTURE tbtcstep.

DATA: END OF s_step.

s_job-jobname = 'Z_JOB'.

s_job-jobclass = 'A'.

s_job-authcknam = sy-uname.

s_step-program = 'RBDAPP01'.

s_step-opsystem = sy-sysid.

s_step-parameter = 'Z_VARIANT'.

s_step-authcknam = sy-uname.

s_step-language = sy-langu.

CALL FUNCTION 'BP_JOB_CREATE'

EXPORTING

job_cr_dialog = 'N'

job_cr_head_inp = s_job

TABLES

job_cr_steplist = s_step

EXCEPTIONS

CANT_CREATE_JOB = 1

INVALID_DIALOG_TYPE = 2

INVALID_JOB_DATA = 3

JOB_CREATE_CANCELED = 4

OTHERS = 5

.

Its coming up with INVALID_JOB_DATA = 3 error.

Is there any other fields to be passed to the FM. Am I missing something. Could somebody help me with this please.

Thanks,

Kiran.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,241

Hi,

Try using

clear: d_JOB_COUNT.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

JOBNAME = d_JOBNAME

IMPORTING

JOBCOUNT = d_JOB_COUNT.

submit ZFI_AGEWISE_PERFORMANCE

VIA JOB d_JOBNAME

NUMBER d_JOB_COUNT

with IKUNNR IN r_id

with s_vertn in S_VERTN

with s_hkont IN S_HKONT

with IBUDAT eq IBUDAT

with P_BUKRS eq P_BUKRS

with s_umskz in s_umskz

*with R1 = R1

WITH R2 = R2

*with r3 = R3

WITH P_SESS = P_SESS

AND RETURN.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

JOBNAME = d_JOBNAME

JOBCOUNT = d_JOB_COUNT

STRTIMMED = 'X'.

Reward points

9 REPLIES 9
Read only

BGarcia
Active Contributor
0 Likes
2,241

Hello Kiran,

If it helps and if you consider alternatives, I normally use this functions to create a job (in this order):

- JOB_OPEN

- JOB_SUBMIT

- JOB_CLOSE

See if it can be helpful to your requirements.

Regards,

Bruno

Read only

Former Member
0 Likes
2,241

Hi Bruno,

Thanks for your reply. I tried using them. But there is no filed to pass on the USERNAME by which the job should be created. Thats the primary requirement for me to pass authorisations etc... anyway thanks..

Regards,

Kiran.

Read only

BGarcia
Active Contributor
0 Likes
2,241

Hello Kiran,

In function JOB_SUBMIT there is an importing paramater AUTHCKNAM where you can specify the username. I think this will suit your requirements... Did you tried it also?

Regards,

Bruno

Read only

Former Member
0 Likes
2,241

Hi Bruno,

Thanks so much. Will try it now.

Regards,

Kiran.

Read only

Former Member
0 Likes
2,241

Try with :

Pass the value for typ as 'A'

s_step-typ = 'A'.

Read only

0 Likes
2,241

Hi Srinivas,

Thanks. Didn't work. still giving short dump..

Regards,

Kishore.

Read only

0 Likes
2,241

Hi Kiran,

Did you get any resolution. I am also trying to create a job that should run with a SAP batch user id.

Thanks in advance

Regards

Kasi

Read only

0 Likes
2,241

For me it doent give short dump but I could not open the job once it is created. It gives a message "defnition of job is incomplete". see logic below:

job_cr_head_inp-jobname = 'CHUKDE'.

job_cr_head_inp-newflag = 'O'.

job_cr_head_inp-SDLSTRTDT = SY-DATUM.

job_cr_head_inp-jobclass = 'A'.

job_cr_head_inp-SDLSTRTTM = RELEASE_STDT-SDLSTRTTM.

job_cr_head_inp-STRTDATE = SY-DATUM.

job_cr_head_inp-STRTTIME = RELEASE_STDT-SDLSTRTTM.

job_cr_head_inp-AUTHCKNAM = SY-UNAME.

job_cr_head_inp-RELUNAME = SY-UNAME.

JOB_CR_STEPLIST-program = 'ZMIIP125'.

JOB_CR_STEPLIST-PARAMETER = 'TEST'.

JOB_CR_STEPLIST-typ = 'A'.

JOB_CR_STEPLIST-status = 'P'.

JOB_CR_STEPLIST-authcknam = SY-UNAME.

JOB_CR_STEPLIST-LANGUAGE = SY-LANGU.

APPEND JOB_CR_STEPLIST.

call function 'BP_JOB_CREATE'

exporting

job_cr_dialog = 'N'

job_cr_head_inp = job_cr_head_inp

IMPORTING

JOB_CR_HEAD_OUT = job_cr_head_inp

JOB_CR_STDT_OUT = JOB_CR_STDT_OUT

tables

job_cr_steplist = JOB_CR_STEPLIST.

Read only

Former Member
0 Likes
2,242

Hi,

Try using

clear: d_JOB_COUNT.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

JOBNAME = d_JOBNAME

IMPORTING

JOBCOUNT = d_JOB_COUNT.

submit ZFI_AGEWISE_PERFORMANCE

VIA JOB d_JOBNAME

NUMBER d_JOB_COUNT

with IKUNNR IN r_id

with s_vertn in S_VERTN

with s_hkont IN S_HKONT

with IBUDAT eq IBUDAT

with P_BUKRS eq P_BUKRS

with s_umskz in s_umskz

*with R1 = R1

WITH R2 = R2

*with r3 = R3

WITH P_SESS = P_SESS

AND RETURN.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

JOBNAME = d_JOBNAME

JOBCOUNT = d_JOB_COUNT

STRTIMMED = 'X'.

Reward points