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

Problem with job_close Exception INVALID_STARTDATE = 2

Former Member
0 Likes
1,059

Following is the test program.

My requirement is to split the program execution in to multiple jobs which should run sequentially - one by one, I have populated prev job name and jobcount. As of now for the below code .. i am getting invalid_startdate exception.

Can any one please let me know, where i am wrong.

I am working on ECC 6.0.

To test the below program, copy the below program as it is in to one test program and create a ZTESTV7 program with simple write statement, that can create a spool.

Thanks,

Shilpa.

data : v_jobcount TYPE TBTCJOB-JOBCOUNT,

v_jobname TYPE TBTCJOB-JOBNAME,

v_pjobcount TYPE TBTCJOB-JOBCOUNT,

v_start type char1,

v_PCHECK type char1,

v_pjobname TYPE TBTCJOB-JOBNAME.

START-OF-SELECTION.

v_jobname = 'TEST'.

do 5 times.

if sy-index = 1.

v_start = 'X'.

V_pcheck = '' .

else.

v_start = SPACE.

v_PCHECK = 'X'.

endif.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = v_jobname

IMPORTING

JOBCOUNT = v_jobcount

.

SUBMIT ZTESTV7 VIA JOB V_JOBNAME NUMBER V_JOBCOUNT AND RETURN.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = v_jobcount

jobname = v_jobname

PREDJOB_CHECKSTAT = v_PCHECK

PRED_JOBCOUNT = v_pjobcount

PRED_JOBNAME = v_pjobname

STRTIMMED = V_START

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 <> 0.

MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

leave list-processing.

ENDIF.

v_pjobcount = v_jobcount.

v_pjobname = v_jobname.

enddo.

Following is the test program.

My requirement is to split the program execution in to multiple jobs which should run sequentially - one by one, I have populated prev job name and jobcount. As of now for the below code .. i am getting invalid_startdate exception.

Can any one please let me know, where i am wrong.

I am working on ECC 6.0.

To test the below program, copy the below program as it is in to one test program and create a ZTESTV7 program with simple write statement, that can create a spool.

Thanks,

Shilpa.

data : v_jobcount TYPE TBTCJOB-JOBCOUNT,

v_jobname TYPE TBTCJOB-JOBNAME,

v_pjobcount TYPE TBTCJOB-JOBCOUNT,

v_start type char1,

v_PCHECK type char1,

v_pjobname TYPE TBTCJOB-JOBNAME.

START-OF-SELECTION.

v_jobname = 'TEST'.

do 5 times.

if sy-index = 1.

v_start = 'X'.

V_pcheck = '' .

else.

v_start = SPACE.

v_PCHECK = 'X'.

endif.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = v_jobname

IMPORTING

JOBCOUNT = v_jobcount

.

SUBMIT ZTESTV7 VIA JOB V_JOBNAME NUMBER V_JOBCOUNT AND RETURN.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = v_jobcount

jobname = v_jobname

PREDJOB_CHECKSTAT = v_PCHECK

PRED_JOBCOUNT = v_pjobcount

PRED_JOBNAME = v_pjobname

STRTIMMED = V_START

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 <> 0.

MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

leave list-processing.

ENDIF.

v_pjobcount = v_jobcount.

v_pjobname = v_jobname.

enddo.

2 REPLIES 2
Read only

Former Member
0 Likes
675

Hi,

It may be because, for the first iteration in the loop, you are setting v_start = 'X', which starts the job immediately and for the

next 4 iterations, it is set to SPACE. Please try specifying the start date and time for the jobs being scheduled in these 4

iterations i.e.(2 to 5).

Also debug and check if this exception is being thrown for the 4 iterations and not for the first one.

Hope this helps.

Regards,

Sagar

Read only

Former Member
0 Likes
675

This reply is already late to this question however just for future reference. I actually have the same requirement and the same error when executing FM JOB_CLOSE. Fortunately I solved the issue. You don't need to pass the job count for PRED_JOBCOUNT parameter of the FM as this causing the error. You only need the PRED_JOBNAME, which should be unique and STRTIMMED which should be marked with u2018Xu2019 always.

Itu2019s kind a weird because when I executed my program via debugging mode, it shows that this job name has this job number after calling JOB_OPEN however this job number is already assigned to the job of the previous execution of the loop. So, when JOB_CLOSE is called, it throws EXCEPTION 2. I also check SM36/37 there were jobs I created with the same job number. It seemed to me, SAP change the job number during actual execution of the job.