09-28-2007 9:20 AM
Hi Experts,
I have one scenario like we need to develop one program for display the Job log.
For example if we run the Job in background after completion of the job, if we want to see the job log, we have to go SE37  give the job name Click on the button (JOBLOG).
It display the Job log in table format.
Our Scenario is.
We need to develop the program for display the job log for particular job.
For example if give the job name as input then it display the job log.
Please help on the same.
Thanks and regards,
Amjad Hussain,
09-28-2007 9:28 AM
Hi,
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.
Reagrds
Vasu
09-28-2007 9:28 AM
Hi,
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.
Reagrds
Vasu
09-28-2007 10:12 AM
Hi Vasu,
Thanks for suggestion,
We don't want to run the job in background.
Already it was run. Just we want to display the joblog based on jobname and date.
I am explain my requirement .
If we want to see the joblog then we have do like
Go to SE37  give the job name  Select the Check box Finished  Execute.
It display the all the jobs which are run the successful.
If we want to see the joblog then we have to select the job and then click on the button joblog.
It display the table format like DATE, TIME, MESSAGE TEST, MESSAGE CLASS, MESSAGE NO, MESSAGE TYPE.
Then now the User has doing manually like ,
1) Download the table into Excel file then select the entries based on MESSAGE NO(34)
2) Find out the Document, and based on that Document no find out the some information(Output type, Sale Org, Sales Group, etc ,.)
We need to develop the program for above scenario.
Thanks and regards,
Amjad Hussain,
09-28-2007 10:29 AM
Hi Mohammed,
There is an FM for this.
Use the FM BP_JOBLOG_SHOW_SM37B.
Reward points if helpful.
Ravi