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

Generate Spool from internal table while running in background??

Former Member
0 Likes
826

Hi,

I have a requirement such that i have to generate an excel sheet when the program is run in foreground (data is fetched from an internal table). That i have managed.

Now when the program is run in background, then i have to generate a spool for this(by checking sy-batch) as in background mode excel sheet can be donwloaded (in presentation).

Please tell me how can i generate a spool request from the internal table and also how to get the name of that spool request, which is gerenated.

Many thanks

Rahul

1 ACCEPTED SOLUTION
Read only

ChandrashekharMahajan
Active Contributor
0 Likes
641

Hi Rahul,

to generate spool, use below code

FORM create_spool .

CONSTANTS : l_c_device(4) VALUE 'LOCL'.

    • Create Spool Request

NEW-PAGE PRINT ON

LINE-SIZE 120

DESTINATION l_c_device

IMMEDIATELY ' '

KEEP IN SPOOL 'X'

NEW LIST IDENTIFICATION 'X'

NO DIALOG.

ENDFORM. " create_spool

And after createing spool to get the spool number use below code,

FORM obtain_spool_id .

TYPES : BEGIN OF t_tsp01,

rqident TYPE tsp01-rqident,

rqowner TYPE tsp01-rqowner,

END OF t_tsp01.

DATA : it_tsp01 TYPE STANDARD TABLE OF t_tsp01,

wa_tsp01 LIKE LINE OF it_tsp01.

SELECT rqident

rqowner

FROM tsp01

INTO TABLE it_tsp01

WHERE rqowner = sy-uname.

SORT it_tsp01 BY rqident DESCENDING.

READ TABLE it_tsp01 INTO wa_tsp01 INDEX 1.

IF sy-subrc = 0 .

v_spool_nr = wa_tsp01-rqident.

ENDIF.

  • Capture the immediate spool created for this report

  • v_spool_nr = sy-spono.

ENDFORM. " obtain_spool_id

Regards,

Chandra

(award points if helpful)

2 REPLIES 2
Read only

Former Member
0 Likes
641

Hi,

When you schedule a report in Background Job with some WRITE statements,automatically it generates a spool.

Go to SP01 and find that related spool and download it.

regards,

Anji

Read only

ChandrashekharMahajan
Active Contributor
0 Likes
642

Hi Rahul,

to generate spool, use below code

FORM create_spool .

CONSTANTS : l_c_device(4) VALUE 'LOCL'.

    • Create Spool Request

NEW-PAGE PRINT ON

LINE-SIZE 120

DESTINATION l_c_device

IMMEDIATELY ' '

KEEP IN SPOOL 'X'

NEW LIST IDENTIFICATION 'X'

NO DIALOG.

ENDFORM. " create_spool

And after createing spool to get the spool number use below code,

FORM obtain_spool_id .

TYPES : BEGIN OF t_tsp01,

rqident TYPE tsp01-rqident,

rqowner TYPE tsp01-rqowner,

END OF t_tsp01.

DATA : it_tsp01 TYPE STANDARD TABLE OF t_tsp01,

wa_tsp01 LIKE LINE OF it_tsp01.

SELECT rqident

rqowner

FROM tsp01

INTO TABLE it_tsp01

WHERE rqowner = sy-uname.

SORT it_tsp01 BY rqident DESCENDING.

READ TABLE it_tsp01 INTO wa_tsp01 INDEX 1.

IF sy-subrc = 0 .

v_spool_nr = wa_tsp01-rqident.

ENDIF.

  • Capture the immediate spool created for this report

  • v_spool_nr = sy-spono.

ENDFORM. " obtain_spool_id

Regards,

Chandra

(award points if helpful)