11-08-2007 6:57 PM
Hi All,
I have a requirement where the ALV report output has customers and details related to it.For example My report output has three customers(with a check box against it) and each customer has 5 line items.The user will select first and the last customer and press a push button provided.Once he clicks this push button, I should get the customers which are selected by the users and the line items related to this customers.I am able to capture all this.Now the real problem here is that I have to create a pdf document for each customer along with line items and send it as an email.In effect, in this scenario I have to create two pdf documents since the user has selected two customers on the output screen and send it to the email of that particular customer.Is there any FM available to create spool in the background for each of these customers(along with line items data) and make use of this spool number to generate a pdf document using CONVERT_ABAPSPOOLJOB_2_PDF.Once I get this I can send the email.
Please help!
Thanks in advance
Sandeep
11-10-2007 12:29 PM
11-12-2007 9:59 AM
Hello Sandeep,
I was just thinking about the below solution, though, it might be a round about.
1) You need to have a spool for the customer detail lines (for the customer which is selected in the initial output). For this it would be better to create a new report which will actually display the output of customer details in the layout you need.
2) In your original report which is interactive, when you select and customer and ask for detail lines, you have to call the above report such that, control is taken to new report which will create a spool with the output you required and will come back to the original report
3) For achieving the same, SUBMIT statement can be used with the additional commands which would be something like below:
SUBMIT ZTEST USING SELECTION-SET 'TEST1'
TO SAP-SPOOL
WITHOUT SPOOL DYNPRO
AND RETURN.
"ZTEST" would be your new program which will display the customer detail lines.
"TEST1" would be your variant for the selection screen, if required.
4) If you need individual spool for each customer, the above statement has to be used for each customer. To fetch the spool number generated, the table 'TSP01' can be used.
Please check the same and hope this works.
Thanks and Regards,
Pavan Kumar Kolli
11-12-2007 12:35 PM
The following steps shows how to download the output data in to PDF.
1.Provide Spool Parameters using following function module 'GET_PRINT_PARAMETERS'.
--This function module will provide the print parameters for creating the output in the spool; the required parameters are passed to the OUT_PARAMETERS import parameter.
2.Submit the report to generate the output in the spool.
SUBMIT (sy-repid) TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS wa_mstr_print_parms
WITH SELECTION-TABLE i_int_tab
AND RETURN.
--Submit the report to generate the output in the spool as i_int_table is an internal table with structure RSPARAMS. As variant allows you to set the names and contents of the parameter and selection options dynamically at runtime, we need to use the function module RS_REFRESH_FROM_SELECTOPTIONS to read the contents of the parameters and selection options of the current program into an internal table i_int_table with the structure RSPARAMS and pass that internal table in above manner.
3.To Find the spool number from the table TSP01
Data: l_rq2name LIKE tsp01-rq2name.
*Concatenate the report and User name as per the value available in the table
TSP01.
CONCATENATE f_repid+0(9)
f_uname+0(3)
INTO l_rq2name.
*Fetch the most recent spool from the TSP01 table
SELECT * FROM tsp01 WHERE rq2name = l_rq2name
ORDER BY rqcretime DESCENDING.
l_rqident = tsp01-rqident.
EXIT.
ENDSELECT.
4.Convert Spool to PDF using the FM : CONVERT_ABAPSPOOLJOB_2_PDF.
5.Download to local file by using the FM : DOWNLOAD
This function module returns an internal table data_tab contains the PDF formatted output.
Using above points your can create the output in the PDF from there you can send the email.
Hope your reqirement can met using the above five points.
Reward points please
Thanks,
Ravi Kanth