Application Development 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: 

2 spool - 1 program

Former Member
0 Kudos

Hi folks,

Lets say that I want to create a program that is going to produce 2 different spools. This program will be a batch so will run in background. By defaulf everything that I write using the WRITE statement is going to go in a spool. I have a requirement to split the information in 2 spools.

The way I am thinking of doing it is:

- Execute Program1

- Send the information to be displayed in the second spool in either a Z-Table or in ABAP Memory

- Submit Program2 from Program1, using:

SUBMIT program2

TO SAP-SPOOL WITHOUT SPOOL DYNPRO

AND RETURN

Program2 would read from memory or Z-Table and would write that information to the list. This information would end up in the second spool.

- Once return from Program2, from Program1 write the information to go in the first spool.

I tried and it works ... But is there a better way ? I checked for a function that let me creates a spool and that I can send my information to be displayed in the spool. I could not find anything. Any of you guys would know something for this. I checked Function-Pool SLST for list processing and many of the Function-Pool for the spool(SPOA, SPOB, SPOC, SPOD, SPOF, SPOI, SPOK, SPOL, SPOO, SPOR, SPOS, SPOX). Can't find anything. Maybe one of you did this before.

Thanks,

Pat

Message was edited by: Pat Baillar

Message was edited by: Pat Baillar

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You can do that without complicating the calling sequence and submitting programs....

Use New-page print on command to open a spool request and New-page print off to close the spool. using this you can have any number of spools generated from one program.

Here is the sample code for your reference.

&----


*& Report YTEST2SPOOLS *

*& *

&----


*& *

*& *

&----


REPORT YTEST2SPOOLS .

DATA PARAMS LIKE PRI_PARAMS.

DATA: DAYS(1) TYPE N VALUE 2,

COUNT(3) TYPE N VALUE 1,

VALID TYPE C.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

DESTINATION = 'LOCL'

COPIES = COUNT

LIST_NAME = 'TEST'

LIST_TEXT = 'Test for multiple spools'

IMMEDIATELY = ' '

RELEASE = 'X'

NEW_LIST_ID = 'X'

EXPIRATION = DAYS

LINE_SIZE = 79

LINE_COUNT = 23

LAYOUT = 'X_PAPER'

SAP_COVER_PAGE = 'X'

RECEIVER = 'SAP*'

DEPARTMENT = 'System'

NO_DIALOG = 'X'

IMPORTING

OUT_PARAMETERS = PARAMS

VALID = VALID.

IF VALID <> SPACE.

NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG.

WRITE / 'This goes into spool ONE'.

SKIP 5.

WRITE / 'This goes into spool ONE'.

NEW-PAGE PRINT OFF.

NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG.

WRITE / 'This goes into spool TWO'.

WRITE / 'This goes into spool TWO'.

WRITE / 'This goes into spool TWO'.

WRITE / 'This goes into spool TWO'.

NEW-PAGE PRINT OFF.

ENDIF.

13 REPLIES 13

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Not sure I 100% follow you, but I would suggest using memeory(IMPORT/EXPORT) instead of writing to the db. Have one driver program which sumbits the two lists, each submitted program will generate separate spools.

Regards,

Rich Heilman

Former Member
0 Kudos

To start a new spool request, you can use FM GET_PRINT_PARAMETERS. It's well documented.

Rob

0 Kudos

Look at this small program.


  DATA: params LIKE pri_params.

  CALL FUNCTION 'GET_PRINT_PARAMETERS'       "Obtain print
    EXPORTING
      no_dialog             = 'X'    "parameters
    IMPORTING
      out_parameters        = params
    EXCEPTIONS
      archive_info_not_found       = 1
      invalid_print_params         = 2
      invalid_archive_params       = 3
      OTHERS                       = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  NEW-PAGE PRINT ON PARAMETERS params NO DIALOG.
  WRITE:/ 'my first spool'.

  NEW-PAGE PRINT ON PARAMETERS params NEW-SECTION NO DIALOG.

  WRITE:/ 'my second spool'.

Former Member
0 Kudos

Hi,

You can do that without complicating the calling sequence and submitting programs....

Use New-page print on command to open a spool request and New-page print off to close the spool. using this you can have any number of spools generated from one program.

Here is the sample code for your reference.

&----


*& Report YTEST2SPOOLS *

*& *

&----


*& *

*& *

&----


REPORT YTEST2SPOOLS .

DATA PARAMS LIKE PRI_PARAMS.

DATA: DAYS(1) TYPE N VALUE 2,

COUNT(3) TYPE N VALUE 1,

VALID TYPE C.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

DESTINATION = 'LOCL'

COPIES = COUNT

LIST_NAME = 'TEST'

LIST_TEXT = 'Test for multiple spools'

IMMEDIATELY = ' '

RELEASE = 'X'

NEW_LIST_ID = 'X'

EXPIRATION = DAYS

LINE_SIZE = 79

LINE_COUNT = 23

LAYOUT = 'X_PAPER'

SAP_COVER_PAGE = 'X'

RECEIVER = 'SAP*'

DEPARTMENT = 'System'

NO_DIALOG = 'X'

IMPORTING

OUT_PARAMETERS = PARAMS

VALID = VALID.

IF VALID <> SPACE.

NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG.

WRITE / 'This goes into spool ONE'.

SKIP 5.

WRITE / 'This goes into spool ONE'.

NEW-PAGE PRINT OFF.

NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG.

WRITE / 'This goes into spool TWO'.

WRITE / 'This goes into spool TWO'.

WRITE / 'This goes into spool TWO'.

WRITE / 'This goes into spool TWO'.

NEW-PAGE PRINT OFF.

ENDIF.

Former Member
0 Kudos

Thanks for the reply.

What I am trying to know is if there are other way to create more than one spool from a single program beside using the following command:

SUBMIT <program>

TO SAP-SPOOL WITHOUT SPOOL DYNPRO

AND RETURN.

Using the SUBMIT like this will create a different spool than the one used by the calling program. But I don't like the fact that its my firt program that have the information that must be contain the spool created by the submit. Like you suggest we can use the ABAP Memory (or Z-table, but I agree with you) to pass the information to the submitted program.

I just want to know if there is another way. Exemple a function that creates a spool and that lets you export to it, the content of the spool. Or a method or something else.

Thanks,

Patrick

Former Member
0 Kudos

Thanks I will try that and will come back to distribute points once tested.

Former Member
0 Kudos

I read the documentation of SAP on "NEW-PAGE PRINT ON" and it says obsolete. But it works for me. Thanks.

0 Kudos

If you do F1 on 'print', you'll see that it says that the FM is the way to do it.

Rob

Former Member
0 Kudos

Thanks everyone, it creates a much nicer solution.

0 Kudos

Hello Pat,

Viewed your postings regarding Multiple Spools - 1 Program.

I too am encountering the same concept and would be glad if you can post On How you have overcome this.

If you could provide the Code it would be of great help.

Regards,

- PSK

Former Member
0 Kudos

Hi,

Read Nagaraju Chidurupalli comments, it is exactly that program structure that I used. The rest of the coding is irrelevant as you are going to apply your own logic.

Regards,

Pat

0 Kudos

Hello Pat,

Thanks for your reply.

I implemented the same within a Loop and was able to produce the output in the format required.

Any idea How the Archive Parameters should be used for the same FM and when the Object is run in Background mode?

Regards,

- PSK

Former Member
0 Kudos

Sorry Sravan,

The archive option, I didn't used, so I cannot help you here.

Regards,

Pat