Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

in R/3 display smartform as pdf in a custom container

Hello,

I want to display smartform as pdf in a custom contianer . I was able to find all the right code from sdn.

but my problem is that when executed my sap gui is closed without any error.

I am unable to understand what is going wrong.

CALL METHOD G_HTML_CONTROL->SHOW_URL( URL = LV_URL

IN_PLACE = 'X' ). does not show the pdf.

Can any one help me to find out if we need to do some setting for MIME type application/pdf. Because I tried to display a bar chart in the custom container of MIME type text/html , and this is working fine.

Is any setting missing in our R/3 because of which the code is not getting executed.

below code is the exact copy from a post in sdn:

report ztest_pdf.

DATA: LT_PDF TYPE TABLE OF TLINE,
      LS_PDF LIKE LINE OF LT_PDF,
      LV_URL TYPE CHAR255,
      PDF_FSIZE TYPE  I,
      LV_CONTENT  TYPE XSTRING,
      LT_DATA TYPE STANDARD TABLE OF X255.

DATA : L_JOB_OUTPUT_INFO TYPE SSFCRESCL.
DATA : LS_CONTROL_PARAM  TYPE SSFCTRLOP.

DATA : G_HTML_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
       G_HTML_CONTROL   TYPE REF TO CL_GUI_HTML_VIEWER.
*      pdf_control type ref to cl_gui_pdfviewer.



DATA : P_VBELN TYPE  VBELN_VL.

DATA : i_html TYPE w3htmltabtype.
",       g_url  TYPE w3url

FIELD-SYMBOLS <FS_X> TYPE X.

INITIALIZATION.
LS_CONTROL_PARAM-GETOTF = 'X'.
LS_CONTROL_PARAM-NO_DIALOG = 'X'.
START-OF-SELECTION.

  CALL FUNCTION '/1BCDWB/SF00000298'
 EXPORTING
*    ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
     CONTROL_PARAMETERS         = LS_CONTROL_PARAM
*     P_VBELN                    = P_VBELN
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
 IMPORTING
*      DOCUMENT_OUTPUT_INFO  = L_DOCUMENT_OUTPUT_INFO
       JOB_OUTPUT_INFO       = L_JOB_OUTPUT_INFO
*      JOB_OUTPUT_OPTIONS    = L_JOB_ OUTPUT_OPTIONS
 EXCEPTIONS
    FORMATTING_ERROR           = 1
    INTERNAL_ERROR             = 2
    SEND_ERROR                 = 3
    USER_CANCELED              = 4
    OTHERS                     = 5
           .
  IF SY-SUBRC <>  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

data pdfxstring type xstring.

  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      FORMAT                = 'PDF'
    IMPORTING
      BIN_FILESIZE          = PDF_FSIZE
      bin_file              = pdfxstring
    TABLES
      OTF                   = L_JOB_OUTPUT_INFO-OTFDATA
      LINES                 = LT_PDF
    EXCEPTIONS
      ERR_MAX_LINEWIDTH     = 1
      ERR_FORMAT            = 2
      ERR_CONV_NOT_POSSIBLE = 3
      OTHERS                = 4.

  CALL SCREEN 100.

module STATUS_0100 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.


  CREATE OBJECT G_HTML_CONTAINER
    EXPORTING
      CONTAINER_NAME = 'PDF'.

 CREATE OBJECT G_HTML_CONTROL
    EXPORTING
      PARENT = G_HTML_CONTAINER.
* Convert xstring to binary table to pass to the LOAD_DATA method
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      BUFFER     = pdfxstring"LV_CONTENT
    TABLES
      BINARY_TAB = LT_DATA.

* PERFORM bar_chart .

* Load the HTML
  CALL METHOD G_HTML_CONTROL->LOAD_DATA(
     EXPORTING
       TYPE         = 'application' "'text' " 'application'
       SUBTYPE      = 'pdf' "'html'  "'pdf'
     IMPORTING
       ASSIGNED_URL         = lv_URL
     CHANGING
       DATA_TABLE           =  LT_DATA "i_html "LT_DATA
     EXCEPTIONS
       DP_INVALID_PARAMETER = 1
       DP_ERROR_GENERAL     = 2
       CNTL_ERROR           = 3
       OTHERS               = 4 ).

* Show it
  CALL METHOD G_HTML_CONTROL->SHOW_URL( URL = LV_URL
    IN_PLACE = 'X' ).

Thanks,

Jaya.

Edited by: kishan P on Jun 9, 2011 1:40 PM

Former Member
Not what you were looking for? View more on this topic or Ask a question