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

Convert ALV into PDF

Former Member
0 Likes
6,489

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?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
5,998

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?

10 REPLIES 10
Read only

himanshu_gupta13
Product and Topic Expert
Product and Topic Expert
0 Likes
5,998

This message was moderated.

Read only

Former Member
0 Likes
5,998

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

Read only

Former Member
0 Likes
5,998

This message was moderated.

Read only

Former Member
0 Likes
5,999

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

Read only

Former Member
0 Likes
5,998

This message was moderated.

Read only

Former Member
0 Likes
5,998

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.

Read only

0 Likes
5,998

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

Read only

0 Likes
5,998

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.

Read only

0 Likes
5,998

first you can convert data into OTF  then PDF.

Read only

0 Likes
5,998

Hi,

You can given the path  during the execution of the program ..it is declared as parameter(P_File).