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

creating spool within a program

Former Member
0 Likes
2,134

I have a program that is creating a file and using GUI_DOWNLOAD to put the file on the user's machine. some of the processes are timing out so now I have to run the process in the background and have the process create a spool file and the user can then open the spool and save it to thier machine. I am not sure how to code to create a spool file. I found this code in another thread within this forum but I am not sure what it is doing.

<i>select single spld into usr01-spld from usr01 where bname eq sy-uname .

if sy-subrc eq 0 .

move: usr01-spld to loc_dest .</i>

I am assuming that I will have to check weather the job is running in foreground or background so that I can execute the code for GUI_DOWNLOAD or create the spool. Is the code listed above all that I have to use to create the spool file or is there something esle that I need to do.

thanks in advance for the help

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,695

Hi,

If you are running it in background for the spool creation

a simple WRITE statement would suffice.

loop at itab.

write : itab.

endloop.

When this is run in background the WRITE statement would automatically create a spool

8 REPLIES 8
Read only

Former Member
0 Likes
1,695

if run inforeground use GUI_DOWNLOAD else just leave as such when run in background the spool is created which can be seen and downloaded later...

Read only

Former Member
0 Likes
1,696

Hi,

If you are running it in background for the spool creation

a simple WRITE statement would suffice.

loop at itab.

write : itab.

endloop.

When this is run in background the WRITE statement would automatically create a spool

Read only

Former Member
0 Likes
1,695

Hi

What do you exactly mean with to create a spool?

If you need to create a file in background you need only to use OPEN DATASET statament, so use this statament insted of GUI_DOWNLOAD:

IF SY-BATCH = SPACE.
   CALL FUNCTION 'GUI_DOWNLOAD'
       .......................................
       TABLES
           DATA = T_FILE
ELSE.
    OPEN DATASET <FILE> IN TEXT MODE ENCODING DEFAULT.
    IF SY-SUBRC = 0.
      LOOP AT T_FILE.
          TRANSFER T_FILE TO <FILE>.
      ENDLOOP.
    ENDIF.
    CLOSE DATASET <FILE>.
ENDIF.

If you need to create prnt spool:

IF SY-BATCH = SPACE.
   CALL FUNCTION 'GUI_DOWNLOAD'
       .......................................
       TABLES
           DATA = T_FILE
ELSE.
    LOOP AT T_FILE.
       WRITE T_FILE
    ENDLOOP.
ENDIF.

Max

Read only

Former Member
0 Likes
1,695

I was able to get the spool by using the write statement. the next problem I am having is that when view the spool, it only shows the first 10 pages. also when I want to save the spool as a file, it looks like it is only saving the data for the first 10 pages. is there a way that I can save the whole file?

Read only

Former Member
0 Likes
1,695

it looks like a can get the whole file by selecting the Goto->Display requests -> Setings and changing the page number from 10 to 999999. the next problem I am having is that it looks like I am getting the page break info. Is there a way to suppress this and just get the data lines?

Read only

0 Likes
1,695

Hi

Why don't you create a file in APPLICATION SERVER and then transfer the file by FTP?

Max

Read only

Former Member
0 Likes
1,695

we were thinking of that but I wanted to see it this was a option before I went the FTP route. with FTP, there comes the issue with usernames and password being stored in the program which is not what we want to do. There are also other issues with the FTP process that we would like to avoid if possible. that is why we are trying this first.

Read only

0 Likes
1,695

Hi

It can create a directory (it doesn't needs it is on server sap) who users and SAP server can be read and update, in this way this directory is a directory of Application Server.

U can try to create a program u read the spool (see fm RSPOSPOOL)

Max