cancel
Showing results for 
Search instead for 
Did you mean: 

Change width of fields displayed on PDF from ALV

Former Member
0 Kudos

Hello,

I have a requirement in which i have to print an alv report in a pdf , now in the report say there are 11 fields of which 5 are hidden , so when i print the report in pdf , in the pdf output the entire width of the page is not occupied but only the width of the displayed fields

for eg. The 6 fields being displayed will cover only a part of the page..however i want the fields to occupy the entire page depending on the fields that are displayed .. plz advice how i can achieve this..

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Alok,

When you are going to Print, Please set the Format(increase Columns) for the Local Printer(Columns for the Report). Capture the SPOOL No and conert the Spool no as PDF.

Other way, you can download the Internal table (ALV Data) in PDF and can take the printout.

venkat_o
Active Contributor
0 Kudos

Hi, <li>After converting to PDF, try to use SX_TABLE_LINE_WIDTH_CHANGE function module to change the width of the PDF.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
       EXPORTING
         src_spoolid              = g_spool_no
         no_dialog                = ' '
       IMPORTING
         pdf_bytecount            = l_no_of_bytes
         pdf_spoolid              = l_pdf_spoolid
         btc_jobname              = l_jobname
         btc_jobcount             = l_jobcount
       TABLES
         pdf                      = i_pdf
       EXCEPTIONS
         err_no_abap_spooljob     = 1
         err_no_spooljob          = 2
         err_no_permission        = 3
         err_conv_not_possible    = 4
         err_bad_destdevice       = 5
         user_cancelled           = 6
         err_spoolerror           = 7
         err_temseerror           = 8
         err_btcjob_open_failed   = 9
         err_btcjob_submit_failed = 10
         err_btcjob_close_failed  = 11
         OTHERS                   = 12.

     CASE sy-subrc.
       WHEN 0.
       WHEN 1.
         MESSAGE s000(0k) WITH 'No ABAP Spool Job'.
         EXIT.
       WHEN 2.
         MESSAGE s000(0k) WITH 'Spool Number does not exist'.
         EXIT.
       WHEN 3.
         MESSAGE s000(0k) WITH 'No permission for spool'.
         EXIT.
       WHEN OTHERS.
         MESSAGE s000(0k)
            WITH 'Error in Function CONVERT_ABAPSPOOLJOB_2_PDF'.
         EXIT.
     ENDCASE.

     CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
       EXPORTING
         line_width_src              = 134
         line_width_dst              = 255
       TABLES
         content_in                  = i_pdf
         content_out                 = l_attachment
       EXCEPTIONS
         err_line_width_src_too_long = 1
         err_line_width_dst_too_long = 2
         err_conv_failed             = 3
         OTHERS                      = 4.
     IF sy-subrc NE 0.
       MESSAGE s000(0k) WITH 'Conversion Failed'.
       EXIT.
     ENDIF.
Thanks Venkat.O

andrs_sarcevic
Contributor
0 Kudos

If you are printing directly from the ALV, you can't. I believe that's the way it works.

You will need to create a custom form, Smartform or Adobe. But even in that case, you will not achieve dynamic width for the columns, at least in Smartform.

Cheers,