11-15-2007 3:11 PM
I did a quick search on this issue and found a few suggestions. One suggestion was to use something like this:
SUBMIT RSFLFIND ... TO SAP-SPOOL DESTINATION 'LT50'.
I looked at the SAP help for SUBMIT and it was quite helpful however it raised a few questions. The program that am writing will be run in the background. I want to create a simple report that will print at several different printers when it is done. Looking at the help section (specifically this part):
"The SUBMIT statement accesses an executable program rep. The executable program is executed as described under Calling Executable Reports.
The program name rep can either be specified directly or as the content of a character-like data object name. The data object name must contain the name of the program to be accessed in block capitals. If the program specified in name is not found, an irretrievable exception is generated.
The selscreen_options additions can be used to determine the selection screen for the program accessed and to supply it with values.
The list_options additions allow you to influence the output medium and the page size in the basic list for the program accessed.
You can schedule the program for background processing by specifying job_options. "
It seems like I would create a simple program like this:
DATA: number TYPE tbtcjob-jobcount,
name TYPE tbtcjob-jobname VALUE 'JOB_TEST',
print_parameters TYPE pri_params.
...
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = name
IMPORTING
jobcount = number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc = 0.
SUBMIT submitable TO SAP-SPOOL
SPOOL DESTINATION 'LT50'.
VIA JOB name NUMBER number
AND RETURN.
IF sy-subrc = 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = number
jobname = name
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc <> 0.
...
ENDIF.
ENDIF.
ENDIF.
That will then call the background job and the output will go to the print spool. I have a few reservations about this. The print spool will not be determined until the background job. The background job creates sales orders and the material group, in the sales order, determines the printer that the final report will go to. Also, if this is the way to do it, do I just do simple write statements in the background job?
11-20-2007 4:55 PM
When I go to SP01 it tells me that I have a "spool request without an output request". I assume this means that it is looking for the default printer for the user that scheduled the background job.
It looks to me like (by double-clicking on the job) the output device that is assigned is LP01. I have no idea why that is assigned to it.
Davis
11-15-2007 3:17 PM
Yes, you need to generate a report inside your SUBMIT report. You can do it with write, ALV List ..
You can determine the printer based on the material groups and assign it into L_PRINTER if you don't want to make it default.
SUBMIT submitable TO SAP-SPOOL
SPOOL DESTINATION L_PRINTER
WITHOUT SPOOL DYNPRO "<< will not bring the spool screen
VIA JOB name NUMBER number
AND RETURN.
Regards,
Naimesh Patel
11-15-2007 3:23 PM
Naimesh,
I won't know the printer (L_printer) until the job (name/number) runs. Is there a way to create a report (ALV will be fine) but instead of displaying it on the screen it send the output to a printer. I am assuming that you can create an ALV grid in background processing.
Regards,
Davis
11-15-2007 3:29 PM
Yes, you can create a ALV grid (with FM) for the background processing.
I think there should be some way to determine the printer before running the job ..
If not, try to explore the ALV's print parameter in which you can pass the printer.
Like, if your SO is generated so, from somewhere you can know the pritner. So, priorer to generating ALV, pass your printer name.. In this caase you might need to change the SUBMIT statment to remove the SPOOL DESTINATION 'LT50'.
Check out the structure slis_print_alv.
p_print-PDEST = 'ZWWW'.
Regards,
Naimesh Patel
11-15-2007 6:13 PM
Naimesh,
Thanks for the tip. I'm going to test it out then get back to the thread.
Thanks again,
Davis
11-19-2007 9:11 PM
Naimesh,
I did what you suggested but, when run in the background, the output gets stuck in the spool. There is a field <b>is_print-print_ctrl-pri_params-primm</b> which is a flag for print immediately but when I set that = to 'X' it still gets hung up in the spool. Can I not do this in the background?
Davis
11-19-2007 9:22 PM
If it has generated a spool than there must be some problem withe Spool Work process. Please check with your basis people or try to generate spool for some other output and print it out.
Regards,
Naimesh Patel
11-19-2007 10:15 PM
Naimesh,
I figured it out but I am not sure how to get around the problem. The problem was that I had LOCL as my default printer. It turns out that the default printer for the user that creates the background job overrides the printer that you specify in the parameter. Do you have any ideas what I can do so it doesn't override it?
Regards,
Davis
11-19-2007 10:28 PM
What happens it you remove your defualt printer? (default printer can be blank).
Regrads,
Naimesh Patel
11-19-2007 10:50 PM
I didn't realize that it could be blank. I'll give that a shot in the morning.
Thanks!
Davis
11-20-2007 4:44 PM
Well I just had a chance to try it out with my default printer being blank. What happened was that it sent the output to the spool (SP01) but there is no status on the job. Here is what I see:
Spool No: 3790
Type: ABAP List
Date: 11/20/2007
Time: 11:41
<b>Status: - </b> <---It has a '-' as the status
Pages: 1
Title: List1s Z_PerfectSho
Regards,
Davis
11-20-2007 5:01 PM
Try to print this SPOOL.
Start SP02.. select the spool .. and press the print button (Second on the Top).
Status '-' means the spool is created.
Regards,
Naimesh Patel
11-20-2007 5:03 PM
Yes I can print it but it will send it to a printer that I do not want (see post above). I want this to automatically print so manually releasing it will not work.
Thanks
Davis
11-15-2007 3:31 PM
Hi,
Please try this ... perhaps it may help.
...
SUBMIT submitable TO SAP-SPOOL
SPOOL DESTINATION 'LT50'.
IMMEDIATELY 'X' "Add here
VIA JOB name NUMBER number
AND RETURN.
OR
SUBMIT submitable TO SAP-SPOOL
SPOOL DESTINATION 'LT50'.
IMMEDIATELY 'X' "Add here
WITHOUT SPOOL DYNPRO "Add here
VIA JOB name NUMBER number
AND RETURN.
...
Regards,
Ferry Lianto
11-20-2007 4:55 PM
When I go to SP01 it tells me that I have a "spool request without an output request". I assume this means that it is looking for the default printer for the user that scheduled the background job.
It looks to me like (by double-clicking on the job) the output device that is assigned is LP01. I have no idea why that is assigned to it.
Davis
11-20-2007 5:03 PM
And next time when you generate the spool, make your you have "Print Immediatly" selected in your master record SU01.
Regards,
Naimesh Patel
11-20-2007 7:20 PM
Naimesh,
I do have that selected. Even if I clear the print spool it still assigns the wrong printer to the job (LP01).
Davis
11-20-2007 7:37 PM
Please try like this in the JOB creation program.
DATA: PRINT_PARAMS LIKE PRI_PARAMS.
print_pramas-pdest = 'LT50'.
print_params-primm = 'X'. " << for immediate printing
SUBMIT submitable TO SAP-SPOOL
SPOOL PARAMETERS PRINT_PARAMS
WITHOUT SPOOL DYNPRO
VIA JOB name NUMBER number
AND RETURN.
Regards,
Naimesh Patel
11-20-2007 7:40 PM
The problem is I do not know the spool until runtime so I can't (well I can but it would be the last resort) do it like you posted. I do have the parameter primm marked for immediate printing, as I stated above.
Davis
11-20-2007 7:42 PM
Than I think you have to use your last option... to give the print at a time of scheduling the job.
Regards,
Naimesh Patel
11-20-2007 7:44 PM
If I give it the spool info when I schedule the job (in sm36) will it override the default (own data) for the user?
Davis
11-20-2007 7:47 PM
Yes..
Give a try.
It a same like when you run the report in Background using F9 from the selection screen. It asks you for the spool specific information. Whatever you put there it will take it further in job and generates the spool with those parameters.
Regards,
Naimesh Patel.
11-20-2007 7:49 PM
It didn't seem to behave that way yesterday but I will give it another shot. Thanks a lot of sticking by me and helping me out with this problem.
Davis
11-23-2007 2:18 AM
We couldn't find a way to go past the default printer so we are doing around it. There are SAP notes out there about it but it isn't that important; it can wait for the next patch.