2014 Mar 28 5:00 AM
I need to create an export button in the ALV toolbar to download the ALV content into a PDF file when clicking the button.Can you help me with any suggestions?
2014 Mar 28 5:45 AM
Hi Sravani,
You can copy any standard GUI from SE41 and add a custom button 'DOWNLOAD' (as shown in image) in the Application toolbar sub menu. You can give any name you want.
And then handle this button click in the PAI of the program/screen and write the logic for converting from ALV to PDF inside that block.
For conversion from ALV to PDF you can refer to this link and few others in SCN itself.
http://scn.sap.com/thread/1407223
Hope it helps!
Regards,
Barkha
I need to create an export button in the ALV toolbar to download the ALV content into a PDF file when clicking the button.Can you help me with any suggestions?
2014 Mar 28 5:11 AM
2014 Mar 28 5:23 AM
Hi Sravani,
You can also use the standard FM 'CONVERT_ABAPSPOOLJOB_2_PDF' to convert the spool generated from alv output to pdf.
Refer the below link for the same -
http://www.erpgenie.com/sap/abap/code/abap51.htm
Regards,
Rachna
2014 Mar 28 5:37 AM
2014 Mar 28 5:45 AM
Hi Sravani,
You can copy any standard GUI from SE41 and add a custom button 'DOWNLOAD' (as shown in image) in the Application toolbar sub menu. You can give any name you want.
And then handle this button click in the PAI of the program/screen and write the logic for converting from ALV to PDF inside that block.
For conversion from ALV to PDF you can refer to this link and few others in SCN itself.
http://scn.sap.com/thread/1407223
Hope it helps!
Regards,
Barkha
2014 Mar 28 8:25 AM
2014 Mar 28 8:45 AM
hi,
EPORT ZII_RKP_TEST.
DATA:flight TYPE sflight OCCURS 0,
pdf LIKE tline OCCURS 0.
DATA:g_spool TYPE tsp01-rqident,
g_program TYPE sy-repid VALUE sy-repid.
TYPE-POOLS:slis.
DATA:w_print TYPE slis_print_alv,
w_print_ctrl TYPE alv_s_pctl.
PARAMETERS: p_file TYPE string.
INITIALIZATION.
p_file = 'd:\flight.pdf'.
START-OF-SELECTION.
SELECT * FROM sflight INTO TABLE flight UP TO 10 ROWS. This will fetch the values of flight
w_print-print = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_program
i_structure_name = 'SFLIGHT'
is_print = w_print
TABLES
t_outtab = flight.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
g_spool = sy-spono.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = g_spool
TABLES
pdf = pdf.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = p_file
filetype = 'BIN'
TABLES
data_tab = pdf.
ENDIF.
ENDIF.
2014 Mar 28 9:06 AM
Hello Kiran,
Yes it worked.
@Sravani: You can try with the Kiran's comments. Based on your requirement you can either place a file in presentation server or application server.
If you want to send the pdf file created to the mail id refer to the demo program BCS_EXAMPLE_7 where it is explained for XLS document and you can refer it and do it for PDF attachment.
Regards,
TP
2014 Apr 08 7:39 AM
Hi Kiran,
In the code you gave, th PDF will be saved in the file that we specify before in the code. But I need to get the path to save it in runtime. Could you pls help.
2014 Apr 08 7:45 AM
2014 Apr 08 12:29 PM
Hi,
You can given the path during the execution of the program ..it is declared as parameter(P_File).
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |