This Program helps you to view any output in PDF viewer as shown below. It’s very simple to understand. Just convert OFT data into PDF as below.
*&---------------------------------------------------------------------*
*& Report ZSAP_PDF_VIEWER_DEMO_2
*&
*&---------------------------------------------------------------------*
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_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_HTML_CONTROL TYPE REF TO CL_GUI_HTML_VIEWER.
DATA : P_VBELN TYPE VBELN_VL.
FIELD-SYMBOLS
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
ENDLOOP.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
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 = 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.
ENDMODULE. " USER_COMMAND_0100 INPUT
No comments:
Post a Comment