2015 Jul 14 4:18 AM
Hi Abapers,
I have a requirement where in i need to publish smartform in PDF format with SAP ITS , is there anyone who has worked on similar requirement, Any help?
Code I am using to show the PDF is below
CALL METHOD cl_hrge_document_services=>show_pdf
EXPORTING
pdf_data_tab = it_lines
pdf_data_size = l_pdf_len
pdf_viewer = a_pdf_viewer
mess_handler = mess_handler
display_in_place = open_inplace
IMPORTING
is_ok = is_ok.
when I execute the code i am getting 'The report did not produce any data for the selections.'
Any suggestions???
2015 Jul 15 7:43 PM
I also created a little test program from SF_EXAMPLE_01 demo programm to illustrate using html viewer to display pdf; maybe it will give you an idea what's wrong with your:
*----------------------------------------------------------------------*
* Report SF_EXAMPLE_01
*----------------------------------------------------------------------*
* Printing of documents using Smart Forms
*----------------------------------------------------------------------*
REPORT zsf_example_01.
DATA: carr_id TYPE sbook-carrid,
fm_name TYPE rs38l_fnam.
PARAMETER: p_custid TYPE scustom-id DEFAULT 1.
SELECT-OPTIONS: s_carrid FOR carr_id DEFAULT 'LH' TO 'LH'.
PARAMETER: p_form TYPE tdsfname DEFAULT 'SF_EXAMPLE_01' MODIF ID oon .
PARAMETERS: p_ingui TYPE c AS CHECKBOX DEFAULT space .
DATA: customer TYPE scustom,
bookings TYPE ty_bookings,
connections TYPE ty_connections.
DATA: gs_control_parameters TYPE ssfctrlop,
gs_output_options TYPE ssfcompop,
gs_job_output_info TYPE ssfcrescl,
g_len_int TYPE i,
go_html_viewer TYPE REF TO cl_gui_html_viewer,
g_url TYPE w3url,
gt_pdf_text TYPE tsftext.
* get data
SELECT SINGLE * FROM scustom INTO customer WHERE id = p_custid.
CHECK sy-subrc = 0.
SELECT * FROM sbook INTO TABLE bookings
WHERE customid = p_custid
AND carrid IN s_carrid
ORDER BY PRIMARY KEY.
SELECT * FROM spfli INTO TABLE connections
FOR ALL ENTRIES IN bookings
WHERE carrid = bookings-carrid
AND connid = bookings-connid
ORDER BY PRIMARY KEY.
START-OF-SELECTION .
* print data
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
gs_control_parameters-getotf = 'X'. "get as otf
gs_output_options-tdnoprint = 'X'. "no <print> button
* now call the generated function module
CALL FUNCTION fm_name
EXPORTING
control_parameters = gs_control_parameters
output_options = gs_output_options
customer = customer
bookings = bookings
connections = connections
IMPORTING
job_output_info = gs_job_output_info
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.
ELSE .
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = g_len_int
TABLES
otf = gs_job_output_info-otfdata[]
lines = gt_pdf_text[]
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 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.
ELSE.
* Force changing to the LIST Processor dynpro *******************
WRITE space .
*****************************************************************
* create HTML viewer object
CREATE OBJECT go_html_viewer
EXPORTING
parent = cl_gui_container=>default_screen.
* load PDF data (get URL)
go_html_viewer->load_data(
EXPORTING
type = 'text'
subtype = 'pdf'
IMPORTING
assigned_url = g_url
CHANGING
data_table = gt_pdf_text
EXCEPTIONS
dp_invalid_parameter = 1
dp_error_general = 2
cntl_error = 3
html_syntax_notcorrect = 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.
* show HTML object with PDF
go_html_viewer->show_url(
EXPORTING
url = g_url
in_place = p_ingui
EXCEPTIONS
cntl_error = 1
cnht_error_not_allowed = 2
cnht_error_parameter = 3
dp_error_general = 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.
* hide unnecessary GUI control
IF p_ingui IS INITIAL .
go_html_viewer->set_visible(
EXPORTING
visible = cl_gui_container=>visible_false
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3
).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF .
ENDIF.
ENDIF.
AT SELECTION-SCREEN OUTPUT .
LOOP AT SCREEN .
IF screen-group1 = 'OON' .
screen-input = 0 .
MODIFY SCREEN .
ENDIF .
ENDLOOP.
2015 Jul 14 9:16 AM
Hi,
If with "publish" you mean show the pdf (that's what cl_hrge_document_services=>show_pdf attempts to do) within "classic dynpro" so that displaying also works under SAP GUI for HTML, then you are on the right path.
You don't actually need that HR wrapper and can (and should, if there is no specific reason to use cl_hrge_document_services) call CL_GUI_HTML_VIEWER directly. Let me know if you need code sample for that.
cheers
Jānis
2015 Jul 14 9:38 AM
Thanks Janis for the reply but I am getting a screen with message I already mentioned in the above post I don't know what exactly I am missing I have checked the smart form and it is looks perfectly fine still it is not displaying the result.
2015 Jul 14 10:14 AM
Then I guess you have to:
1) look where the message is coming from... debugging an so forth;
2) try to describe the problem better (I assumed "when I execute the code" refers to the code you posted - the cl_hrge_document_services call in other words)
The point about simply trying to use in custom code some obscure SAP standard class, which is not mentioned in the public interface of SAP package in question, to accomplish, I assume, nothing more than displaying pdf, still stands - it creates unnecessary and avoidable dependency.
cheers
Jānis
2015 Jul 15 3:51 AM
Hi Janis,
Let me clarify, I have implemented the code and it does not give me any error, even the return code is_ok but i am not able to produce the PDF output instead it is starting a new window with message ' 'The report did not produce any data for the selections.''
Can you please share the code if you have and do check my code below
CREATE OBJECT PARENT
EXPORTING
CLSID = space
EXCEPTIONS
create_error = 1
others = 2.
if sy-subrc ne 0.
exit.
endif.
CREATE OBJECT A_PDF_VIEWER
EXPORTING
PARENT = PARENT
EXCEPTIONS
CNTL_ERROR = 1
CNTL_INSTALL_ERROR = 2
DP_INSTALL_ERROR = 3
DP_ERROR = 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 METHOD cl_hrge_document_services=>show_pdf
EXPORTING
pdf_data_tab = it_lines
pdf_data_size = l_pdf_len
pdf_viewer = a_pdf_viewer
mess_handler = mess_handler
display_in_place = open_inplace
IMPORTING
is_ok = is_ok.
2015 Jul 15 7:14 AM
Hi Aarif,
Please explain:
1) what are you trying to achieve (display pdf embedded in GUI or open a new browser window to display it)?
2) what kind of program does the functionality need to be integrated into (ABAP report, module pool with dynpro screens, something else like webdynpro application)?;
3) why do you believe you need to use cl_hrge_document_services to achieve it?
cheers
Jānis
2015 Jul 15 7:50 AM
Hi Janis,
thanks for reply.
It is module pool program which is integrated with SAP ITS so we write the logic in module pool and pass on the values to HTML( ITS ) to show the data dynamically.
example :
module pool screen->100->go to layout editor->click on utilities go to Internet service template->create-> takes you to HTML editor and this is where HTML logic is written.
Currently there is button on the HTML side so if we click on that it will call sapcript in the back end abap program and right now it is converting the sapcript into pdf and showing the data.
I am trying to replace sapscript with smartforms and convert it into pdf in a similar way as above.
please suggest.
2015 Jul 15 7:41 PM
Hi,
Still quite difficult to get a picture of what might be going on... bear with me please
So, I assume there is a (report) program that used to handle converting SAP Script OTF output to pdf and displaying pdf, and now you have to replace that Sapscript with Smartform in that program, is that right? Which is also why you have no idea why cl_hrge_document_services is used to show pdf?
If that's the setup, I'd suggest to check if all the exceptions involved in calling smartform are handled properly (whether cl_hrge_document_services does indeed receive the pdf data).
Another question: was the SAPscript pdf opened in new browser window? It would be helpful, if you could attach the whole program handling the form or at least the fragment from calling sapscript/smartform to displaying pdf.
cheers
Jānis
2015 Jul 15 7:43 PM
I also created a little test program from SF_EXAMPLE_01 demo programm to illustrate using html viewer to display pdf; maybe it will give you an idea what's wrong with your:
*----------------------------------------------------------------------*
* Report SF_EXAMPLE_01
*----------------------------------------------------------------------*
* Printing of documents using Smart Forms
*----------------------------------------------------------------------*
REPORT zsf_example_01.
DATA: carr_id TYPE sbook-carrid,
fm_name TYPE rs38l_fnam.
PARAMETER: p_custid TYPE scustom-id DEFAULT 1.
SELECT-OPTIONS: s_carrid FOR carr_id DEFAULT 'LH' TO 'LH'.
PARAMETER: p_form TYPE tdsfname DEFAULT 'SF_EXAMPLE_01' MODIF ID oon .
PARAMETERS: p_ingui TYPE c AS CHECKBOX DEFAULT space .
DATA: customer TYPE scustom,
bookings TYPE ty_bookings,
connections TYPE ty_connections.
DATA: gs_control_parameters TYPE ssfctrlop,
gs_output_options TYPE ssfcompop,
gs_job_output_info TYPE ssfcrescl,
g_len_int TYPE i,
go_html_viewer TYPE REF TO cl_gui_html_viewer,
g_url TYPE w3url,
gt_pdf_text TYPE tsftext.
* get data
SELECT SINGLE * FROM scustom INTO customer WHERE id = p_custid.
CHECK sy-subrc = 0.
SELECT * FROM sbook INTO TABLE bookings
WHERE customid = p_custid
AND carrid IN s_carrid
ORDER BY PRIMARY KEY.
SELECT * FROM spfli INTO TABLE connections
FOR ALL ENTRIES IN bookings
WHERE carrid = bookings-carrid
AND connid = bookings-connid
ORDER BY PRIMARY KEY.
START-OF-SELECTION .
* print data
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
gs_control_parameters-getotf = 'X'. "get as otf
gs_output_options-tdnoprint = 'X'. "no <print> button
* now call the generated function module
CALL FUNCTION fm_name
EXPORTING
control_parameters = gs_control_parameters
output_options = gs_output_options
customer = customer
bookings = bookings
connections = connections
IMPORTING
job_output_info = gs_job_output_info
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.
ELSE .
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = g_len_int
TABLES
otf = gs_job_output_info-otfdata[]
lines = gt_pdf_text[]
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 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.
ELSE.
* Force changing to the LIST Processor dynpro *******************
WRITE space .
*****************************************************************
* create HTML viewer object
CREATE OBJECT go_html_viewer
EXPORTING
parent = cl_gui_container=>default_screen.
* load PDF data (get URL)
go_html_viewer->load_data(
EXPORTING
type = 'text'
subtype = 'pdf'
IMPORTING
assigned_url = g_url
CHANGING
data_table = gt_pdf_text
EXCEPTIONS
dp_invalid_parameter = 1
dp_error_general = 2
cntl_error = 3
html_syntax_notcorrect = 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.
* show HTML object with PDF
go_html_viewer->show_url(
EXPORTING
url = g_url
in_place = p_ingui
EXCEPTIONS
cntl_error = 1
cnht_error_not_allowed = 2
cnht_error_parameter = 3
dp_error_general = 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.
* hide unnecessary GUI control
IF p_ingui IS INITIAL .
go_html_viewer->set_visible(
EXPORTING
visible = cl_gui_container=>visible_false
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3
).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF .
ENDIF.
ENDIF.
AT SELECTION-SCREEN OUTPUT .
LOOP AT SCREEN .
IF screen-group1 = 'OON' .
screen-input = 0 .
MODIFY SCREEN .
ENDIF .
ENDLOOP.
2015 Jul 16 3:09 AM
Hi Janis,
Thanks for your time and help your code really helped me to identify the missing point in my code, now my report does work fine when executing in back end however when the same program is being called from IE (ITS) it says " The website cannot display the page" HTTP 500 Internal server error.
p.s standalone program is working fine.
2015 Jul 16 11:04 AM
Hi,
I'm glad at least something is working already I have very, very little experience with "ITS GUI", but maybe you can try to give me an idea, how the report is getting called in this scenario (what actually happens when the "button on the HTML side" is pressed)? What is actually being called from "HTML side" and how..?
On our system we had to enable one Z transaction for use over the "integrated ITS", so it can be called from Siebel web UI and shown in SAP GUI for HTML. It involves something called ICF service... configured in transaction SICF:
Then, in our Z transaction /fww/vert1 there is some logic related to running under "ITS_GUI" (reacting to values supplied to screen fields via service url and processing the screen with them). The transaction then, depending on user actions, can display pdfs generated from smartforms using html viewer placed in custom control of the backend dynpro. The transaction always displays pdfs inplace (no separate browser windows opended) and looks something like this:
Do you have something similar, some kind of service to call backend? Or how does the backend programm actually get called from/via ITS, how do parameters, if any, get passed from "HTML side" to backend...?
Can you also post the actual ITS error screen please?
Edit in: pinging community experts for help
Also, I detest how SAP GUI for HTML presents the GUI Status of the transaction;Employ SAP GUI for HTML instead of an Internet service - Wiki - SCN Wiki actually has lots of useful information on how to configure GUI Status appearance...; this is what the "real deal" looks like in "normal" SAP GUI for Windows:
cheers
Jānis
Message was edited by: Jānis B
2015 Jul 17 2:08 AM
Hi Janis,
We have created a Z service where we have mapped our Z transaction and as of now we have sapscript in place which opens a pdf file when we click on a HTML designed button, so what i have been trying to do is to change sapscript and put smartforms in place, i don't want a new window it should just open a pdf file but so far i have not been able to do that.
On SICF side i have checked all the configuration everything seems ok, please see the screen shot below, i think that this is a GUI issue but dont know how to fix it.
Do you think using cl_gui_pdfviewer will do any good??
2015 Jul 18 12:35 PM
Hi,
CL_GUI_PDFVIEWER is marked as (Do not use!!) in my system so I'd stay away from it...
Regarding "internal error" is this set in your service?
If not, do not change the service... Instead please post the whole code of program handling Sapscript, before you made any changes.
I may have lead you astray with that sample program of mine, because I can't get it to run properly (display pdf) under ICF service/HTML GUI even with "GUI Link" enabled...
If your service for Sapscript handling is "GUI Link" enabled, check my next post for another test program - it runs on our system both under SAP GUI for Windows and SAP GUI for HTML (under ICF Service).
cheers
Jānis
2015 Jul 18 12:48 PM
So, here is the next test program (it will also require creating one dynpro with custom container in which html viewer has to run):
*----------------------------------------------------------------------*
* Report SF_EXAMPLE_01
*----------------------------------------------------------------------*
* Printing of documents using Smart Forms
*----------------------------------------------------------------------*
REPORT zsf_example_01.
TABLES: sscrfields .
INCLUDE icons.
DATA: carr_id TYPE sbook-carrid,
fm_name TYPE rs38l_fnam.
SELECTION-SCREEN FUNCTION KEY 1. "Will have a function code of 'FC01'
PARAMETER: p_custid TYPE scustom-id DEFAULT 1.
SELECT-OPTIONS: s_carrid FOR carr_id DEFAULT 'LH' TO 'LH'.
PARAMETER: p_form TYPE tdsfname DEFAULT 'SF_EXAMPLE_01' MODIF ID oon .
PARAMETERS: printpar LIKE eprintparams NO-DISPLAY.
DATA: customer TYPE scustom,
bookings TYPE ty_bookings,
connections TYPE ty_connections.
DATA: gs_sfcp TYPE ssfctrlop ,
gs_sfoo TYPE ssfcompop,
gs_job_output_info TYPE ssfcrescl,
g_pdf_len TYPE i,
g_pdf_xstring TYPE xstring ,
gc_html_viewer TYPE REF TO cl_gui_custom_container,
go_html_viewer TYPE REF TO cl_gui_html_viewer,
gt_pdf_raw TYPE STANDARD TABLE OF bin1024 ."raw255 ."or bin1024 or any type x.
* get data
SELECT SINGLE * FROM scustom INTO customer WHERE id = p_custid.
CHECK sy-subrc = 0.
SELECT * FROM sbook INTO TABLE bookings
WHERE customid = p_custid
AND carrid IN s_carrid
ORDER BY PRIMARY KEY.
SELECT * FROM spfli INTO TABLE connections
FOR ALL ENTRIES IN bookings
WHERE carrid = bookings-carrid
AND connid = bookings-connid
ORDER BY PRIMARY KEY.
INITIALIZATION .
sscrfields-functxt_01 = icon_print_with_parameters && 'Options' .
AT SELECTION-SCREEN .
* force input of print options
IF sy-ucomm EQ 'FC01' OR
( ( sy-ucomm EQ 'ONLI' OR sy-ucomm EQ 'PRIN' OR sy-ucomm EQ 'SJOB' ) AND
printpar-tddest IS INITIAL ) .
PERFORM get_printpar CHANGING printpar .
IF printpar-tddest IS INITIAL .
CLEAR sy-ucomm .
LEAVE TO SCREEN sy-dynnr .
ENDIF.
ENDIF .
START-OF-SELECTION .
* print data
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
MOVE-CORRESPONDING printpar TO gs_sfcp .
MOVE-CORRESPONDING printpar TO gs_sfoo .
gs_sfcp-no_dialog = 'X'.
IF sy-batch IS INITIAL . "get_otf in dialog
gs_sfcp-getotf = 'X' .
ENDIF .
* now call the generated function module
CALL FUNCTION fm_name
EXPORTING
control_parameters = gs_sfcp
output_options = gs_sfoo
customer = customer
bookings = bookings
connections = connections
IMPORTING
job_output_info = gs_job_output_info
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.
ELSE .
CHECK sy-batch IS INITIAL . "Only online
PERFORM get_pdf_as_rawtable
USING
gs_job_output_info-otfdata[]
CHANGING
gt_pdf_raw
g_pdf_len .
CALL SCREEN 100 .
ENDIF.
AT SELECTION-SCREEN OUTPUT .
LOOP AT SCREEN .
IF screen-group1 = 'OON' .
screen-input = 0 .
MODIFY SCREEN .
ENDIF .
ENDLOOP.
*&---------------------------------------------------------------------*
*& Module CREATE_VIEWER OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE create_viewer OUTPUT.
CHECK gc_html_viewer IS NOT BOUND .
SET PF-STATUS 'SIMPLE' .
PERFORM create_pdf_viewer USING gt_pdf_raw g_pdf_len.
ENDMODULE. " CREATE_VIEWER OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command INPUT.
CASE sy-ucomm .
WHEN 'EXIT' OR 'CANC' OR 'BACK' .
go_html_viewer->free( ) .
gc_html_viewer->free( ).
LEAVE PROGRAM .
WHEN OTHERS .
CLEAR sy-ucomm .
ENDCASE .
ENDMODULE. " USER_COMMAND INPUT
FORM get_printpar CHANGING cs_printpar TYPE eprintparams.
DATA: ls_printpar TYPE eprintparams .
ls_printpar = cs_printpar .
ls_printpar-device = 'PRINTER'.
CALL FUNCTION 'EFG_GET_PRINT_PARAMETERS'
EXPORTING
x_printparams = ls_printpar
x_no_preview = abap_true
x_no_archive = abap_true
x_no_last_doc = abap_true
x_only_printer = abap_true
IMPORTING
y_printparams = ls_printpar
EXCEPTIONS
cancelled = 1
input_error = 2
failed = 3
OTHERS = 4.
IF sy-subrc EQ 0 .
cs_printpar = ls_printpar .
ELSEIF sy-subrc EQ 1 OR
sy-subrc EQ 2 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSEIF sy-subrc GE 3 .
MESSAGE e898(e9) WITH
'sy-subrc' sy-subrc 'EFG_GET_PRINT_PARAMETERS' space.
ENDIF.
ENDFORM. " DEFINE_PRINT_PAR
FORM create_pdf_viewer
USING
it_pdf_raw TYPE STANDARD TABLE
i_pdf_len TYPE i .
DATA:
l_style TYPE i,
l_pdf_alignment TYPE i,
l_url TYPE w3url.
l_style = cl_gui_control=>ws_child +
cl_gui_control=>ws_visible.
* create custom container
CREATE OBJECT gc_html_viewer
EXPORTING
container_name = 'GC_HTML_VIEWER'
style = l_style
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* create HTML viewer object
CREATE OBJECT go_html_viewer
EXPORTING
parent = gc_html_viewer.
l_pdf_alignment = go_html_viewer->align_at_left +
go_html_viewer->align_at_right +
go_html_viewer->align_at_top +
go_html_viewer- >align_at_bottom.
go_html_viewer->set_alignment(
EXPORTING
alignment = l_pdf_alignment " Alignment
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3
).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* load PDF data (get URL)
go_html_viewer->load_data(
EXPORTING
type = 'application'
subtype = 'pdf'
size = i_pdf_len
IMPORTING
assigned_url = l_url
CHANGING
data_table = it_pdf_raw
EXCEPTIONS
dp_invalid_parameter = 1
dp_error_general = 2
cntl_error = 3
html_syntax_notcorrect = 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.
* show HTML object with PDF
go_html_viewer->show_url(
EXPORTING
url = l_url
in_place = 'X'
EXCEPTIONS
cntl_error = 1
cnht_error_not_allowed = 2
cnht_error_parameter = 3
dp_error_general = 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.
ENDFORM .
FORM get_pdf_as_rawtable
USING
it_otf TYPE tsfotf
CHANGING
ct_pdf_rawtable TYPE STANDARD TABLE
c_pdf_size TYPE i.
DATA: lt_dummylines TYPE tlinetab,
l_pdf_xstring TYPE xstring.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = c_pdf_size
bin_file = l_pdf_xstring
TABLES
otf = it_otf[]
lines = lt_dummylines[]
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 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.
ELSE .
PERFORM xstring_to_rawtable
USING l_pdf_xstring ct_pdf_rawtable .
ENDIF.
ENDFORM .
FORM xstring_to_rawtable
USING
i_xstring TYPE xstring
CHANGING
ct_rawtable TYPE STANDARD TABLE .
FIELD-SYMBOLS: <l_raw> TYPE x .
DATA: l_ref TYPE REF TO data .
DATA: l_size TYPE i, l_offset TYPE i, l_len TYPE i .
DATA: lo_table TYPE REF TO cl_abap_tabledescr .
DATA: lo_line TYPE REF TO cl_abap_datadescr .
l_size = xstrlen( i_xstring ) .
"create table work area
lo_table ?= cl_abap_tabledescr=>describe_by_data( ct_rawtable ) .
lo_line ?= lo_table->get_table_line_type( ).
CREATE DATA l_ref TYPE HANDLE lo_line .
ASSIGN l_ref->* TO <l_raw> . "should dump if wrong table type passed
"set data length
l_len = cl_abap_typedescr=>describe_by_data( <l_raw> )->length .
"limit data length
IF l_offset + l_len GT l_size .
l_len = l_size - l_offset .
ENDIF.
WHILE l_offset LT l_size.
<l_raw> = i_xstring+l_offset(l_len) .
APPEND <l_raw> TO ct_rawtable .
"offset to next data line
ADD l_len TO l_offset .
"limit length of last data line
IF l_offset + l_len GT l_size .
l_len = l_size - l_offset .
ENDIF.
ENDWHILE .
ENDFORM .
Create a dynpro 0100 for the program as follows:
- add custom container named GC_HTML_VIEWER
- add flow logic as follows:
PROCESS BEFORE OUTPUT.
MODULE create_viewer .
*
PROCESS AFTER INPUT.
MODULE user_command.
Finally, create a GUI status named SIMPLE, with nothing but EXIT, BACK and CANC functions enabled:
Activate everything and program should run. Then create a report transaction for it and test it under ICF services.
cheers
Jānis
2015 Sep 01 6:18 AM
Sorry mate for late reply was on long vacation, it did not work and now we have decided to continue with the existing design.