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

Dowloading Internal table into pdf formate

Former Member
0 Likes
741

Hi,

I want to know how to conert an internal table into pdf file is there any fm avaliable for this .

regards,

zafar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
708

try this sample code--

tables:tsp01.

TYPE-POOLS : vrm.

DATA : vrm_val TYPE vrm_values,
       wa_vrm  LIKE LINE OF vrm_val,
       g_name  LIKE wa_vrm-text.

data: w_pdf like table of tline.

data:
  print_parameters like pri_params,
  valid_flag(1) type c,
  w_spono type tsp01-rqident.

  CLEAR wa_vrm.
  wa_vrm-key  = 'M'.
  wa_vrm-text = 'Mango'.
  APPEND wa_vrm TO vrm_val.

  CLEAR wa_vrm.
  wa_vrm-key  = 'P'.
  wa_vrm-text = 'Pineapple'.
  APPEND wa_vrm TO vrm_val.

  CLEAR wa_vrm.
  wa_vrm-key  = 'A'.
  wa_vrm-text = 'apple'.
  APPEND wa_vrm TO vrm_val.

call function 'GET_PRINT_PARAMETERS'
 exporting
     no_dialog          = 'X'
     user               = sy-uname
 importing
   out_parameters       = print_parameters
   valid                = valid_flag
 exceptions
   invalid_print_params = 2
   others               = 4.

if valid_flag = 'X' and sy-subrc = 0.

  new-page print on parameters print_parameters
                      no dialog.

LOOP AT vrm_val into wa_vrm.             " your internal table
  WRITE :wa_vrm-key.
ENDLOOP.

LOOP AT vrm_val into wa_vrm.
  WRITE : wa_vrm-text.

ENDLOOP.


 new-page print off.
endif.

w_spono = sy-spono.

call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
  exporting
    src_spoolid                    = w_spono

 tables
   pdf                            = w_pdf[]
         .
if sy-subrc  EQ 0.

endif.


call function 'GUI_DOWNLOAD'
  exporting
    filename                        = 'C:\w_pdf.pdf'
   filetype                        = 'BIN'
  tables
    data_tab                        = w_pdf[]
         .
if sy-subrc EQ 0.
endif.

Sumit

6 REPLIES 6
Read only

former_member206377
Active Contributor
0 Likes
708

Hi Zafar,

You can follow the following steps :

1) Create a Spool number

2) Then use FM 'CONVERT_ABAPSPOOLJOB_2_PDF' to convert to PDF.

Read only

Former Member
0 Likes
708

Hi,

You can use submit report to generate spool number.

SUBMIT zricef_test USING SELECTION-SET v_variant

WITH p_online = 'X'

TO SAP-SPOOL

SPOOL PARAMETERS %_print

WITHOUT SPOOL DYNPRO

AND RETURN.

Then use FM 'RSPO_RETURN_ABAP_SPOOLJOB'.

And then to convert this internal table into PDF use FM 'CONVERT_ABAPSPOOLJOB_2_PDF'.

Thansk,

Archana

Read only

Former Member
0 Likes
709

try this sample code--

tables:tsp01.

TYPE-POOLS : vrm.

DATA : vrm_val TYPE vrm_values,
       wa_vrm  LIKE LINE OF vrm_val,
       g_name  LIKE wa_vrm-text.

data: w_pdf like table of tline.

data:
  print_parameters like pri_params,
  valid_flag(1) type c,
  w_spono type tsp01-rqident.

  CLEAR wa_vrm.
  wa_vrm-key  = 'M'.
  wa_vrm-text = 'Mango'.
  APPEND wa_vrm TO vrm_val.

  CLEAR wa_vrm.
  wa_vrm-key  = 'P'.
  wa_vrm-text = 'Pineapple'.
  APPEND wa_vrm TO vrm_val.

  CLEAR wa_vrm.
  wa_vrm-key  = 'A'.
  wa_vrm-text = 'apple'.
  APPEND wa_vrm TO vrm_val.

call function 'GET_PRINT_PARAMETERS'
 exporting
     no_dialog          = 'X'
     user               = sy-uname
 importing
   out_parameters       = print_parameters
   valid                = valid_flag
 exceptions
   invalid_print_params = 2
   others               = 4.

if valid_flag = 'X' and sy-subrc = 0.

  new-page print on parameters print_parameters
                      no dialog.

LOOP AT vrm_val into wa_vrm.             " your internal table
  WRITE :wa_vrm-key.
ENDLOOP.

LOOP AT vrm_val into wa_vrm.
  WRITE : wa_vrm-text.

ENDLOOP.


 new-page print off.
endif.

w_spono = sy-spono.

call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
  exporting
    src_spoolid                    = w_spono

 tables
   pdf                            = w_pdf[]
         .
if sy-subrc  EQ 0.

endif.


call function 'GUI_DOWNLOAD'
  exporting
    filename                        = 'C:\w_pdf.pdf'
   filetype                        = 'BIN'
  tables
    data_tab                        = w_pdf[]
         .
if sy-subrc EQ 0.
endif.

Sumit

Read only

0 Likes
708

Hi,

Thanks for your reply.

As the code which u have given it required spool no. but I have a normal zreport and output table of that report i want to convert in pdf so how to do it w/o sool number.

regards,

zafar

Read only

0 Likes
708

Hi,

I guess below wiki will solve your problem

http://wiki.sdn.sap.com/wiki/display/Snippets/SaveReportOutputtoaPDFFile

Pooja

Read only

Former Member
0 Likes
708

Hi,

Please follow te below mentioned wiki to solve your problem:

http://wiki.sdn.sap.com/wiki/display/ABAP/PDFDownlaodByCreatingSpool+Request

Hope this might help you.

Pooja