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

alv + pdf

Former Member
0 Likes
945

Hi,

I have an alv list.

the requirement is to add a new button in the alv tool bar to convert the alv list in pdf.

How to convert the alv list in pdf.?

thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
860

Instead of re-printing the table in a non-alv format, the ALV report can be sent to the spool. The following code will perform this task.

data: l_params type pri_params,

l_valid type string,

l_print type slis_print_alv.

  • Set print immediate off so the spool does not get printed

call function 'GET_PRINT_PARAMETERS'

exporting

immediately = ' '

no_dialog = 'X'

importing

out_parameters = l_params

valid = l_valid.

if sy-subrc = 0.

endif.

l_print-print = 'X'.

l_print-prnt_info = ' '.

l_print-no_print_selinfos = 'X'.

l_print-no_print_listinfos = 'X'.

l_print-no_coverpage = 'X'.

l_print-reserve_lines = 1.

l_print-print_ctrl-pri_params = l_params.

  • Set the sy-batch flag to prevent the print options pop-up from being displayed

sy-batch = 'X'.

  • Unfortunately the GRID_DISPLAY will still display the print options pop-up,

  • but the LIST_DISPLAY works.

  • Pass exactly the same parameters to the LIST_DISPLAY as you did to the

  • GRID_DISPLAY when you first called the function.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_buffer_active = ' '

i_callback_program = g_repid

i_callback_pf_status_set = g_status_set

i_callback_user_command = g_user_command

is_layout = gs_layout

is_print = l_print

it_fieldcat = gt_fieldcatalog

it_sort = gt_sort

i_save = g_save

is_variant = gs_variant

it_events = gt_events[]

tables

t_outtab = tbl_itab

exceptions

program_error = 1

others = 2.

if sy-subrc = 0.

endif.

data : l_spool_nr like tsp01-rqident.

  • Now Call the standard SAP program to convert the spool to PDF

  • and to download the PDF to a PC file.

  • Select the recently created spool

select max( rqident ) into l_spool_nr from tsp01

where rqclient = sy-mandt

and rqowner = sy-uname.

wait up to 3 seconds.

submit rstxpdft4

exporting list to memory

with spoolno = l_spool_nr

with p_file = 'c:\temp\dp11.pdf'

and return.

Regards

5 REPLIES 5
Read only

Former Member
0 Likes
860

hi ,

to add the Push button.

first add the statemnet in the start-of -selection.

SET PF-STATUS 'STATUS'.

and double click on Status ..

it will take you to se41 andd the button "save to PDF"

and activate...

next come to source code

at user-command...

when sy-ucomm.

case "savetopDF"

now call the Fm


*Work Area for Print Parameters & Work Area for Converted PDF file
 Data : wa_pri_params TYPE pri_params,
        wa_pdf TYPE tline.
 
  if t_ouputdata[] is not initial.
*    WAIT UP TO 1 SECONDS.
    CONCATENATE 'E'
                 w_tabix
                 sy-datum+4(4)
                 sy-uzeit INTO
                 wa_pri_params-plist.
  ENDIF.

  NEW-PAGE PRINT ON NO DIALOG PARAMETERS wa_pri_params.     "creating spool request
  WRITE : / text-s32.
  ULINE.
  LOOP AT t_ouputdata INTO wa_ouputdata.
    WRITE : /  wa_ouputdata.
  ENDLOOP.
  WRITE : / text-s33.
  NEW-PAGE PRINT OFF.                                        "closing spool request
 
 
* To fetch the spool number from TSP01 table
  SELECT rqident
         FROM tsp01
         INTO w_rqident
         UP TO 1 ROWS
         WHERE rq2name = wa_pri_params-plist.
  ENDSELECT.

* Function Module to Convert Spool to PDF file
  CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
    EXPORTING
      src_spoolid     = w_rqident
      no_dialog       = 'X'
      dst_device      = 'LP01'
      pdf_destination = 'X'
    TABLES
      pdf             = t_pdf.


* Now t_pdf table contains the PDF data...
" now call the function module in GUI_DOWNLOAD to download the PDF file to desktop... 

prabhudas

Read only

Former Member
0 Likes
860

Hi,

Thank you very much.

i will code it like you have described.

regards

Read only

0 Likes
860

This message was moderated.

Read only

Former Member
0 Likes
860

HI experts.

I have coded neerly as described.

i can get a pdf converted file with all details like in ALV grid (it's ok).

But how to integrate the header (TOP of page of alv) and footer (End of list of alv) in the PDF file.

i have few lines in the header and few lines in the footer.

Regards

Read only

Former Member
0 Likes
861

Instead of re-printing the table in a non-alv format, the ALV report can be sent to the spool. The following code will perform this task.

data: l_params type pri_params,

l_valid type string,

l_print type slis_print_alv.

  • Set print immediate off so the spool does not get printed

call function 'GET_PRINT_PARAMETERS'

exporting

immediately = ' '

no_dialog = 'X'

importing

out_parameters = l_params

valid = l_valid.

if sy-subrc = 0.

endif.

l_print-print = 'X'.

l_print-prnt_info = ' '.

l_print-no_print_selinfos = 'X'.

l_print-no_print_listinfos = 'X'.

l_print-no_coverpage = 'X'.

l_print-reserve_lines = 1.

l_print-print_ctrl-pri_params = l_params.

  • Set the sy-batch flag to prevent the print options pop-up from being displayed

sy-batch = 'X'.

  • Unfortunately the GRID_DISPLAY will still display the print options pop-up,

  • but the LIST_DISPLAY works.

  • Pass exactly the same parameters to the LIST_DISPLAY as you did to the

  • GRID_DISPLAY when you first called the function.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_buffer_active = ' '

i_callback_program = g_repid

i_callback_pf_status_set = g_status_set

i_callback_user_command = g_user_command

is_layout = gs_layout

is_print = l_print

it_fieldcat = gt_fieldcatalog

it_sort = gt_sort

i_save = g_save

is_variant = gs_variant

it_events = gt_events[]

tables

t_outtab = tbl_itab

exceptions

program_error = 1

others = 2.

if sy-subrc = 0.

endif.

data : l_spool_nr like tsp01-rqident.

  • Now Call the standard SAP program to convert the spool to PDF

  • and to download the PDF to a PC file.

  • Select the recently created spool

select max( rqident ) into l_spool_nr from tsp01

where rqclient = sy-mandt

and rqowner = sy-uname.

wait up to 3 seconds.

submit rstxpdft4

exporting list to memory

with spoolno = l_spool_nr

with p_file = 'c:\temp\dp11.pdf'

and return.

Regards