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

Report will be split into different spools

Former Member
0 Likes
1,518

Hi experts,

I have a requirement to display a report using WRITE statements. I have an internal table that contains all the data that I will be needing for the report. Then I will loop at the internal table and display the workarea one by one. But then, I need to split the spool into different files when the customer is changed. Will it be possible to split the spool into files? What Function module should I use? I will not be using Smartforms or sapscript. This will be run every night through a batch job in background.

Any help will be greatly appreciated.

Thanks,

Lalyn

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,099

Hi Lalyn,

Use AT-NEW kunnr control statement for your internal table. Then perform function modules for background job scheduling.

Job Open, Job Submit & Job Close.

Ashven

8 REPLIES 8
Read only

Former Member
0 Likes
1,100

Hi Lalyn,

Use AT-NEW kunnr control statement for your internal table. Then perform function modules for background job scheduling.

Job Open, Job Submit & Job Close.

Ashven

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,099

ONe easy way to do this is to have the ouput as a separate program and then use the SUBMIT statement with the TO SAP-SPOOLER extension. This will allow you to create multple spools from one driver program.

Regards,

Rich Heilman

Read only

christian_wohlfahrt
Active Contributor
0 Likes
1,099

Hi Lalyn!

Yes it's possible. For some help about the flags look

Use FM SET_PRINT_PARAMETERS and GET_PRINT_PARAMETERS to get and set the print parameters (yes, you guessed by the name); have a look at both documentation, too - they are quite long and usefull.

Regards,

Christian

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
1,099

I think that FM GET_PRINT_PARAMETERS with the option 'new spool request' (PRI_PARAMS-PRNEW) should work. It would look like this:

DATA: params TYPE pri_params,
      valid.

params-prnew = ‘X’.

CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING
      no_dialog      = 'X'
      in_parameters = params
    IMPORTING
      out_parameters = params
      valid          = valid.

and then when you need to start new page:

NEW-PAGE PRINT ON PARAMETERS params NO DIALOG.

Depending on your requirements you might need to populate additional fields when calling the FM (it is pretty well documented).

Note that 'no dialog' option should be selected in both places for background processing. It is also possible that params-prnew should be set up after the FM call - I haven't got a chance to test it, sorry!

Hope this helps.

Read only

0 Likes
1,099

Thanks Christian and Jelena. I'll try to make a sample code with the FM. I'll let you know what happens.

Lalyn

Read only

0 Likes
1,099

I actually have done early what Jelena as suggested and it did not work for me. Instead it just put all pages in one spool request.

Regards,

Rich Heilman

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
1,099

Maybe something could be done by manipulating different options in PRI_PARAMS (or other fields in GET_PRINT_PARAMETERS)? For example, the request can be separated by forcing the request name to be different. Here the request name is the 3-part 'Name' field that can be seen after double-clicking on the request entry in SP01. PRI_PARAMS has the field PLIST, which is labeled 'name of spool request'. I'm wondering what it would do...

Another thing just crossed my mind. If a report runs as a background job maybe there is some spool assignment linked directly to that job and maybe it is overriding whatever the report is trying to do? Just a guess though...

I'm very curious how this turns out. Please keep us posted, Lalyn.

Read only

0 Likes
1,099

Hi everyone,

Thanks for all the help. FInally, I was able to make my codes work. I just added the line NEW-PAGE PRINT OFF after the first spool.

DATA PARAMS LIKE PRI_PARAMS.

DATA: DAYS(1) TYPE N VALUE 2,

COUNT(3) TYPE N VALUE 1,

VALID TYPE C,

ARPARAMS LIKE ARC_PARAMS.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING DESTINATION = 'LP01'

COPIES = COUNT

LIST_NAME = 'TEST'

LIST_TEXT = 'Test NEW-PAGE PRINT ON'

" IMMEDIATELY = 'X'

" RELEASE = 'X'

NEW_LIST_ID = 'X'

EXPIRATION = DAYS

LINE_SIZE = 79

LINE_COUNT = 23

LAYOUT = 'X_PAPER'

SAP_COVER_PAGE = 'X'

RECEIVER = 'MSANTOS' "'SAP*'

DEPARTMENT = 'System'

NO_DIALOG = 'X'

IMPORTING OUT_PARAMETERS = PARAMS

VALID = VALID.

IF VALID <> SPACE.

NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG.

WRITE / 'first line..'.

NEW-PAGE PRINT OFF.

NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG.

WRITE / 'Second Line...!'.

NEW-PAGE PRINT OFF.

ENDIF.

Thanks,

lalyn