RDI Preview
RDI Preview
Date: 2009-06-17
Contents
SAPScript RDI Preview Solution for StreamServe.......................................................................................2
Disclaimer................................................................................................................................................2
Use Case.................................................................................................................................................3
Technical Requirements.........................................................................................................................11
Customer Developments........................................................................................................................11
Disclaimer
The solution has been tested on SAP R/3 4.7 (WAS 6.2) connected to StreamServe Persuasion SP4. The
specific scenario tested has been preview of a Billing document from inside SAP. However the solution
should work for NetWeaver based SAP systems and for other SAPScripts than Billing form
(RVINVOICE01). The only Prerequisite in StreamServe is that HTTP in connector and HTTP response
out connectors can be used, together with the RDI Agent (delivered in E-docs of StreamServe Connect
for SAP) and an StreamIn event for handling the RDI data in StreamServe.
The given solution is provided from R&D as an implementation example solution and any solution
implemented at customer site is owned and maintained by Professional Services or Customer.
Overview
The goal of this solution is to provide a way to preview documents without a client installation (only SAP
GUI and Acrobat Reader is needed on the clients). And additionally, to ensure delivery of the preview
document in all distributed environments.
This method is implemented by integrating the solution with the existing SAP infrastructure, using the
SAP session to transport the preview document to the front end. On the front end the SAP HTML
Framework (which the SAPGUI and the ABAP runtime provide) is used to display the actual document.
The HTML Framework normally requires Acrobat Reader to view PDF files, so that must also be available
on the client PC.
This allows the StreamServe preview to be embedded into a standard SAP user experience. It also
minimizes deployment costs, since IT does not need to install and maintain anything on the user’s
computers.
Modifications
(optional):
-LSTXCRDI
Use Case
The basic use case is that StreamServe handles output of a selected document type from SAP, say
Billing documents. An RDI-enabled (see below) SAPScript and corresponding print program exists in
SAP. And the customer wants to use SAP internal preview functionality to view the document before
releasing it for actual output. The RDI SAPScript for Billing use case is given below. Step 4-5 are
executed by the actual SAP user, whereas steps 1-3 are one-time pre-requisite activities set up by an
administrator.
1. Standard Billing SAPScript RVINVOICE01 is changed and RDI output is enabled. Alternativery a
customer copy ZRVINVOICE01 is created and changed. Transaction se71:
Select Attributes -> Miscellaneous from the Menu.
Transaction NACE:
Select the Row for Print Output and press the “Details” icon.
Enter the name of the StreamServe RDI Preview program “ZRSTRS_RDI2PDF_PREVIEW” and
Form routine “ENTRY” in the fields for Processing step 2. This tells SAP to trigger the
StreamServe preview after the first SAP print program has created the RDI spool request.
Technical Requirements
The preview is implemented between SAP and StreamServe using HTTP protocol. Thus the HTTP port
used in StreamServe must be accessible from SAP. Also note that the current solution doesn’t implement
any encryption or authentication, however such extensions should be possible if required.
Note that SAP standard spool processing will create an RDI spool request even if preview is selected (this
solution relies on that fact for reading the RDI data). This means that even if it is a preview request the
spool file will be sent to de designated device (which will be StreamServe in this case). Thus the
StreamServe project must ensure to drop preview requests (identified via $r3_tdpreview = ‘X’) that
doesn’t arrive on the HTTP preview connector.
Customer Developments
In order for the StreamServe Preview to work from within SAP the following is needed:
b. Table ZSTRS_OPTS containing settings for StreamServe hostname and port (contents
must be changed manually admin)
2. Add entries to table ZSTRS_OPTS pointing out StreamServe hostname/ip and the HTTP port
number set for preview. See “Settings table for StreamServe host name and port number” below.
3. Enable RDI preview: Either as “Enable Preview for all RDI Forms” or as “Enable RDI Preview for
a specific output type”. See the respective sections below.
Modification of LSTXCRDI
*&---------------------------------------------------------------------*
*& Form RDI_CLOSE_FORM (called from CLOSE_FORM)
*&---------------------------------------------------------------------*
form rdi_close_form using result like itcpp
rdi_result like rdiresult.
* rdi
if flag_rdi_active = true.
* write rdi data, if any and close
if rdi_status-doc_started = true.
rdi_status-doc_started = false.
perform rdi_transfer_data.
endif.
perform rdi_close_raw_dataset.
* reset rdi status, flag rdi
rdi_status-is_open = false.
rdi_status-spool_started = false.
flag_rdi_active = false.
* set spool id in result
result-tdspoolid = itcpp-tdspoolid.
* return idoc control if rdi mode is idoc
if rdi_mode = c_rdi_idoc_mode.
rdi_result = rdi_idoc_control.
endif.
endif.
*{ INSERT R30K900002 1
* StreamServe print preview enhancement. Enables Preview of all RDI forms.
IF itcpp-tdpreview = 'X'.
CALL FUNCTION 'ZSTRS_RDI2PDF_PREVIEW'
EXPORTING
RDI_SPOOLREQ = itcpp-TDSPOOLID.
ENDIF.
*} INSERT
endform.
Modification of LSTXCRDI
*&---------------------------------------------------------------------*
*& Form RDI_CLOSE_FORM (called from CLOSE_FORM)
*&---------------------------------------------------------------------*
form rdi_close_form using result like itcpp
rdi_result like rdiresult.
* rdi
if flag_rdi_active = true.
* write rdi data, if any and close
if rdi_status-doc_started = true.
rdi_status-doc_started = false.
perform rdi_transfer_data.
endif.
perform rdi_close_raw_dataset.
* reset rdi status, flag rdi
rdi_status-is_open = false.
rdi_status-spool_started = false.
flag_rdi_active = false.
* set spool id in result
result-tdspoolid = itcpp-tdspoolid.
* return idoc control if rdi mode is idoc
if rdi_mode = c_rdi_idoc_mode.
rdi_result = rdi_idoc_control.
endif.
endif.
*{ INSERT R30K900002 1
* StreamServe print preview enhancement.
EXPORT itcpp-tdspoolid itcpp-tdpreview TO MEMORY ID
'Z_STRS_PREVIEW'.
*} INSERT
endform.
To create the host and port number configuration entries in this table in SAP use transaction se16, select
table ZSTRS_OPTS and press the “empty sheet / create enries” button.
FUNCTION zstrs_rdi2pdf_preview
FUNCTION zstrs_rdi2pdf_preview.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(RDI_SPOOLREQ) TYPE ITCPP-TDSPOOLID OPTIONAL
*" REFERENCE(STRS_PREVIEW_HOST) TYPE STRING OPTIONAL
*" REFERENCE(STRS_PREVIEW_PORT) TYPE STRING OPTIONAL
*" EXCEPTIONS
*" ERROR_HTTP_CALL
*" ERROR_CONFIG
*" ERROR_SPOOL
*" NO_RDI_PRV_DATA
*"----------------------------------------------------------------------
TABLES: itcpp.
*
* Only valid in Dialog mode.
*
IF sy-batch = 'X'.
RETURN.
ENDIF.
*
* First step, read RDI Spool via determined Spool Request ID
* the request ID is determined primarily from input parameter,
* secondarily from Memory ID Z_STRS_PREVIEW and lastly the
* final option is to select last Spool Request for current user-
*
ENDIF.
ENDIF.
strs_host = strs_preview_host.
strs_port = strs_preview_port.
IF strs_host IS INITIAL.
SELECT SINGLE ssvalue FROM zstrs_opts
INTO strs_host WHERE ssoption = c_prv_rdi_host_host.
IF sy-dbcnt = 0.
l_resp_message = 'Missing entry STR_RDI_PRV_HOST in table ZSTRS_OPTS'.
MESSAGE l_resp_message TYPE 'E' RAISING error_config DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
IF strs_port IS INITIAL.
SELECT SINGLE ssvalue FROM zstrs_opts
INTO strs_port WHERE ssoption = c_prv_rdi_host_port.
IF sy-dbcnt = 0.
l_resp_message = 'Missing entry STR_RDI_PRV_PORT in table ZSTRS_OPTS'.
MESSAGE l_resp_message TYPE 'E' RAISING error_config DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
*
* Second step set up HTTP connection to StreamServe
*
*
* * Set header values
*
CALL METHOD lc_http_cl->request->set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.
*
* * Call HTTP post
*
CALL METHOD lc_http_cl->send
EXPORTING
timeout = 10000
EXCEPTIONS
http_communication_failure = 1
http_invalid_state =2
http_processing_failed =3
http_invalid_timeout =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 RAISING error_http_call.
ENDIF.
*
* * Get HTTP Response
*
CALL METHOD lc_http_cl->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state =2
http_processing_failed =3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 RAISING error_http_call.
ENDIF.
IF l_resp_code NE '200'.
CONCATENATE 'Received HTTP response code, for preview: ' l_resp_code INTO l_resp_message.
MESSAGE l_resp_message TYPE 'E' RAISING error_http_call DISPLAY LIKE 'E'.
ENDIF.
*
* * Here we have the PDF in response. Begin logic to display PDF
*
*
* Call screen and flow logic
*
g_pdf_result = l_pdf_result.
CALL SCREEN 100.
ENDFUNCTION.
Report ZRSTRS_RDI2PDF_PREVIEW
*&---------------------------------------------------------------------*
*& Report ZRSTRS_RDI2PDF_PREVIEW *
*& *
*&---------------------------------------------------------------------*
*& *
*& Description: *
*& *
*& Execute RDI Preview. To be executed after SAPScript Print Program. *
*& Uses memory ID Z_STRS_PREVIEW to retrieve spoolid and preview flag *
*&, if not found the actual latest RDI spool for current user is read *
*& and checked for preview flag. *
*& *
*& Author: *
*& *
*& StreamServe, Christian Josefsson *
*&---------------------------------------------------------------------*
REPORT zrstrs_rdi2pdf_preview.
1. HTTP input connector, listening on the IP and port as set up in SAP table ZSTRS_OPTS above.
The Input connector will receive the RDI file for preview from SAP.
2. HTTP response connector, which returns a PDF file which constitutes the preview, back in an
synchronous HTTP response replying to the originating HTTP request from SAP.
Sample preview runtime: In a real-life scenario the null_out connector would be replaced by an actual
destination to receive the “live” (non-preview) document. Also ensure that any job having
$r3_tdpreview = ‘X’ must be treated as a preview (and if that job doesn’t arrive via the HTTP
connector used for preview the request should be skipped).
1. Unpack strs_edocs_preview.zip. The archive contains two directories named: cofiles and data.
The contents of these directories should be copied to the corresponding directory under the
transport directory (named “trans”) at the relevant SAP target system. E.g on a SAP windows
host named “winhost” the files would be copied to \\winhost\sapmnt\trans\cofiles and
\\winhost\sapmnt\trans\data.
2. Start the transport management system in the SAP system to import to (typically the relevant
SAP development system).
Transaction STMS:
Press “Import overview” icon (truck).
Double click on the relevant import queue.
Manually select the request (the request name is similar to the filenames copied in step 1 ) for the
import queue via menu “Extras -> Other requests -> Add” and then select the request.
Mark the request and select “Import”. If required test the import first via “Perform Test import”.
3. Done! The package ZSTRSPRV with configuration table ZSTRS_OPTS and function modules
ZSTRS_XSF2PDF_PREVIEW, ZSTRS_RDI2PDF_PREVIEW and report
ZRSTRS_RDI2PDF_PREVIEW is now imported in the target system.
Note! If the package ZSTRSPRV needs further transport from the target system, the package
ZSTRSPRV can be changed, using transaction se80 (to change transport layer) and then to write
the whole package contents to a new workbench request.