01-08-2007 12:04 PM
Hi,
Could any one let me know the name of function module to retrieve the Job Log & Spool for specified Date?
I need to apply Select Queries on Job Log/Spool of Job which has already run some days back. So I am in search of some efficient way by means of which I can retrieve Job Log/ Spool of Job which ran a few days back . I feel that there must be some Function module which would retrieve Job Log/Spool.
Please help me out by making me aware with the same.
Thanks & Regards
Jigar
01-08-2007 12:07 PM
Use JOB_OPEN, pass the job name & get the jobcount which is a unique id to refer to your job.
Then use JOB_SUBMIT to Submit the job in background. Here you need to pass the jobname & jobcount. If you want the spool output to go to a printer then use GET_PRINT_PARAMETERS to get the print parameters & pass the same in JOB_SUBMIT.
Then close the Job using JOB_CLOSE.
To get the spool number use FM BP_JOB_READ. Pass jobname & jobcount & get job steplist. Read the same & get the spool number.
REFRESH : i_jobsteplist.
SET PF-STATUS 'AGENCY'.
*----
Get the Spool Number
*----
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '20'
JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
CHANGING
RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 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.
*----
Read the Job Step list to get the spool number
*----
READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
CHECK wa_jobsteplist-listident <> space.
*----
Spool Number
*----
l_rqident = wa_jobsteplist-listident.
*----
Check the spool in TSP01
*----
SELECT SINGLE * FROM tsp01 WHERE rqident = l_rqident.
IF sy-subrc = 0.
LEAVE TO LIST-PROCESSING.
*----
Display the Spool Content on Screen
*----
CALL FUNCTION 'RSPO_DISPLAY_SPOOLJOB'
EXPORTING
rqident = l_rqident
FIRST_LINE = 1
LAST_LINE =
EXCEPTIONS
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
OTHERS = 7
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
To get the status of the job, get Jobhead from FM BP_JOB_READ.
*----
To Display the STATUS of the JOB which is exectued in background
*----
CLEAR : wa_jobsteplist.
REFRESH : i_jobsteplist.
WRITE:/ text-044. " 'DISPLAYING JOB STATUS'
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '20'
JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
CHANGING
RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
OTHERS = 4
.
*----
To Display the status text as per the status type
*----
CASE wa_jobhead-status.
WHEN 'S'. WRITE: / text-045. "'Scheduled'.
WHEN 'R'. WRITE: / text-046. "'Released'.
WHEN 'F'. WRITE: / text-047. "'Completed'.
WHEN 'A'. WRITE: / text-048. "'Cancelled'.
WHEN OTHERS.
ENDCASE.
Now, inorder to see the job log :-
*----
To display the log of the background program
*----
LEAVE TO LIST-PROCESSING.
CALL FUNCTION 'BP_JOBLOG_SHOW_SM37B'
EXPORTING
client = sy-mandt
jobcount = w_jobcount
joblogid = ' '
jobname = w_jobname
EXCEPTIONS
error_reading_jobdata = 1
error_reading_joblog_data = 2
jobcount_missing = 3
joblog_does_not_exist = 4
joblog_is_empty = 5
joblog_show_canceled = 6
jobname_missing = 7
job_does_not_exist = 8
no_joblog_there_yet = 9
no_show_privilege_given = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
01-09-2007 5:51 AM
Hi Thanks a lot for such a quick answer....
In order to get the Job Log, we need to pass Job Log ID .Could you please let me know how to get the Job Log ID? I am interested for getting Job Log of some specific Date. My job runs daily and I would like to get the JOb Log of Job which ran couple of days back. Also my requirement is to store the this Job Log inside one internal Table.
Thanks for your help
01-09-2007 5:54 AM
go to SE80 and Function Group <b> BTCH </b>..
U will find FMs related to Batch Job..
amit
01-09-2007 5:55 AM
Hi,
Please use the following FM to retrieve the JOBLOG.
BP_JOBLOG_READ
BP_JOBLOG_SHOW
RSPO_DISPLAY_SPOOLJOB
Regards
Bhupal Reddy