Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Programmatically reading and processing a spool file

Former Member
0 Likes
9,065

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
6,527

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

9 REPLIES 9
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
6,527

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.

Read only

0 Likes
6,527

>

> 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.

Read only

0 Likes
6,527

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?

Read only

0 Likes
6,527

HI Ruby,

Create a Ztable and save every spool you generated, including Date,

Read only

0 Likes
6,527

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

Read only

0 Likes
6,527
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

Read only

Former Member
0 Likes
6,527

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

Read only

ThomasZloch
Active Contributor
0 Likes
6,527

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

Read only

Former Member
0 Likes
6,528

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