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

Many documents into one spool request

Former Member
0 Likes
3,948

How can I control the opening & closing of spool requests in ABAP?

The context is a program that prints dunning letters and their associated billing documents.

We want the hard copies to appear in the correct order (dunnning letter, its billing documents, dunnning letter, its billing documents,...)

One way to achieve this could be to have a single spool request for each "dunning letter + billing documents" set of documents.

Currently the documents go into the spool-request list in the correct order (in separate spool requests), but that does not ensure the correct order for the hard copies, since we have more than one work process handling the spool queue.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,508

Hi,

Once the spool number is processed, build a logic to delete the spool using FM RSPO_R_RDELETE_SPOOLREQ.

This would ensure that two processes wont access the same spool number.

Best regards,

Prashant

10 REPLIES 10
Read only

Former Member
0 Likes
2,509

Hi,

Once the spool number is processed, build a logic to delete the spool using FM RSPO_R_RDELETE_SPOOLREQ.

This would ensure that two processes wont access the same spool number.

Best regards,

Prashant

Read only

0 Likes
2,508

Thanks, Prashant.

My problem is the opposite one:

I am trying to put amny documents into one spool request!

Read only

christian_wohlfahrt
Active Contributor
0 Likes
2,508

Hi John!

You can control this with flags of the printing options.

Two flags 'new spool request' and 'protection against append' handle the possibility of 'two prints in one spool'.

If two requests are combined into one spool is based on the spool name (also in the printing options) - if name is same, then appending is done (and the flags are matching).

So you should define unique names for the two documents to be grouped (e.g. concatenate the billing doc number and something else). Also the last (billing doc?) can set the protection flag - maybe the first should have the 'new spool'-flag.

For testing you can use a test-report, just make some write statements, have the flags in some parameters and plan a job with several steps - in each step some different flag combinations from report-variants. Then you can test the behavior quite easy.

Regards,

Christian

Read only

0 Likes
2,508

Thanks, Christian.

I should have said that the dunning letters & billing documents are SAPscript documents. So I do not have direct control over their creation.

For the dunning letters, I'm using the FM 'PRINT_DUNNING_NOTICE' (or my own version of that).

For the billing documents, I'm calling the form einzelnachricht_ohne_update in program rsnast00.

What do you mean by 'printing options'?

For SAPscript documents, we have the structure itcpo.

Read only

0 Likes
2,508

Hi John!

I put at some time two and more (different) smartforms into one spool, so this is surely working - if you have access to the spool parameters.

They can be found at many places, e.g. in the popup when pushing the print-button. Also in the import-parameter of the smartform-function module, but in itcpo it's:

itcpo-TDNEWID for 'new spool' (flag for the first doc)

(itcpo-TDDATASET

itcpo-TDSUFFIX1

itcpo-TDSUFFIX2 ) for the spool name

itcpo-TDIMMED = space (immediate output can't work)

itcpo-TDFINAL for 'no append' (flag for the last doc)

I see you have a parameter in PRINT_DUNNING_NOTICE, but the second call it's not so easy.

It's a generic call, I don't have time to figure out the exact situation - just have a look, where such values like tdnewid come from in 2nd call.

Maybe a watchpoint might help; in FM OPEN_FORM it's parameter OPTIONS (like ITCPO) which you should have a look at.

There are also separate function modules, which can open and close spool requests (if you like to create several spools in one report) - but these might be too much overload for your problem (right now).

Regards,

Christian

Read only

0 Likes
2,508

Thanks again, Christian.

I'm nearly there now. I'm getting a single spool request for each "dunning letter + billing documents" set of documents.

I still need to close each change request, because, if the user re-runs the program, the new documents will go into the same spool requests as the old ones, unless these spool requests have been deleted.

Now I could close a spool request by setting itcpo-tdfinal to 'X' for the last document for the spool request. However, the spooling of this document could fail (I'm checking the return code), in which case the spool request would not be closed, I assume.

I have tried using the FMs RSPO_OPEN_SPOOLREQUEST & RSPO_CLOSE_SPOOLREQUEST, but I cannot make the documents go into the spool request opened by the FM.

I get an empty spool request opened by the FM followed by a spool request with the same type & title holding the documents.

Read only

0 Likes
2,508

Hallo Christian,

I have a problem similar to this problem. I have a program that has to print a lot of different smartforms in opposit order in one spool request to get the the right order of printing.

I have 2 questions.

1. What paramaters do you have to set to put al those smartforms output in the same spool request.

2. Is there a possibilty to print the smartforms ouptut in the opposite order. (The last smartform output has to be print first The second last has to printed second etc......The first has to be printed last) like a LIFO.

I'm interesting for your answer.

Frank

Read only

0 Likes
2,508

Hi!

@John:

I'm not so sure, if you aren't ready by now. Even if last spool fails, next run will start with flag for new spool request -> might get a new one anyway.

The function modules should work in case of write-output - looks like bad luck in sapscript case.

@Frank:

Parameters like described above.

You never will get the LIFO order - the output is done by independent program calls, there can't be a re-order with just a flag.

You might call your documents in a different order and you might try to write a spool, read the result, re-order the pages and create a new / changed version.

But it's much easier to set a flag in a printer (definition in SAP), so that a printer makes a LIFO print of a spool request. Therefore you can put the documents into one request according above hints.

Regards,

Christian

Read only

Former Member
0 Likes
2,508

My program is working: for each dunning letter and its billing documents there is one spool request. Thanks, Christian.

Some key points...

[1] Invoices in table MHND can be other than SD invoices. The non-SD ones were disregarded - trying to print them as SD billing documents would fail, and maybe mess up the logic for opening/closing spool requests.

[2] For each billing document, I used itcpo values exactly as for its dunning letter, except that:

for the dunning letter, itcpo-tdnewid = 'X' and itcpo-tdfinal = ' ';

for billing documents other than the last, itcpo-tdnewid = ' ' and itcpo-tdfinal = ' '.

for the last billing document for the dunning letter, itcpo-tdnewid = ' ' and itcpo-tdfinal = 'X';

If you use different values of any of tddest, tdreceiver, tddataset, tdsuffix1, tdsuffix2,..., for instance, then you will get a new spool request, whatever the values of tdnewid or tdfinal.

[3] Fortunately we already use our own print program for billing documents. So just before the CALL FUNCTION 'OPEN_FORM', I tested the value of sy-cprog, and if it was the name of my report then I assigned as in [2] to the structure for the OPTIONS (i.e. itcpo) parameter of OPEN_FORM.

[4] To pass values for [3] from the report to the print program, I used export/import to/from memory.

[5] Because I was controlling the itcpo values, I was able to arrange that something helpful to the user appears in the Title column in 'Own spool requests' (transaction SP02). This title comes from the itcpo fields tddataset, tdsuffix1 & tdsuffix2, and I arranged that the dunning level and the customer number appears in Title.

Read only

Former Member
0 Likes
2,508

This has been working OK for a while now.