cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Sandra_Rossi
Active Contributor
0 Kudos

You forgot to pass the size of the PDF in bytes, to the LOAD_DATA method (the extra null bytes sometimes make the Adobe viewer fail)

Former Member
0 Kudos

Hello Sandra,

Thanks for your reply, but eventhen it fails to load the pdf. Is ADS required to be installed for this?

Can I just pass the pdf_fsize imported from CONVERT_OTF which is of type i.

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 METHOD G_HTML_CONTROL->LOAD_DATA(

EXPORTING

TYPE = 'application' "'text' " 'application'

SUBTYPE = 'pdf' "'html' "'pdf'

size = PDF_FSIZE

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 ).

Thanks,

Jaya.

Former Member
0 Kudos

Hello Sandra,

I had to go through this page to overcome the sapgui from crashing:

http://wiki.sdn.sap.com/wiki/display/PLM/Adobe%209%20-%20SAPGUI%20crash

So now the pdf is displayed without the sapgui crashing.

But the pdf is displayed as a new window instead of displaying in the custom container.

my aim to do this is, to store the pdf data in the form of xstring in a ztable instead of downloading the pdf in a folder for storage purpose. and then this can be called/read in another tcode to display the pdf when required.

Please give your view on this is it OK to store the pdf in xstring format or download it to the folder.

Thanks,

Jaya.

Sandra_Rossi
Active Contributor
0 Kudos

Hi Jaya,

well done about the bug!

About the display in a separate window, I can't say why it happens. Did you make sure the RSDEMO_HTML_VIEWER program works? Did you check SAP notes?

About storing the binary in a database table, you can use a field of type RAWSTRING. I don't understand your question about the folder.

BR

Sandra

Sandra_Rossi
Active Contributor
0 Kudos

I've just made a test. If you applied the solution of changing the Adobe Reader option, then it's normal that the PDF is displayed separately.

So, I think you should check the config of your softwares, install latest patches, contact support, etc.

Former Member
0 Kudos

Hello Sandar,

Yes you are right if we uncheck the option it is obvisous that the pdf is displayed in separate window.

So, finally it is the SAPGUI and the Adobe version mismatch. Either we upgrade the patch level or the second option was that instead of using Adobe 9 we installed Adobe 8.

And now it is showing up the pdf in custom container.

Even after finding the correct code 1 day went in digging out this solution for the bug.....

Thanks a lot Sandar.

Thanks,

Jaya.

Former Member
0 Kudos

I have the same problem as you. Could you please tell me which option you used in Adobe Reader 8? Do we have to restart the computer for the options take into effect? I can not find the option you mentioned

Thank you very much