04-12-2006 1:22 PM
How to catch the corresponding spool request which i have scheduled to run in background.
Please help me with any example program.
04-12-2006 1:28 PM
Hi Ashok,
Go to sm37 transaction there will an option to view the spool for completed jobs on the apllication tool bar(ctrlshiftf8)
Regards,
Ravi
04-12-2006 1:32 PM
I think Ashok is after the table name.
Have you tried to find it out for yourself. I cannot imagine it is that difficult.
Martin
04-12-2006 1:33 PM
TSP01 is the table from where you can retrieve the spool id..
Regards,
Suresh Datti
04-12-2006 1:32 PM
Convert Spool request to PDF format to your local drive
After sending your ABAP List or SAP Scripts to the spool request (SP01), you can use the SAP standard spool PDF conversion program.
RSTXPDFT4 - Convert ABAP List and SAP Script to PDF files
Immediately send the spool to SAP user after a background run
After running the background jobs, send the spool to the SAP users Office Mail Box.
REPORT ZMAILSPOOL.
INCLUDE LBTCHDEF.
Include the Business Object Repository object
INCLUDE <CNTN01>.
DATA ABAPNM LIKE SY-REPID.
DATA BEGIN OF LOCAL_JOB.
INCLUDE STRUCTURE TBTCJOB.
DATA END OF LOCAL_JOB.
DATA BEGIN OF LOCAL_STEP_TBL OCCURS 10.
INCLUDE STRUCTURE TBTCSTEP.
DATA END OF LOCAL_STEP_TBL.
Data declarations for the mail recipient
DATA RECIPIENT TYPE SWC_OBJECT.
DATA RECIPIENT_OBJ LIKE SWOTOBJID.
SWC_CONTAINER CONTAINER.
Data declarations for the background job
PARAMETERS ABAPNAME(20) DEFAULT 'ZTEST1'.
PARAMETERS EMPFNAME LIKE SY-UNAME DEFAULT SY-UNAME.
ABAPNM = ABAPNAME.
LOCAL_JOB-JOBNAME = ABAPNAME.
Generate recipient object (see report RSSOKIF1 for an example)
1. Create the recipient:
IF EMPFNAME <> SPACE.
"** 1.1 Generate an object reference to a recipient object
SWC_CREATE_OBJECT RECIPIENT 'RECIPIENT' SPACE.
"** 1.2 Write the import parameters for method
"** recipient.createaddress into the container
"** and empty the container
SWC_CLEAR_CONTAINER CONTAINER.
"** Set address element (internal user 'JSMITH')
SWC_SET_ELEMENT CONTAINER 'AddressString' EMPFNAME.
"** Set address type (internal user)
SWC_SET_ELEMENT CONTAINER 'TypeId' 'B'.
"** 1.3 Call the method recipient.createaddress
SWC_CALL_METHOD RECIPIENT 'CreateAddress' CONTAINER.
"** Issue any error message generated by a method exception
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO.
ENDIF.
SWC_CALL_METHOD RECIPIENT 'Save' CONTAINER.
SWC_OBJECT_TO_PERSISTENT RECIPIENT RECIPIENT_OBJ.
ENDIF.
Recipient has been generated and is ready for use in a
background job
CALL FUNCTION 'JOB_OPEN'
exporting
DELANFREP = ' '
JOBGROUP = ' '
jobname = LOCAL_JOB-JOBNAME
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
IMPORTING
JOBCOUNT = LOCAL_JOB-JOBCOUNT
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4
.
if sy-subrc <> 0.
WRITE: / 'JOB_OPEN PROBLEM ', SY-SUBRC.
ELSE.
WRITE: / 'JOB OPEN SUCCESS',
LOCAL_JOB-JOBNAME, LOCAL_JOB-JOBCOUNT.
endif.
CALL FUNCTION 'JOB_SUBMIT'
exporting
ARCPARAMS =
authcknam = SY-UNAME
COMMANDNAME = ' '
OPERATINGSYSTEM = ' '
EXTPGM_NAME = ' '
EXTPGM_PARAM = ' '
EXTPGM_SET_TRACE_ON = ' '
EXTPGM_STDERR_IN_JOBLOG = 'X'
EXTPGM_STDOUT_IN_JOBLOG = 'X'
EXTPGM_SYSTEM = ' '
EXTPGM_RFCDEST = ' '
EXTPGM_WAIT_FOR_TERMINATION = 'X'
jobcount = LOCAL_JOB-JOBCOUNT
jobname = LOCAL_JOB-JOBNAME
LANGUAGE = SY-LANGU
PRIPARAMS = ' '
REPORT = ABAPNM
REPORT = 'ZTEST1'
VARIANT = ' '
IMPORTING
STEP_NUMBER = LOCAL_JOB-STEPCOUNT
EXCEPTIONS
BAD_PRIPARAMS = 1
BAD_XPGFLAGS = 2
INVALID_JOBDATA = 3
JOBNAME_MISSING = 4
JOB_NOTEX = 5
JOB_SUBMIT_FAILED = 6
LOCK_FAILED = 7
PROGRAM_MISSING = 8
PROG_ABAP_AND_EXTPG_SET = 9
OTHERS = 10
.
if sy-subrc <> 0.
WRITE: / 'JOB_SUBMIT PROBLEM ', LOCAL_JOB-JOBCOUNT,
LOCAL_JOB-JOBNAME, ABAPNAME, SY-SUBRC.
endif.
IF EMPFNAME <> SPACE.
CALL FUNCTION 'JOB_CLOSE'
exporting
AT_OPMODE = ' '
AT_OPMODE_PERIODIC = ' '
CALENDAR_ID = ' '
EVENT_ID = ' '
EVENT_PARAM = ' '
EVENT_PERIODIC = ' '
jobcount = LOCAL_JOB-JOBCOUNT
jobname = LOCAL_JOB-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 = RECIPIENT_OBJ
TARGETSERVER = ' '
DONT_RELEASE = ' '
IMPORTING
JOB_WAS_RELEASED = 'X'
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 ).
WRITE: / 'Job_Close Problem:', ABAPNAME, SY-SUBRC.
ELSE.
WRITE: / 'Job_Close done'.
ENDIF.
ELSE. "no empfname
...
ENDIF.
regards
vinod
04-12-2006 1:35 PM
RSTXPDFT4
Convert spool request to PDF document
RSTXPDFT5
GUI download of a spool request
function modules
So_wind_spool_list
Browse printer spool numbers according to user informed.
So_spool_read
Fetch printer spool according to the spool number informed.
regards
vinod
04-12-2006 1:36 PM
Hi,
you can do little coding also...
select *
from TSP01
into table IT_TSP01
where RQOWNER = 'USER'
and RQCMODE = '1'.
you can also give program name RQ2NAME using like in where clause.
Regards
vijay
04-12-2006 1:37 PM
04-12-2006 7:34 PM
Hi Ashok,
I've written a little example report for you.
You can enter the name of the backgroundjob and the rundate in the selection screen.
Then the report acquires the matching background jobs and the spool numbers from the table
TBTCP
, retrieves the spool with the function modulRSPO_RETURN_ABAP_SPOOLJOB
and put this output to his list.Hope this helps.
Reagards,
Stefan
*&---------------------------------------------------------------------*
*& Report ZGER_TEST
*&---------------------------------------------------------------------*
*& Ermitteln der Spoolausgabe für einen Hintergrundjob
*&---------------------------------------------------------------------*
REPORT zger_test.
DATA: BEGIN OF gs_jobinfo,
jobcount TYPE btcjobcnt,
stepcount TYPE btcstepcnt,
progname TYPE btcprog,
variant TYPE btcvariant,
listident TYPE btclistid,
sdldate TYPE btcsdldate,
sdltime TYPE btcsdltime,
END OF gs_jobinfo.
DATA: gt_jobinfo LIKE TABLE OF gs_jobinfo,
gv_liste LIKE bapixmspoo,
gt_liste LIKE TABLE OF gv_liste,
gv_rqident LIKE tsp01-rqident.
PARAMETERS: p_btcjob TYPE btcjob OBLIGATORY.
SELECT-OPTIONS: s_date FOR sy-datum.
START-OF-SELECTION.
SELECT * FROM tbtcp INTO CORRESPONDING FIELDS OF TABLE gt_jobinfo
WHERE jobname = p_btcjob
AND sdldate IN s_date.
LOOP AT gt_jobinfo INTO gs_jobinfo.
ULINE.
WRITE: /1 'Output of Job:', p_btcjob,
'Jobnumber:' , gs_jobinfo-jobcount,
'Date / Time:' , gs_jobinfo-sdldate, gs_jobinfo-sdltime,
/1 'Step:' , gs_jobinfo-stepcount,
'Programm:' , gs_jobinfo-progname,
'Variant' , gs_jobinfo-variant.
.
SKIP.
IF NOT gs_jobinfo-listident IS INITIAL.
CLEAR gt_liste.
gv_rqident = gs_jobinfo-listident.
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
rqident = gv_rqident
TABLES
buffer = gt_liste
EXCEPTIONS
no_such_job = 1
not_abap_list = 2
job_contains_no_data = 3
selection_empty = 4
no_permission = 5
can_not_access = 6
read_error = 7
OTHERS = 8.
SKIP.
IF sy-subrc = 0.
LOOP AT gt_liste INTO gv_liste.
WRITE /1 gv_liste.
ENDLOOP.
ELSE.
WRITE /1 'Error!'.
ENDIF.
ELSE.
WRITE 'No spool'.
ENDIF.
ULINE.
ENDLOOP.