0% found this document useful (0 votes)
28 views25 pages

RDI Preview

Uploaded by

ogulcanzor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views25 pages

RDI Preview

Uploaded by

ogulcanzor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Author: StreamServe R&D

Date: 2009-06-17

Contents
SAPScript RDI Preview Solution for StreamServe.......................................................................................2

Disclaimer................................................................................................................................................2

Use Case.................................................................................................................................................3

Technical Requirements.........................................................................................................................11

Customer Developments........................................................................................................................11

Enable Preview for all RDI Forms.......................................................................................................12

Settings table for StreamServe host name and port number.............................................................13

Source code for ZSTRS_RDI2PDF_PREVIEW..................................................................................15

Source code for report ZRSTRS_RDI2PDF_PREVIEW.....................................................................19

StreamServe Preview Project................................................................................................................20

Importing the ABAP transport.................................................................................................................22


SAPScript RDI Preview Solution for StreamServe
This document describes how a preview of an RDI-enabled SAPScript form can be previewed inside SAP
(sapgui) using StreamServe.

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.

The Document process flow is outlined below.


RDI / XSF (http post)
Preview request (rfc)
SAP NetWeaver
ABAP Application
SAPGU Server SteamServer
I Client Preview response (rfc) PDF (http response)
Customizing: -
Output Type
-StreamServe
Options
User executes
ABAP: - Function
SAPScript document
Modules -Report -
preview in
Config table
transaction.

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.

Enable RDI Output Mode.


2. Assign delivered Preview program: ZRSTRS_RDI2PDF_PREVIEW as an additional print
program for output type in conditions for output control in SAP.

Transaction NACE:

Select relevant application


Select relevant Output type and doube-click “Processing routines”.

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.

3. Optional. Add modification to Include LSTXCRDI. Alternative:

a. Export the Spool request ID to memory with ID Z_STRS_PREVIEW. As part of standard


SAP RDI output process. This enables the StreamServe Preview program defined in the
step above to exactly know the Spool request. If this is not provided the StreamServe
program will use the last RDI spool request for current user as the preview request.
b. Alternatively to get a generic approach for all Output Types (in fact for all RDI Enabled
SAPScripts). The StreamServe RDI Preview Function Module
ZSTRS_RDI2PDF_PREVIEW can be called directly from the the SAP Standard RDI
output process. In this case step 2 above must be skipped (since otherwise the preview
would be executed twice).
4. A SAP user maintains a Billing document and wants to preview the document before releasing it
for final output.
Transaction VF03 (Display Billing Document):
Billing document -> Printer from menu:
5. The StreamServe document preview is executed and displayed.

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:

1. Import of attached ABAP transport contained in “strs_edocs_preview_YYmmdd.zip” . This


contains:
a. Function modules ZSTRS_XSF2PDF_PREVIEW, ZSTRS_RDI2PDF_PREVIEW which
implements preview logic for XSF and RDI respectively with accompanying screens.

b. Table ZSTRS_OPTS containing settings for StreamServe hostname and port (contents
must be changed manually admin)

c. RDI Preview Print program ZRSTRS_RDI2PDF_PREVIEW which can be executed after


a standard print program to add Preview functionality for a specific Output Type.

d. All these objects are contained in development package ZSTRSPRV.

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.

Enable Preview for all RDI Forms


The code below contains a modification that can be added to SAP Report (include) LSTXCRDI. In form
RDI_CLOSE_FORM. The added code modification is marked in Red below. The modification enbles RDI
Preview for any RDI form and thus the RDI Preview Print (ZRSTRS_RDI2PDF_PREVIEW) program need
not be assigned to the Output Type as described earlier.

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.

Enable RDI Preview for a specific output type


If only a smaller set of RDI enabled forms needs the preview functionality then the StreamServe preview
Report ZRSTRS_RDI2PDF_PREVIEW can be added as an additional procesing step for Print output for
the given outpyut type (step 2 in Use Case above). To ensure that the correct Spool Request ID is read
by the Preview function ZSTRS_RDI2PDF_PREVIEW then the below modification can be added to export
the spool request ID and Preview flag to memory. The benefit will be a small performance enhancement
(since the preview doesn’t need to search for the latest RDI Spool request for the current user) and also if
the actual output is done in Dialog mode (the preview will never be executede if run in Batch mode) the
preview function might need to read the Spool request and parse it to determine that it is not a preview
request. Which is not necessary if the below modification is added. If this is still OK, then the below
modification is not necessary.

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.

Settings table for StreamServe host name and port number


Function module ZSTRS_RDI2PDF_PREVIEW reads the StreamServe host name and port from the table
below. These values must be manually saved in the table by an administrator as part of initial
configuration of this scenario.
The host name of StreamServe should be saved as a record with STRSOPTION =
‘STR_RDI_PRV_HOST’ and the port number should be saved as a record with STRSOPTION =
‘STR_RDI_PRV_PORT’.

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.

Press save to save host/ip option.


Change the STRSOPTION key to STRS_RDI_PRV_PORT and press save again to save the port number
configuration option.

Source code for ZSTRS_RDI2PDF_PREVIEW


The below function module is delivered in separate ABAP transport, but for reference the code is provided
below. Note that apart from the below source code, defined ABAP screens and gui element for previewing
is also needed (also present in transport).

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.

TYPES: BEGIN OF data_set_line,


data_line(1000),
END OF data_set_line.

DATA: l_spoolreq LIKE tsp01-rqident,


l_rdi_header TYPE STXRDIH,
l_spooltime LIKE tsp01-rqcretime,
l_tmp_spoolreq TYPE string,
l_tmp_sycode TYPE string,
lt_buffer TYPE STANDARD TABLE OF data_set_line,
ls_buffer LIKE LINE OF lt_buffer,
lc_http_cl TYPE REF TO if_http_client,
l_pdf_result TYPE xstring,
l_resp_code TYPE string,
l_resp_message TYPE string,
l_rdi_data TYPE string,
l_tmp_len TYPE i,
strs_host TYPE string,
strs_port TYPE string.

*
* 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-
*

IF rdi_spoolreq IS NOT INITIAL.


l_spoolreq = rdi_spoolreq.
ELSE.
* Read from memory ID
IMPORT itcpp-tdspoolid itcpp-tdpreview
FROM MEMORY ID 'Z_STRS_PREVIEW'.
l_spoolreq = itcpp-tdspoolid.
FREE MEMORY ID 'Z_STRS_PREVIEW'.
IF l_spoolreq IS INITIAL.
SELECT rqident rqcretime INTO (l_spoolreq, l_spooltime) FROM tsp01
WHERE rqowner = sy-uname AND rqdoctype = 'RDI'
ORDER BY rqcretime DESCENDING.
EXIT.
ENDSELECT.
ELSE.
IF itcpp-tdpreview <> 'X'.
* * No preview, just return
RETURN.
ENDIF.

ENDIF.
ENDIF.

CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB_RAW'


EXPORTING
rqident = l_spoolreq
* FIRST_LINE =1
* LAST_LINE =
TABLES
buffer = lt_buffer
EXCEPTIONS
no_such_job =1
not_abap_list =2
job_contains_no_data =3
selection_empty =4
no_permission =5
can_not_access =6
read_error =7
OTHERS =8
.
IF sy-subrc <> 0.
l_tmp_spoolreq = l_spoolreq.
l_tmp_sycode = sy-subrc.
CONCATENATE 'Unable to acces spool job: ' l_tmp_spoolreq ', return code = ' l_tmp_sycode
INTO l_resp_message SEPARATED BY space.
MESSAGE l_resp_message TYPE 'E' RAISING error_spool DISPLAY LIKE 'E'.
ENDIF.

* Create RDI data string to send to StreamServe


CLEAR l_rdi_data.
LOOP AT lt_buffer INTO ls_buffer.
SHIFT ls_buffer LEFT DELETING LEADING SPACE.
IF sy-tabix = 1.
* Check if valid RDI and Preview mode
IF NOT ( ls_buffer+0(1) = 'H' AND ls_buffer+185(1) = 'X' ).
* Uncomment below if this is an Error, just return by default
RETURN.
* l_tmp_spoolreq = l_spoolreq.
* CONCATENATE 'No valid RDI Preview data found in context of spool request:' l_tmp_spoolreq
* INTO l_resp_message SEPARATED BY space.
* MESSAGE l_resp_message TYPE 'E' RAISING NO_RDI_PRV_DATA DISPLAY LIKE 'E'.
ENDIF.
ENDIF.

CONCATENATE l_rdi_data ls_buffer-data_line INTO l_rdi_data


SEPARATED BY cl_abap_char_utilities=>newline.
ENDLOOP.

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
*

CALL METHOD cl_http_client=>create


EXPORTING
host = strs_host
service = strs_port
* proxy_host = '192.168.4.103'
* proxy_service = '8888'
* Scheme = 1 is HTTP, Scheme = 2 is HTTPS
scheme = '1'
* ssl_id = ssl_id
IMPORTING
client = lc_http_cl
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error =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.

*
* * Set header values
*
CALL METHOD lc_http_cl->request->set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.

CALL METHOD lc_http_cl->request->set_header_field


EXPORTING
name = 'Content-Type'
value = 'text/plain'.

CALL METHOD lc_http_cl->request->set_cdata


EXPORTING
data = l_rdi_data.

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

CALL METHOD lc_http_cl->response->get_data


RECEIVING
data = l_pdf_result.

CALL METHOD lc_http_cl->response->get_header_field


EXPORTING
name = '~status_code'
RECEIVING
value = l_resp_code.

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.

Source code for report ZRSTRS_RDI2PDF_PREVIEW


The Report below can be added to enable RDI Preview for a specific Output Type as described in step 2
of Use Case earlier. The Report is included in the ABAP transport but the source code is also provided
for reference below:

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.

FORM entry USING return_code us_screen.


IF us_screen = 'X' AND sy-batch <> 'X'.
CALL FUNCTION 'ZSTRS_RDI2PDF_PREVIEW'.
IF sy-subrc = 0.
return_code = 0.
ENDIF.
ELSE.
return_code = 0.
ENDIF.
ENDFORM. "entry

StreamServe Preview Project


For the RDI SAPScript preview solution to work, a deployed StreamServe project must exists which
provide the following:

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

HTTP input connector settings (example):


Note: HTTP input connector HTTP Access settings (URI must be “/”).

HTTP Response connector:


Importing the ABAP transport
The function pool containing the preview functionality is delivered as an ABAP transport, contained in file
strs_edocs_preview_YYmmdd.zip. The following steps are necessary to import the transport. Note that
the handling of transports typically is handled by a SAP BASIS team at customer site.

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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy