Skip to end of metadata
Go to start of metadata

Using the below program we can read any OTF data in to Adobe Reader directly.To simplify further we can create a Function group with a function module as importing parameter to take OTF data and create a screen 100 for Function group and add below mention code from conversion of the OTF data to till end, there after we can directly call this newly created Z function module to pass OTF data in to adobe reader directly.

 

 

 

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT  ZSAP_PDF_VIEWER.
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_CONTROL   TYPE REF TO CL_GUI_HTML_VIEWER.
DATA : LO_DOCKING_CONTAINER TYPE REF TO CL_GUI_DOCKING_CONTAINER.
DATA : P_VBELN TYPE  VBELN_VL.
FIELD-SYMBOLS <FS_X> TYPE X.
INITIALIZATION.
LS_CONTROL_PARAM-GETOTF = 'X'.
LS_CONTROL_PARAM-NO_DIALOG = 'X'.
START-OF-SELECTION.
  CALL FUNCTION '/1BCDWB/SF00000034'
 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.
  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      FORMAT                = 'PDF'
    IMPORTING
      BIN_FILESIZE          = PDF_FSIZE
    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.
* convert pdf to xstring string
  LOOP AT LT_PDF INTO LS_PDF.
    ASSIGN LS_PDF TO <FS_X> CASTING.
    CONCATENATE LV_CONTENT <FS_X> INTO LV_CONTENT IN BYTE MODE.
  ENDLOOP.
  CALL SCREEN 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
  SET PF-STATUS '100'.
*  SET TITLEBAR 'xxx'.
CREATE OBJECT LO_DOCKING_CONTAINER
  EXPORTING
    REPID     = SY-REPID
    DYNNR     = '100'"SY-DYNNR
    SIDE      = LO_DOCKING_CONTAINER->DOCK_AT_LEFT
    EXTENSION = 1200.
CREATE OBJECT G_HTML_CONTROL
  EXPORTING
    PARENT = LO_DOCKING_CONTAINER.
* Convert xstring to binary table to pass to the LOAD_DATA method
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      BUFFER     = LV_CONTENT
    TABLES
      BINARY_TAB = LT_DATA.
* Load the HTML
  CALL METHOD G_HTML_CONTROL->LOAD_DATA(
     EXPORTING
       TYPE         = 'application'
       SUBTYPE      = 'pdf'
     IMPORTING
       ASSIGNED_URL         = LV_URL
     CHANGING
       DATA_TABLE           = 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' ).
ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
  DATA ok_code LIKE sy-ucomm.
  MOVE sy-ucomm TO ok_code.
  CASE ok_code.
    WHEN 'BACK' OR 'EXIT'.
      CALL METHOD LO_DOCKING_CONTAINER->free.
*      CALL METHOD g_html_control->free.
      LEAVE TO SCREEN 0.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT  

 

 

 

1 Comment

  1. this code is very help full

    Thanks [sai kumar

    wiki/display/%7Eycdirgk]