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

Dynamically create JOBNAME

Former Member
0 Likes
772

Hi ,

I am trying to run jobs from a report.

I am trying create the JOBNAME dynamically.

I am just taking it like this

data : P_JOBNM like TBTCJOB-JOBNAME.

after this I did the call for job_open

CALL FUNCTION 'JOB_OPEN'

EXPORTING

  • DELANFREP = ' '

  • JOBGROUP = ' '

JOBNAME = p_jobname

  • SDLSTRTDT = NO_DATE

  • SDLSTRTTM = NO_TIME

IMPORTING

JOBCOUNT = p_jobcount

EXCEPTIONS

CANT_CREATE_JOB = 1

INVALID_JOB_DATA = 2

JOBNAME_MISSING = 3

OTHERS = 4

But sy-subrc is 3.

that is it is saying JOBNAME missing.

and thus there is no jobcount created.

Anyone help me with this.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
605

Hi,

Check this sample code..

DATA: p_jobcnt LIKE tbtcjob-jobcount,

l_release(1) TYPE c.

  • Open the job

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = 'ZMY_OBJ'

IMPORTING

jobcount = p_jobcnt

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4.

  • Submit the job.

SUBMIT ztest_program VIA JOB 'ZMY_OBJ' NUMBER p_jobcnt

TO SAP-SPOOL WITHOUT SPOOL DYNPRO

WITH destination = 'LOCL'

WITH immediately = space

WITH keep_in_spool = 'X' AND RETURN.

  • Close the job.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = p_jobcnt

jobname = 'ZMY_OBJ'

strtimmed = 'X'

prdmins = 15

IMPORTING

job_was_released = l_release.

Thanks,

Naren

3 REPLIES 3
Read only

Former Member
0 Likes
606

Hi,

Check this sample code..

DATA: p_jobcnt LIKE tbtcjob-jobcount,

l_release(1) TYPE c.

  • Open the job

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = 'ZMY_OBJ'

IMPORTING

jobcount = p_jobcnt

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4.

  • Submit the job.

SUBMIT ztest_program VIA JOB 'ZMY_OBJ' NUMBER p_jobcnt

TO SAP-SPOOL WITHOUT SPOOL DYNPRO

WITH destination = 'LOCL'

WITH immediately = space

WITH keep_in_spool = 'X' AND RETURN.

  • Close the job.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = p_jobcnt

jobname = 'ZMY_OBJ'

strtimmed = 'X'

prdmins = 15

IMPORTING

job_was_released = l_release.

Thanks,

Naren

Read only

0 Likes
605

Hi Naren,

Thanks for your quick answer but can you please see my previous thread regarding the job scheduling for every 10 minutes & answer it too?I didnot get a good answer for it.

Thanks in advance

Read only

Former Member
0 Likes
605

Hi,

Do you want to schedule in SM37 or via program??

Thanks,

Naren