Skip to Content
0
Dec 20, 2019 at 07:35 AM

How to set CL_GUI_HTML_VIEWER pdf file ?

2217 Views Last edit Dec 20, 2019 at 07:36 AM 3 rev

Hi,

I am trying to set pdf file in dialogbox with CL_GUI_HTML_VIEWER, but i trying to use LOAD DATA method with parameters in below code output result like image-1. When i try to type = 'TEXT' and subtype = 'HTML' output result like image-2. How can i display to data in dbox ?

"Global Data Definations
DATA: go_pdf_object         TYPE REF TO cl_gui_html_viewer,
      go_pdf_dialog         TYPE REF TO cl_gui_dialogbox_container,
      go_pdf_handler        TYPE REF TO gc_pdf_handler.

" in the subroutine get pdf file and convert to binary
DATA: gv_fm_name         TYPE rs38l_fnam,
      gs_fp_docparams    TYPE sfpdocparams,
      gs_fp_outputparams TYPE sfpoutputparams,
      gs_fp_outputforms  TYPE fpformoutput.

" binary itab definations
TYPES: BEGIN OF ty_itab,
       line TYPE x LENGTH 255,
      END OF ty_itab.
DATA: lt_itab TYPE STANDARD TABLE OF x255,"ty_itab,
      lv_url  TYPE char255,
      lv_size TYPE i VALUE 0.

gs_fp_outputparams-getpdf     = abap_true.

CALL FUNCTION 'FP_JOB_OPEN'
  CHANGING
    ie_outputparams = gs_fp_outputparams.

CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
  EXPORTING
    i_name     = gv_form_name
  IMPORTING
    e_funcname = gv_fm_name.

CALL FUNCTION gv_fm_name
  EXPORTING
    /1bcdwb/docparams  = gs_fp_docparams
    iv_sflight         = lt_sflight
    iv_scarr           = lt_scarr
    it_sbook           = lt_sbook
  IMPORTING
    /1bcdwb/formoutput = gs_fp_outputforms.
" xstring to binary
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer        = gs_fp_outputforms-xml
  IMPORTING
    output_length = lv_size
  TABLES
    binary_tab    = lt_itab.

CALL FUNCTION 'FP_JOB_CLOSE'.


" create dialogbox and set data 
CREATE OBJECT go_pdf_dialog
  EXPORTING
     width  = 900
     height = 450.

CREATE OBJECT go_pdf_handler.
SET HANDLER   go_pdf_handler->close_pdf_view FOR go_pdf_dialog.
CREATE OBJECT go_pdf_object
  EXPORTING
    parent = go_pdf_dialog.

CALL METHOD go_pdf_object->load_data
  EXPORTING
    type                   = 'APPLICATION'  " 'TEXT'
    subtype                = 'PDF'          " 'HTML'
    size                   = lv_size
  IMPORTING
    assigned_url           = lv_url
  CHANGING
    data_table             = lt_itab
  EXCEPTIONS
    dp_invalid_parameter   = 1
    dp_error_general       = 2
    cntl_error             = 3
    html_syntax_notcorrect = 4
    OTHERS                 = 5.

CALL METHOD go_pdf_object->show_data
  EXPORTING
    url      = lv_url
    in_place = abap_true.

CALL METHOD go_pdf_dialog->set_visible
  EXPORTING
    visible = abap_true.

Attachments

image-1.png (44.7 kB)
image-2.png (212.3 kB)