2009 Apr 30 6:37 AM
Hello Experts,
I have developed one report,it has two variants , for which two spools generated and 2 mail float automatically for two spools after that.
My requirement :Is two spools can be combined in one file ,so that only one mail float.
Aastha
2009 Apr 30 6:48 AM
Helo,
I also had a similar requirement and after analysis it was found out that you cannot combine two spools into one. Only thing can be done is read the joblog to get a spool number and then combine 2 spools in an internal table to mail to the user as one.
Hope this workaround works for u.
Regards,
Mansi.
2009 Apr 30 7:27 AM
Hello Mansi,
U suggest is to read the joblog to get a spool number .
Plz can u elaborately explain me how to process.
Aastha
2009 Apr 30 7:37 AM
Hello,
You can read the spool numbers as logic given below:
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = g_jcount
job_read_jobname = g_jbname
job_read_opcode = l_opcode
TABLES
job_read_steplist = l_t_steps
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
OTHERS = 4.
IF sy-subrc = 0.
CLEAR g_t_spool.
LOOP AT l_t_steps ASSIGNING <fs_steps> WHERE NOT ( listident IS INITIAL ).
g_wa_spool-listident = <fs_steps>-listident.
APPEND g_wa_spool TO g_t_spool.
ENDLOOP.
ENDIF.
After reading, just to display the spools use the following logic:
LOOP AT g_t_spool INTO g_wa_spool.
g_spool1 = g_wa_spool-listident.
CALL FUNCTION 'COM_SE_SPOOL_DISPLAY'
EXPORTING
iv_spool_no = g_spool1.
ENDLOOP.
But since you dont want to display, but mail to the user, you will have to build logic around the spool file, taking it into some internal table.
Regards,
Mansi.
2009 Apr 30 7:50 AM
Hello Mansi,
Thanks 4 ur immediate reply.
My is ALV report,can u tell where to assigned this code which u sugggest.
Aastha
2009 Apr 30 7:52 AM
You will have to submit ALV program via Job i.e in background using JOB_SUBMIT and at end my code will be included after JOB_CLOSE.
2009 Apr 30 9:46 AM
Hi,
perhaps there is another less exhaustive way. SAP spooling offers some options. If the user and naming of the spool is equal you may choose output options, in detail "New Spool Request" = No and "Do not append Print Jobs" = No. You can do this by abap coding as well. Have a look into ABAP Dcumentation. Search SUBMIT TO SAP-SPOOL. There you will find some explenations and there is the reference to function "GET_PRINT_PARAMETERS".
If this is no way for you, nevertheless I would not take much effort to combine SAP Spools within SAP. I would prefer to do the merge outside from SAP. Have a look at Report RSTXPDFT4. This Reports converts spool to pdf. After that you can use the free pdftk (PDF-Toolkit) to merge your files by command line utility. You can execute this with ABAP system command on os level.
Example (Windows):
DATA:
parcom(250),
BEGIN OF tabl OCCURS 0,
line(200),
END OF tabl,
str(250).
parcom = 'copy c:\temp\dummy.txt c:\temp\dummy2.txt'.
CALL 'SYSTEM' ID 'COMMAND' FIELD parcom
ID 'TAB' FIELD tabl-sys.
IF sy-subrc IS INITIAL.
RAISE dummytxt_not_copied.
ENDIF.
Regards
Walter Habich