2007 Oct 16 7:40 AM
Hello All,
What is the wrong in this code?
DATA lv_jobname TYPE tbtcjob-jobname.
DATA lv_count TYPE tbtcjob-jobcount.
DATA: ls_tbtstrt LIKE tbtcstrt. "description startdate/reappl.
DATA gp_phase LIKE cnvstate-phase VALUE 'C'.
CONCATENATE sy-repid 'XXXX' INTO lv_jobname.
CALL FUNCTION 'BP_STDT_EDITOR_AT_DATE_TIME'
EXPORTING
stdt_dttm_input = ls_tbtstrt
stdt_dttm_editor_opcode = '14'
* STDT_DTTM_EDITOR_TITLE = ' '
IMPORTING
stdt_dttm_output = ls_tbtstrt
* STDT_DTTM_MODIFIED =
EXCEPTIONS
invalid_opcode = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
* DELANFREP = ' '
* JOBGROUP = ' '
jobname = lv_jobname
* SDLSTRTDT = NO_DATE
* SDLSTRTTM = NO_TIME
* JOBCLASS =
IMPORTING
jobcount = lv_count
* CHANGING
* RET =
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_count
jobname = lv_jobname
laststrtdt = ls_tbtstrt-laststrtdt
laststrttm = ls_tbtstrt-laststrttm
prddays = ls_tbtstrt-prddays
prdhours = ls_tbtstrt-prdhours
prdmins = ls_tbtstrt-prdmins
prdmonths = ls_tbtstrt-prdmonths
prdweeks = ls_tbtstrt-prdweeks
sdlstrtdt = ls_tbtstrt-sdlstrtdt
sdlstrttm = ls_tbtstrt-sdlstrttm
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7.
When i execute the above code i am able to see the job is scheduled but it will remain same in the same state as scheduled.
My requirement is it should be released. How can i do this?
Can any modify it the above code or give some suggestions to me?
Regards,
Lisa
Message was edited by:
Lisa Roy
These are just example, adapt to your code
Regards
2007 Oct 16 7:44 AM
Hi,
If you want to specify date/time of execution, look at this sample <a href="http://help.sap.com/saphelp_40b/helpdata/en/fa/096d8e543b11d1898e0000e8322d00/content.htm">Sample Program: Start-Time Window with JOB_CLOSE</a>
If you want immediate execution look at this sample <a href="http://help.sap.com/saphelp_sm32/helpdata/en/fa/096d74543b11d1898e0000e8322d00/content.htm">Sample Program: Immediate Start with JOB_CLOSE</a>
Regards
2007 Oct 16 8:36 AM
Hello Raymond,
Do you have any idea why my job is not active?
Regards,
Lisa
2007 Oct 16 8:41 AM
2007 Oct 16 8:47 AM
Hello Raymond,
I have changed my program like this. Even it didn't work.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
* DELANFREP = ' '
* JOBGROUP = ' '
jobname = lv_jobname
* SDLSTRTDT = NO_DATE
* SDLSTRTTM = NO_TIME
* JOBCLASS =
IMPORTING
jobcount = lv_count
* CHANGING
* RET =
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* SUBMIT (sy-repid)
* VIA JOB lv_jobname
* NUMBER lv_count
* WITH gp_phase = gp_phase
* AND RETURN.
* IF sy-subrc = 0.
* MESSAGE ID 'CNV' TYPE 'I' NUMBER 804
* WITH sy-repid lv_jobname.
* ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
* AT_OPMODE = ' '
* AT_OPMODE_PERIODIC = ' '
* CALENDAR_ID = ' '
* EVENT_ID = ' '
* EVENT_PARAM = ' '
* EVENT_PERIODIC = ' '
jobcount = lv_count
jobname = lv_jobname
* LASTSTRTDT = NO_DATE
* LASTSTRTTM = NO_TIME
* PRDDAYS = 0
* PRDHOURS = 0
* PRDMINS = 0
* PRDMONTHS = 0
* PRDWEEKS = 0
* PREDJOB_CHECKSTAT = ' '
* PRED_JOBCOUNT = ' '
* PRED_JOBNAME = ' '
* SDLSTRTDT = NO_DATE
* SDLSTRTTM = NO_TIME
* STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS
strtimmed = 'X'
* TARGETSYSTEM = ' '
* START_ON_WORKDAY_NOT_BEFORE = SY-DATUM
* START_ON_WORKDAY_NR = 0
* WORKDAY_COUNT_DIRECTION = 0
* RECIPIENT_OBJ =
* TARGETSERVER = ' '
* DONT_RELEASE = ' '
* DIRECT_START =
IMPORTING
job_was_released = lv_job_released
* CHANGING
* RET =
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
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Regards,
Lisa
2007 Oct 16 8:53 AM
2007 Oct 16 7:46 AM
http://help.sap.com/saphelp_nw70/helpdata/en/fa/096ef2543b11d1898e0000e8322d00/frameset.htm
Please visit the above link:
The user should have the corresponding permission profile for the Background job releasing...Please assign the SAP_ALL permission profile for your user....
2007 Oct 16 8:37 AM
Hello Ramkumar,
Do you have any idea why my job is not active?
Regards,
Lisa
2007 Oct 16 8:38 AM
Hello Ramkumar,
I have authorization for SAP_ALL.
Regards,
Lisa
2007 Oct 16 8:42 AM
2007 Oct 16 8:44 AM
Hi
As user can "lauch" the job in foreground or background, use something like
screen fields
TABLES sscrfields.
check box
PARAMETER checkbox AS CHECKBOX.
if run and checkbox, force batch
AT SELECTION-SCREEN.
IF sscrfields-ucomm EQ 'ONLI' AND checkbox = 'X'.
sscrfields-ucomm = 'SJOB'.
ENDIF.
Here is the sample program
*Submit report as job(i.e. in background)
data: jobname like tbtcjob-jobname value
' TRANSFER TRANSLATION'.
data: jobcount like tbtcjob-jobcount,
host like msxxlist-host.
data: begin of starttime.
include structure tbtcstrt.
data: end of starttime.
data: starttimeimmediate like btch0000-char1.
Job open
call function 'JOB_OPEN'
exporting
delanfrep = ' '
jobgroup = ' '
jobname = jobname
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit
importing
jobcount = jobcount
exceptions
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03.
if sy-subrc ne 0.
"error processing
endif.
Insert process into job
SUBMIT zreport and return
with p_param1 = 'value'
with p_param2 = 'value'
user sy-uname
via job jobname
number jobcount.
if sy-subrc > 0.
"error processing
endif.
Close job
starttime-sdlstrtdt = sy-datum + 1.
starttime-sdlstrttm = '220000'.
call function 'JOB_CLOSE'
exporting
event_id = starttime-eventid
event_param = starttime-eventparm
event_periodic = starttime-periodic
jobcount = jobcount
jobname = jobname
laststrtdt = starttime-laststrtdt
laststrttm = starttime-laststrttm
prddays = 1
prdhours = 0
prdmins = 0
prdmonths = 0
prdweeks = 0
sdlstrtdt = starttime-sdlstrtdt
sdlstrttm = starttime-sdlstrttm
strtimmed = starttimeimmediate
targetsystem = host
exceptions
cant_start_immediate = 01
invalid_startdate = 02
jobname_missing = 03
job_close_failed = 04
job_nosteps = 05
job_notex = 06
lock_failed = 07
others = 99.
if sy-subrc eq 0.
"error processing
endif.
2007 Oct 16 8:53 AM
Hello Naresh,
SUBMIT zreport and return
with p_param1 = 'value'
with p_param2 = 'value'
user sy-uname
via job jobname
number jobcount.
if sy-subrc > 0.
"error processing
endif.Could you please explain me what the field Value contains in the above submit statement.
Do you have any liknk how to write the submit statement?
Regards,
Lisa
2007 Oct 16 9:19 AM
There seems to be TWO problems with your code
- No step specified : Use correct syntax of submit in a background job
SUBMIT report
WITH parameter EQ value
VIA JOB jobname NUMBER jobcount
AND RETURN. " <- add this - No first execution
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_count
jobname = lv_jobname
SDLSTRTDT = ls_tbtstrt-SDLSTRTDT " <- add this
SDLSTRTTM = ls_tbtstrt-SDLSTRTTM " <- add this
laststrtdt = ls_tbtstrt-laststrtdt
laststrttm = ls_tbtstrt-laststrttm
prddays = ls_tbtstrt-prddays
prdhours = ls_tbtstrt-prdhours
prdmins = ls_tbtstrt-prdmins
prdmonths = ls_tbtstrt-prdmonths
prdweeks = ls_tbtstrt-prdweeksRegards
2007 Oct 16 9:32 AM
Hello Raymond,
Could you please explain me what will be the value for field 'value' in the submit statement and what values these two fields consists
ls_tbtstrt-SDLSTRTDT " <- add this
ls_tbtstrt-SDLSTRTTM
Regards,
Lisa
2007 Oct 16 9:44 AM
Sample Program: Immediate Start with JOB_CLOSE
Submit job for processing: immediate start
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = JOBNUMBER " Job identification: number
JOBNAME = JOBNAME " and name.
STRTIMMED = 'X' " Schedules the job for
" immediate start. The job
" is started immediately
" only if the user has the
" RELE authorization to
" release a job to run.
IMPORTING
JOB_WAS_RELEASED = JOB_RELEASED " If user has authorization
" to release jobs to run, job
" is automatically released
" when it is scheduled. This
" field is set to 'x' if the
" job has been released.
" Otherwise, the job is sche-
" duled but must be released
" by an administrator before
" it can be started.
EXCEPTIONS
CANT_START_IMMEDIATE No longer used. Replaced by IMPORTING
parameter JOB_WAS_RELEASED.
INVALID_STARTDATE = 01
JOBNAME_MISSING = 02
JOB_CLOSE_FAILED = 03
JOB_NOSTEPS = 04
JOB_NOTEX = 05
LOCK_FAILED = 06
OTHERS = 99.
IF SY-SUBRC > 0.
<Error processing>
2007 Oct 16 12:33 PM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |