‎2011 Jan 05 11:48 AM
Hello,
I would like to read and process a spool file generated by a background job in my ABAP program.
Can anyone advise if this is possible in SAP and if so, the best way to do this?
The only information I will have in my program is the job name and the date on which the job was run. I then need to find the corresponding spool and read this into an internal table.
Any ideas on how to do this would be appreciated.
Thanks,
Ruby
‎2011 Jan 07 5:18 AM
Hi Ruby,
FIrst use BP_JOB_READ to read the job.
You will get the spools from return table SPOOL_ATTRIBUTES-SPOOLID.
You can use RSPO_RETURN_SPOOLJOB to read the spool using that spool id.
Regards,
Joivto
‎2011 Jan 05 12:10 PM
Hi,
Use table TBTCP for relating the spool and background job name. Both are available.
for processing a spool request in your program , you can search in SCN.There are lot of posts available.
‎2011 Jan 05 12:27 PM
>
> Hi,
>
> Use table TBTCP for relating the spool and background job name. Both are available.
> for processing a spool request in your program , you can search in SCN.There are lot of posts available.
Table TBTCP has the date when the job was scheduled, but not date when the job was run. Since Ruby wrote that he wants to select by the date when the job was run, he can't simply to a SELECT from TBTCP.
@ Ruby:
With FM BP_JOB_SELECT you can search jobs by jobname and run time date. In the output list of the FM you'll get the internal job number (JOBCOUNT) from all matching jobs. Now you can do a SELECT from TBTCP supplying the JOBCOUNT and JOBNAME which were supplied by BP_JOB_SELECT.
‎2011 Jan 06 9:32 AM
Thank you guys for your responses. I have checked table TBTCP and I can see one of the spools in here, however, my job generates 3 separate spools and only the last one seems to be in this table.
Is there any way of getting the other spools or is this a limitation of SAP?
‎2011 Jan 06 9:40 AM
HI Ruby,
Create a Ztable and save every spool you generated, including Date,
‎2011 Jan 06 11:56 AM
RSPO_FIND_SPOOL_REQUESTS
you should be able to\, based ont he spool name, date and time, determine which are for the job that was run
‎2011 Jan 07 5:22 AM
DATA : it_spool TYPE STANDARD TABLE OF rsporq .
.
*&---------------------------------------------------------------------*
*& Form find_spool_request_id
*&---------------------------------------------------------------------*
FORM find_spool_request_id.
CALL FUNCTION 'RSPO_FIND_SPOOL_REQUESTS'
EXPORTING
allclients = '320'
datatype = '*'
has_output_requests = '*'
rq0name = nast-dsnam
rq1name = '*'
rq2name = '*'
rqdest = 'LOCL'
rqowner = sy-uname
TABLES
spoolrequests = it_spool
EXCEPTIONS
no_permission = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE i000 DISPLAY LIKE 'E' WITH text-002.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " find_spool_request_id
READ TABLE it_spool INTO wa_spool INDEX 1.
v_spoolno = wa_spool-rqident.
*Get Spool request attributes
SELECT SINGLE *
FROM tsp01
INTO tsp01
WHERE rqident EQ v_spoolno.Edited by: K.Manas on Jan 7, 2011 6:22 AM
‎2011 Jan 05 12:38 PM
Look at RSPO_FIND_SPOOL_REQUESTS to determine the spool id, then at rspo_return_spooljob to read the data from the spool file into a buffer where you can access it.
look at function groups SPOO and SPOX for other helpful function modules
dave
‎2011 Jan 05 12:47 PM
Please don't leave meaningless comments when closing old threads, the comment box can be left empty, only fill it when you want to describe your solution so other people might benefit.
Thomas
‎2011 Jan 07 5:18 AM
Hi Ruby,
FIrst use BP_JOB_READ to read the job.
You will get the spools from return table SPOOL_ATTRIBUTES-SPOOLID.
You can use RSPO_RETURN_SPOOLJOB to read the spool using that spool id.
Regards,
Joivto