Application Development 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: 

problem with pdf output of an internal table

Former Member
0 Kudos
75

Hi,

My requirement is to get the internal table out put to be displayed through pdf in a table form.

Internal table :

Matter Matter Description -


> Table Head

0011 Standard -


> Table contents

0022 Clerk

I want this to be displayed through pdf in same format.

I searched sdn and tried this way.

Please help if am wrong anywhere.

Thanks,

Sandeep

Edited by: SandeepReddy on Jun 9, 2010 9:13 AM

1 REPLY 1

Former Member
0 Kudos
43

types:begin of ty_mara,
matnr type matnr,
end of ty_mara.
data i_mara type standard table of ty_mara.
data itab like line of i_mara.

DATA: v_handle LIKE sy-tabix,
v_spool_id type RSPOID,
v_rc TYPE c,
v_errmessage(100) TYPE c,
gd_spool_nr type RSPOID,
gd_bytecount type i,
v_text(70) TYPE c.
types ty_pdf type tline.
data it_pdf_output type standard table of ty_pdf.
data i_pdf like line of it_pdf_output.

gd_spool_nr = sy-spono.

SELECT matnr FROM mara INTO TABLE i_mara.

CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'
EXPORTING
dest = 'LP01'
LIFETIME = '8'
IMPORTING
handle = v_handle
spoolid = gd_spool_nr
rc = v_rc
errmessage = v_errmessage.

LOOP AT i_mara into itab.
v_text = itab-matnr.

CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'
EXPORTING
handle = v_handle
text = v_text
IMPORTING
rc = v_rc
errmessage = v_errmessage
EXCEPTIONS
handle_not_valid = 1
OTHERS = 2.

ENDLOOP.

CALL FUNCTION 'RSPO_CLOSE_SPOOLREQUEST'
EXPORTING
handle = v_handle
IMPORTING
rc = v_rc
errmessage = v_errmessage
EXCEPTIONS
handle_not_valid = 1
OTHERS = 2.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.

LOOP AT it_pdf_output INTO i_pdf .
TRANSLATE i_pdf USING ' ~'.
CONCATENATE OUTPUT i_pdf INTO OUTPUT IN CHARACTER MODE.
ENDLOOP.
TRANSLATE OUTPUT USING '~ ' .
  app_type   = 'APPLICATION/PDF;'.
    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text     = output
      mimetype = 'APPLICATION/PDF;'
    IMPORTING
      buffer   = l_xstring.

CONCATENATE cl_abap_char_utilities=>byte_order_mark_little
              l_xstring
         INTO l_xstring IN BYTE MODE.
*
  CONCATENATE 'attachment; filename=NIM2_matter_Summary_'
              sy-uzeit
              '.pdf'
         INTO l_content.

  CALL METHOD cl_bsp_utility=>download
    EXPORTING
      object_s            = l_xstring
      content_type        = app_type
      content_disposition = l_content
      response            = _m_response
      navigation          = _m_navigation
.
 

Edited by: SandeepReddy on Jun 9, 2010 10:30 AM