Skip to Content
-1

Not able to view the PDF data in SAP

Apr 18, 2017 at 07:14 PM

78

avatar image

Hi All,

I have generated an ALV in ABAP and have written the code for displaying the data in a PDF in SAP when the line item of the output is double clicked.But I am not able to see the data in the PDF .It throws an error File does not begin with '%PDF-'. i have attached the screen shot of the error too .pdf.jpg .Below is the code that i have used.Can you please help me in this.

CREATEOBJECT g_html_container
    EXPORTING
      container_name ='PDF'.

CREATEOBJECT g_html_control
    EXPORTING
      parent = g_html_container.


* Convert xstring to binary table to pass to the LOAD_DATA method

CALLFUNCTION'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer= gv_content
 TABLES
binary_tab = gt_data.

* Load the HTML

CALL METHOD g_html_control->load_data(
EXPORTING
*       size         =       gv_pdf_len
        type         =      'application'
      subtype              ='pdf'
IMPORTING
      assigned_url         = gv_url
    CHANGING
      data_table           = gt_data"lint_pdf_uc_line_tab[] EXCEPTIONS
      dp_invalid_parameter =1
      dp_error_general     =2
      cntl_error           =3
      OTHERS               =4).
* Show itCALLMETHOD g_html_control->show_url( url = gv_url
    in_place ='X').pdf.jpg
pdf.jpg (52.4 kB)
10 |10000 characters needed characters left characters exceeded

Please write the complete code for reference.

0

Please don't. Relevant code ONLY.

2

What happens if you try to open the file in the path shown in your jpeg on your PC?

What does gv_content contain?

0
*-----------------------------------------------------------------------
* Conversion of output format OTF into PDF format
*-----------------------------------------------------------------------
* now convert the final document (OTF format) into PDF format
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format                = 'PDF'
          IMPORTING
            bin_filesize          = gv_pdf_len
*           bin_file              = l_pdf_xstring       " binary file
          TABLES
            otf                   = ls_output_data-otfdata
            lines                 = gt_lines
          EXCEPTIONS
            err_max_linewidth     = 1
            err_format            = 2
            err_conv_not_possible = 3
            err_bad_otf           = 4
            OTHERS                = 5.
        IF sy-subrc <> 0.
          lv_error = 'Cannot output data to PDF format'.
        ENDIF.



* convert pdf to xstring string 
LOOP AT gt_lines INTO gs_line.
ASSIGN ls_line TO <fs_x> CASTING. CONCATENATE gv_content <fs_x> INTO gv_content IN BYTE MODE.
ENDLOOP.

GV content contains the above data .the data is not displayed on the PDF.it is empty

0
Shashikanth Rayappagari
What do you mean "it" is empty? What is "It"? Please show the byte value of GV_CONTENT (by debug).
1
* Please Login or Register to Answer, Follow or Comment.

0 Answers