on 11-09-2004 1:01 PM
So what am I missing?
<b>BSP Programming: Handling Of Non-HTML Documents</b>
/people/mark.finnern/blog/2003/09/23/bsp-programming-handling-of-non-html-documents
<b>Generate file .doc or .pdf as from a text</b>
<b>Page Layout</b>
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2002" >
<htmlb:page>
<htmlb:form method = "post"
encodingType = "multipart/form-data" >
<htmlb:radioButtonGroup id="display_type" >
<htmlb:radioButton id = "inline"
text = "Display Inline" />
<htmlb:radioButton id = "html"
text = "Display Inside HTML Page" />
<htmlb:radioButton id = "window"
text = "Display In New Window" />
<htmlb:radioButton id = "convert"
text = "Convert to PDF Inside HTML Page" />
<htmlb:radioButton id = "convertnew"
text = "Convert to PDF In New Window" />
</htmlb:radioButtonGroup>
<htmlb:fileUpload id = "myUpload"
onUpload = "HandleUpload"
upload_text = "Display"
size = "90" />
<hr>
<br>Name = <%= file_name%>
<br>MIME-Type = <%= file_mime_type%>
<br>Length = <%= file_length%>
<%
IF ( display_type = 'html' OR display_type = 'convert' ) AND display_url IS NOT INITIAL.
%>
<iframe src="<%= display_url%>" width="100%" height="500px">
</iframe>
<%
ENDIF.
IF ( display_type = 'window' OR display_type = 'convertnew' ) AND display_url IS NOT INITIAL.
%>
<script language="Javascript">
window.open("<%= display_url%>").focus();
</script>
<%
ENDIF.
%>
</htmlb:form>
</htmlb:page>
</htmlb:content>
<b>OnInputProcessing</b>
* event handler for checking and processing user input and
* for defining navigation
DATA: radioButtonGroup TYPE REF TO CL_HTMLB_RADIOBUTTONGROUP.
DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD.
DATA: cached_response TYPE REF TO if_http_response.
DATA: response TYPE REF TO if_http_response.
DATA: guid TYPE guid_32.
fileUpload ?= CL_HTMLB_MANAGER=>GET_DATA(
request = request
id = 'myUpload'
name = 'fileUpload' ).
file_name = fileUpload->file_name.
file_mime_type = fileUpload->file_content_type.
file_length = fileUpload->file_length.
file_content = fileUpload->file_content.
radioButtonGroup ?= CL_HTMLB_MANAGER=>GET_DATA(
request = request
id = 'display_type'
name = 'radioButtonGroup' ).
display_type = radioButtonGroup->selection.
IF display_type = 'inline' AND XSTRLEN( file_content ) > 0.
response = runtime->server->response.
response->set_data( file_content ).
response->set_header_field( name = if_http_header_fields=>content_type
value = file_mime_type ).
" response->set_header_field( name = if_http_header_fields=>content_length
" value = file_length ).
response->delete_header_field( name = if_http_header_fields=>cache_control ).
response->delete_header_field( name = if_http_header_fields=>expires ).
response->delete_header_field( name = if_http_header_fields=>pragma ).
* signal that response is complete
navigation->response_complete( ).
RETURN.
ENDIF.
IF ( display_type = 'html' OR display_type = 'window' ) AND XSTRLEN( file_content ) > 0.
CREATE OBJECT cached_response TYPE CL_HTTP_RESPONSE EXPORTING add_c_msg = 1.
cached_response->set_data( file_content ).
cached_response->set_header_field( name = if_http_header_fields=>content_type
value = file_mime_type ).
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 180 ).
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = guid.
CONCATENATE runtime->application_url '/' guid INTO display_url.
cl_http_server=>server_cache_upload( url = display_url
response = cached_response ).
RETURN.
ENDIF.
IF ( display_type = 'convert' OR display_type = 'convertnew' ) AND XSTRLEN( file_content ) > 0.
CREATE OBJECT cached_response TYPE CL_HTTP_RESPONSE EXPORTING add_c_msg = 1.
cached_response->set_data( file_content ).
cached_response->set_header_field( name = if_http_header_fields=>content_type
value = 'application/pdf' ).
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 180 ).
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = guid.
CONCATENATE runtime->application_url '/' guid '.pdf' INTO display_url.
cl_http_server=>server_cache_upload( url = display_url
response = cached_response ).
RETURN.
ENDIF.
Again so what am I missing? If I select the Convert to PDF with a text file and open in a new window I get my page then I do a save as and I save it as a .PDF but then Adobe can't open it. So I must be missing something easy...
Hi Craig,
Are you saving a text file with .pdf extension and trying to open it with adobe?
If thats the case it won't work because you haven't converted the text to PDF format.
To convert you need a ADOBE full version or some other free tools available on the net to convert from some format to PDF format.
Regards
Raja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Craig,
if I didn't miss something in your coding above I'd say
that you miss the pdf conversion somewhere (as Raja pointed out).
However, you don't need Adobe for that. Use e.g. function module CONVERT_OTF. Our approach was to create a smartform object and then do the conversion. Don't know how it works for plain text though.
regards, Ulli
Hi Craig,
Using Smartforms this is possible. Even I have been looking for FM's frantically for this conversion, in vain. I did look at the FM, Ulli mentiones, but not sure how to use.
Unfortunately, even I am starting from scratch.
Look at this Smartforms PDF file(how ironic!!!),
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVSCRSF/BCSRVSCRSF.pdf
and someone here has done that successfully. Once I figure it out, I shall definitely keep you posted.
Regards,
Subramanian V.
Other alternative:
Create ABAP Spool.
call function 'GET_PRINT_PARAMETERS'
exporting
destination = loc_dest
copies = wf_copies
list_name = wf_listname
list_text = wf_listtext
immediately = ' '
release = ' '
new_list_id = 'X'
expiration = wf_days
line_size = 200
line_count = 65
layout = 'X_65_200'
sap_cover_page = 'X'
receiver = 'SAP*'
department = ''
no_dialog = 'X'
importing
out_parameters = wf_params
valid = wf_valid.
if wf_valid <> space.
new-page print on parameters wf_params no dialog.
<using the normal ABAP write statement write the contents here (e.g Write:/'This is for testing'>
new-page print off.
endif .
this will create a spool.
now the sy-spono will contain the current spool no.
then call
FM CONVERT_ABAPSPOOLJOB_2_PDF withe spool no. as the parameter
save the returned table (PDF STRUCTURE TLINE) with .pdf extension and open it.
I havent tried this myself inside a BSP application, but i feel that it should work.
Regards
Raja
Raja, thanks for the alternative. For now though I think I am going to try Ulli's example with CONVERT_OTF
so <b>Ulli</b>!!!
data: l_pdf_xstring type xstring,
lt_lines type table of tline,
ls_line type tline,
l_pdf_len type i,
itab type TSFOTF,
witab type ITCOO,
tmp_line type STRING,
tmp_header type STRING.
tmp_header = 'BSP to PDF'.
tmp_line = file_content.
CONCATENATE
tmp_header
tmp_line
INTO tmp_line IN CHARACTER MODE.
APPEND tmp_line TO itab.
call function 'CONVERT_OTF'
exporting
format = 'PDF'
importing
bin_filesize = l_pdf_len
bin_file = l_pdf_xstring
tables
otf = itab
lines = lt_lines
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
others = 5
.
if sy-subrc EQ 0.
response->set_header_field( name = 'content-type'
value = 'application/pdf' ).
response->set_header_field(
name = 'cache-control'
value = 'max-age=0' ).
response->set_header_field(
name = 'content-disposition'
value = 'attachment; filename=test.pdf' ).
l_pdf_len = xstrlen( l_pdf_xstring ).
response->set_data( data = l_pdf_xstring
length = l_pdf_len ).
navigation->response_complete( ).
ENDIF.
This is the right way I think? So how do I get the data into OTF format to begin with? I keep getting an SY-SUBRC = 4 for BAD OTF format.
Hi Craig,
As far as I know, it is not all that easy to just use function modules and get away. (If you did get away with it, please please let me know...)
As you have asked the right question, how to get the OTF ??
This is a crude format of the code, but I can explain with my 1 day knowledge of SMARTFORMS what is happening in here.
If you see the control_parameters, there is a field called getotf, which gives the output of the function module into a table with OTF data.
So to start with you have to create a SMARTFORM. Transaction is SMARTFORMS. I took a printout of the link that I mentioned in my earlier post and started going through it. It is not difficult, but at the same time, it doesn't make it very easy. If you have any question regarding SMARTFORMS, you need to put up in ABAP Programming(they are a helpful lot).
In Smartforms, you need to tell how your output should look like and give all the nitty-gritty details, like where my heading goes, where my footer goes, where my table goes and stuff like that. When you activate this form, it creates a function module(<b>/1BCDWB/SF00000009</b>).
And this function module returns otf format and you then pass it to FM CONVERT_OTF.
report ytestsmartformreport .
data: lt_sflight type table of sflight.
data: output_options type ssfcompop,
control_parameters type ssfctrlop,
output_data type ssfcrescl,
devtype type rspoptype.
DATA: L_PDF_XSTRING TYPE XSTRING,
LT_LINES TYPE TABLE OF TLINE,
* LS_LINE TYPE TLINE,
L_PDF_LEN TYPE I.
control_parameters-langu = sy-langu.
control_parameters-no_dialog = 'X'.
control_parameters-getotf = 'X'.
select * from sflight into table lt_sflight.
call function '/1BCDWB/SF00000009'
exporting
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = control_parameters
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
* OUTPUT_OPTIONS =
* USER_SETTINGS = 'X'
importing
* DOCUMENT_OUTPUT_INFO =
job_output_info = output_data
* JOB_OUTPUT_OPTIONS =
tables
lt_sflight = lt_sflight
exceptions
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5
.
if sy-subrc <> 0.
endif.
write : 1.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
IMPORTING
BIN_FILESIZE = L_PDF_LEN
BIN_FILE = L_PDF_XSTRING " binary file
TABLES
OTF = OUTPUT_DATA-OTFDATA
LINES = LT_LINES
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5
.
IF SY-SUBRC <> 0.
* error handling
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Life is not easy. 😛
Regards,
Subramanian V.
P.S. - Let us know if you nailed it.
Basically this was the BSP Application "SF_WEBFORM_04" right?
I got my initial code from that as well but I was actually attempting to create the OTF output from something other than a table. I guess I could build the data into rows of an Internal table as rows of text - I guess that is basically the LINES table then huh?
I'll try the SmartForm way, maybe even read the link Subramanian V. gave then I'll try the SPOOL way from Raja and I'll post what my final results were.
Maybe you can post a weblog or two and do a comparison!!! 😛
You know what! when you say webform, that reminds me of something more. I had seen a webform video clip/tutorial on SDN, probably that would help you as well.
I just saw the webform you mention and yes it can be done that way as well. Now where is that link of the clip.(I downloaded that, it is a 39 MB video.
It has a transaction SFP.
Regards,
Subramanian V.
Message was edited by: Subramanian Venkateswaran
OTF Vs. ABAP spool model
1. for OTS you have to create/maitain additional object (a smartform) whereas you eliminate this in ABAP list spool model.
2. In terms of performance also ABAP list spool model would be better.
If you willing to spend , like HTMLDOC there are some activex objects / products also available which can handle different sources.
Regards
Raja
HTMLDOC availbale as GNU -> http://www.htmldoc.org/
and commercial app -> www.easysw.com
Depending on what your needs are, the GNU version might be fine (like for ours).
So Raja, only write statements will work out in ABAP spool , right ? (i.e. all list processing statements, like WRITE ..FORMAT.. COLOR etc.).
Can I call a <b>REUSE_ALV_LIST_DISPLAY</b> and put inside this spool (because then I can create a nice table without any hassles and colour is automatically put for heading , table entries, sum, subtotal)?
I suspect if it is good graphics, then probably ABAP Spool would not work , and ABAP spool will have more write statements and formatting as compared to other techniques.
Regards,
Subramanian V.
hope that helps:
1) create smartform object
2) CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = [smartform object]
IMPORTING
fm_name = [function module]
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
3) CALL FUNCTION [function module]
EXPORTING
....
IMPORTING
job_output_info = output_data
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
4) CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = pdf_length
bin_file = pdf_xstring
TABLES
otf = output_data-otfdata
lines = lines
EXCEPTIONS
.....
Craig,
The way to go is to install HTMLDOC, then make an external command.
In your BSP page (with extension pdf, is needed for MIE) make you HTML and write it to temp file.
Call the external command with the temp file as input. Then read the pdf and set it as content and set all response headers for pdf. Clean up the temp files.
It works good and fast.
Eddy
Raja do yo have a complete code sample for you suggestion?
I've been playing around with it but still haven't gotten it, I think I'm close though and it's the last bit to put in the weblog before publishing.
DATA: itab TYPE TLINE,
witab TYPE TABLE OF TLINE,
loc_dest TYPE STRING,
output TYPE STRING,
outputx TYPE XSTRING,
wf_params TYPE PRI_PARAMS.
loc_dest = 'c:temp'.
wf_params-PDEST = 'lp01'.
wf_params-PRCOP = 1.
call function 'GET_PRINT_PARAMETERS'
EXPORTING
* destination = loc_dest
* copies = wf_copies
* list_name = wf_listname
* list_text = wf_listtext
* expiration = wf_days
immediately = ' '
release = ' '
new_list_id = 'X'
line_size = 200
line_count = 65
layout = 'X_65_200'
sap_cover_page = 'X'
receiver = 'SAP*'
department = ''
no_dialog = 'X'
IMPORTING
out_parameters = wf_params.
* valid = wf_valid
* if wf_valid <> space.
* new-page print on parameters wf_params no dialog.
*
** using the normal ABAP write statement
** write the contents here
** (e.g Write:/'This is for testing'
*
* new-page print off.
* endif .
*this will create a spool. now the sy-spono will contain the current spool no.
*then call FM CONVERT_ABAPSPOOLJOB_2_PDF withe spool no. as the parametersave
*the returned table (PDF STRUCTURE TLINE) with .pdf extension and open it.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = sy-spono
NO_DIALOG = 'X'
TABLES
PDF = witab
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 8
ERR_BTCJOB_SUBMIT_FAILED = 9
ERR_BTCJOB_CLOSE_FAILED = 10
others = 11.
if sy-subrc EQ 0.
LOOP AT witab INTO itab.
CONCATENATE
output
itab-tdline
INTO output IN CHARACTER MODE.
ENDLOOP.
outputx = output.
CREATE OBJECT cached_response TYPE CL_HTTP_RESPONSE EXPORTING add_c_msg = 1.
l_pdf_len = xstrlen( outputx ).
cached_response->set_data( data = outputx
length = l_pdf_len ).
cached_response->set_header_field( name = if_http_header_fields=>content_type
value = 'application/pdf' ).
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 180 ).
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = guid.
CONCATENATE runtime->application_url '/' guid '.pdf' INTO display_url.
cl_http_server=>server_cache_upload( url = display_url
response = cached_response ).
ENDIF.
If you can give me a hand Raja I can publish this weblog with 3 possible solutions and code samples for 2 and not just 1 that work.
I just don't know all the input parameters with the "GET_PRINT_PARAMETERS" FM.
Actually the more I think about this, I don't think this way would work, at least not easily. You can't do the ABAP write statements in BSP's.
Now if you already know the Spool number it will work, if I can figure out how to convert STRING to XSTRING, going from XSTRING to STRING is easy
BSP/HowTo: Generate PDF Output from a BSP.
/people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp
Need to generate a BSP page report as PDF? Read the posts and weblogs available for it? Still having a problem? Myself with lots and lots of help from other SDNers, well have we got a nice little write-up for you...
Craig, I think I can a learn a tip or two from you on Smartforms now.
That weblog makes the task so much easier.
Talking about points, you should get some <b>additional + bonus points</b>, as you managed to figure out SMARTFORMS in hours, and not to forget making the weblog in minutes.
Regards,
Subramanian V.
Message was edited by: Subramanian Venkateswaran
Hello Subramanian,
I assume you mean Interactive Forms. You can find the homepage here: https://www.sdn.sap.com/sdn/developerareas/was.sdn?page=AdobeForms.htm
And the video how to use it in Web AS 6.40 for print forms (transaction SFP) is here https://www.sdn.sap.com/sdn/elearning.sdn?class=/public/videos/S9-ABAP_Design_time_demo.wmv
Cheers
Matthias
I was on vacation in Paris and nearly missed this good discussion. Indeed Interactive Forms is the "next generation" forms tool in SAP (and not only for interactive, but also for print forms). It is available starting with Web AS 6.40. Smart Forms and SAPscript will be continue to be available but all new development around SAP forms will be done in the new Interactive Forms. The Adobe document services (ADS) which are part of Interactive Forms can generate different output including PDF, PS, PCL and ZPL (for Zebra Label printers).
So with Interactive Forms you will be able to generate PDF in an SAP system natively by merging forms data with a form template (so you do not need to create OTF anymore and use the CONVERT_OTF libraries to generate PDF). This can be configured in ABAP using transaction SFP or with Web Dynpro for Java to create PDF documents embedded in a Web UI (and in the future also with Web Dynpro for ABAP).
The PDFs generated with ADS are actually the latest version PDF 1.6 and can be made accessible to blind people via screen readers.
By the way the Interactive Forms functionality to generate print forms (non-interactive forms) is freely available to SAP customers as part of Web AS. However if you want to deploy custom interactive PDF forms (PDF forms which can be used to capture data in the free Adobe Reader and return it to the SAP application) in production you will need an additional license for it (available through SAP). That helps Adobe to pay for all my SAP TechEd travel
Hi Cragi,
Sorry about the delay. Its holiday time here (Diwali - an Indian festival means festival of lights and EID). I just managed to visit SDN last night and saw the developments in this thread.
Here it goes for creating spool:
If BSP dosent allow write statements, you could simply write a report program (type 1) and use
<b>SUBMIT rep ... TO SAP-SPOOL.</b> statement to create spool.
If your content is just plain text you can use the following function module to create a spool
RSPO_SX_OUTPUT_TEXTDATA
exporting
name = "LOCAL"
rows = <no of rows>
startrow = 1
title = <title>
immediately = ""
tables
text_data = datatab
importing
rqid = <returned spool number> .
I will be back to work on 16th and i will try to create a working complete example and post it here.
In the meantime if you need any info mail me @ athavanraja@gmail.com
Regards
Raja
I am back.
Here is the code for ABAP spool.
<u><b>OnInputProcessing</b></u>
DATA: itab TYPE tline,
witab TYPE TABLE OF tline,
output TYPE string ,
wf_spono type TSP01-RQIDENT ,
wf_params TYPE pri_params,
valid_flag(1) TYPE c ,
lc_rq2name type tsp01-rq2name ,
tsp01_wa type tsp01 .
call function 'GET_PRINT_PARAMETERS'
EXPORTING
destination = 'locl'
immediately = ' '
release = ' '
new_list_id = 'X'
line_size = 200
line_count = 65
layout = 'X_65_200'
sap_cover_page = 'X'
receiver = 'SAP*'
department = ''
no_dialog = 'X'
IMPORTING
out_parameters = wf_params
valid = valid_flag .
IF valid_flag = 'X' AND sy-subrc = 0.
SUBMIT GUILSTCN TO SAP-SPOOL
SPOOL PARAMETERS wf_params
WITHOUT SPOOL DYNPRO and return .
ENDIF.
this is to get the spool no. created. Not a real nice
way though. if someone knows a better method please do
share
concatenate 'SAPMHTTP'
sy-uname+0(3)
into lc_rq2name separated by '_'.
select * from tsp01 into tsp01_wa where rq2name = lc_rq2name and
rqowner = sy-uname
order by rqcretime descending.
wf_spono = tsp01_wa-rqident.
exit.
endselect.
if sy-subrc ne 0.
clear wf_spono.
endif.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = wf_spono
no_dialog = 'X'
TABLES
pdf = witab
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 8
err_btcjob_submit_failed = 9
err_btcjob_close_failed = 10
OTHERS = 11.
IF sy-subrc EQ 0.
In his weblog on <u><b>BSP Programming: Handling Of Non-HTML Documents</b></u> Brian McKellar mentioned about
<b><i>A long time ago we debugged for hours to understand why we couldn't display a PDF document correctly. The document was created by some function module, and if downloaded with SAP GUI worked perfectly. However, in HTTP context it was corrupted every time.
The simple coding used was:
CALL FUNCTION 'GIME_PDF' RECEIVING table_of_pdf_data.
LOOP AT table_of_pdf_data INTO line.
CONCATENATE content line INTO content.
ENDLOOP.
PDF data is text data that can be handled with normal STRING operations. However, it often happened that "line" contained trailing spaces, which were separator tokens in the PDF document. For ABAP, trailing spaces have no further meaning and they are completely ignored. So these trailing spaces never made it into the "content" string. Now the final string contained tokens that were not space separated anymore. Boom. Crash. Burn.
The simple solution: use character mode when concatenating the strings together.
CONCATENATE content line INTO content IN CHARACTER MODE.</i></b>
*But it didnt help me. I had to manage the spaces like below.
LOOP AT witab INTO itab .
TRANSLATE itab USING ' ~'.
CONCATENATE output itab INTO output IN CHARACTER MODE.
ENDLOOP.
TRANSLATE output USING '~ ' .
CREATE OBJECT cached_response TYPE cl_http_response EXPORTING add_c_msg = 1.
l_pdf_len = STRLEN( output ).
cached_response->set_cdata( data = output
length = l_pdf_len ).
cached_response->set_header_field( name = if_http_header_fields=>content_type
value = 'application/pdf' ).
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 180 ).
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = guid.
CONCATENATE runtime->application_url '/' guid '.pdf' INTO display_url.
cl_http_server=>server_cache_upload( url = display_url
response = cached_response ).
RETURN .
endif .
Hope it is clear.
Regards
Raja
Durairaj and all other guru's out there.
I've managed to get this working through a BSP using both 'CONVERT_OTF' and 'CONVERT_ABAPSPOOLJOB_2_PDF'.
It works great and would like to thank you for the guidance. I do however have a question:
1) Is there a way to compress the PDF data before sending to the browser as the PDF takes a while to load.
Regards
Faaiez
Why not use the archive link parameters of the function GET_PRINT_PARAMETERS:
sap_object = sap_obj
ar_object = ar_obj
archive_mode = '2'
archive_info = info(3)
archive_text = 'Test'(001)
My problem with this is that it seem to require a external storage system and I want to use the SAP content storage (the one in SAP 4.6c where the data is stored in R/3 database tables). It seem to require an entry in table TOAAR (goto trx SM30 and entry view name TOAAR_C and press display or maintain). Does anybody know how to get around this problem?
Meanwhile I am going with the suggestions as described in this forum thread. When I have some example I will post it here.
Cheers Dennis.
> 1) Is there a way to compress the PDF data before
> sending to the browser as the PDF takes a while to
> load.
On the server object there is a method set_compression( ). From what I remember it might even be duplicated on the response object as well. This will (attempt to) turn on GZIP compression for the response.
*----
Store smartform output as a pdf in DMS
Document storage in the SAP content storage system (R/3 tables)
Works with any smartform
30/june/2005 Dennis vd Broek
*----
REPORT oatestform.
parameters smartform control structure
PARAMETER:
no_open TYPE tdsfflag,
no_close TYPE tdsfflag,
device TYPE tddevice,
nodialog TYPE tdsfflag,
preview TYPE tdpreview,
getotf TYPE tdgetotf,
langu TYPE tdspras,
rplangu1 TYPE tdspras,
rplangu2 TYPE tdspras,
rplangu3 TYPE tdspras,
strtpage TYPE tdobjname.
declarations data for smartform
DATA:
lcl_fname TYPE rs38l_fnam, "function name smartform routine
wa_adrsite TYPE adrc,
wa_telsite TYPE adr2,
wa_faxsite TYPE adr3,
wa_adrsubco TYPE adrc,
wa_telsubco TYPE adr2,
wa_faxsubco TYPE adr3,
wa_rmksubco TYPE adrt,
wa_approver TYPE adrp,
wa_bednr LIKE ekpo-bednr,
wa_notif_act TYPE zcon_subconpaymreq,
wa_notif_prv TYPE zcon_subconpaymreq,
wa_notif_cum TYPE zcon_subconpaymreq,
wa_addr1_val TYPE addr1_val, "address values
wa_ssfctrlop TYPE ssfctrlop, "control parameters
wa_ssfcrescl TYPE ssfcrescl, "job output (among others otf data)
wa_ssfcresop TYPE ssfcresop, "ouput options
wa_spoolids TYPE rspoid, "spoolid
i_pdf_bytecount TYPE i, "byte count file size
tb_pdf TYPE STANDARD TABLE OF tline. "pdf file data
declaratons sap document object
DATA:
o_document_set TYPE REF TO cl_bds_document_set,
tb_pdf_content TYPE STANDARD TABLE OF bapiascont,
tb_bapicompon TYPE STANDARD TABLE OF bapicompon,
wa_bapicompon TYPE bapicompon,
wa_signature TYPE bapisignat, "signature
tb_signature TYPE STANDARD TABLE OF bapisignat. "signature
*----
START-OF-SELECTION.
*----
get function module name for given smartform
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZCON_PR_NOTIFICATION_LETTER'
IMPORTING
fm_name = lcl_fname
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.
set control parameters
wa_ssfctrlop-no_open = no_open.
wa_ssfctrlop-no_close = no_close.
wa_ssfctrlop-device = device.
wa_ssfctrlop-no_dialog = nodialog.
wa_ssfctrlop-preview = preview.
wa_ssfctrlop-getotf = getotf.
wa_ssfctrlop-langu = langu.
wa_ssfctrlop-replangu1 = rplangu1.
wa_ssfctrlop-replangu2 = rplangu2.
wa_ssfctrlop-replangu3 = rplangu3.
wa_ssfctrlop-startpage = strtpage.
start output smartform
CALL FUNCTION lcl_fname
*CALL FUNCTION '/1BCDWB/SF00000050'
EXPORTING
archive_index = toa_dara
archive_params = arparams
user_settings = ' '
ssfctrlop = wa_ssfctrlop
adrsubco = wa_adrsubco
adrsite = wa_adrsite
telsubco = wa_telsubco
telsite = wa_telsite
faxsite = wa_faxsite
bednr = wa_bednr
znotif_prv = wa_notif_prv
znotif_cum = wa_notif_cum
faxsubco = wa_faxsubco
approver = wa_approver
znotif_act = wa_notif_act
rmksubco = wa_rmksubco
wa_addr1_val = wa_addr1_val
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = wa_ssfcrescl
job_output_options = wa_ssfcresop
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
check result
CASE sy-subrc.
WHEN 0.
everything oke
WHEN 1.
MESSAGE ID 'ZCONK' TYPE 'E' NUMBER '000' WITH 'Formatting error'(m08).
WHEN 2.
MESSAGE ID 'ZCONK' TYPE 'E' NUMBER '000' WITH 'Internal error'(m09).
WHEN 3.
MESSAGE ID 'ZCONK' TYPE 'E' NUMBER '000' WITH 'Send error'(m10).
WHEN OTHERS.
ignore
ENDCASE.
get spoolid
LOOP AT wa_ssfcrescl-spoolids INTO wa_spoolids.
get first id
EXIT.
ENDLOOP. "wa_ssfcrescl-SPOOLIDS
convert spooljob to pdf
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = wa_spoolids
NO_DIALOG =
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
pdf_bytecount = i_pdf_bytecount
PDF_SPOOLID =
OTF_PAGECOUNT =
BTC_JOBNAME =
BTC_JOBCOUNT =
TABLES
pdf = tb_pdf
EXCEPTIONS
err_no_otf_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_dstdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
check result
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
convert pdf table to table for storage in DMS
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src = 134
line_width_dst = 1022
TABLES
content_in = tb_pdf
content_out = tb_pdf_content
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
create document instance
CREATE OBJECT o_document_set.
set componants values
wa_bapicompon-doc_count = '1'.
wa_bapicompon-comp_count = '1'.
wa_bapicompon-comp_id = 'DBTEST001'.
wa_bapicompon-comp_size = i_pdf_bytecount.
APPEND wa_bapicompon TO tb_bapicompon.
set values document signature
copy data for signature info
MOVE:
'00000001' TO wa_signature-doc_count,
'DBTEST001' TO wa_signature-doc_id,
attribute name
'BDS_DOCUMENTTYPE' TO wa_signature-prop_name,
attribute value
'ZCON_REMAD' TO wa_signature-prop_value.
APPEND wa_signature TO tb_signature.
copy document type for signature info
MOVE:
'00000001' TO wa_signature-doc_count,
'BDS_DOCUMENTCLASS' TO wa_signature-prop_name,
'PDF' TO wa_signature-prop_value.
APPEND wa_signature TO tb_signature.
copy description for signature info
MOVE:
'00000001' TO wa_signature-doc_count,
'DESCRIPTION' TO wa_signature-prop_name,
'Remittance Advice HBG UK' TO wa_signature-prop_value.
APPEND wa_signature TO tb_signature.
call method
CALL METHOD o_document_set->create_with_as_table
EXPORTING classname = 'BKPF'
classtype = 'BO'
components = tb_bapicompon
ascii_content = tb_pdf_content
CHANGING signature = tb_signature.
write info to screen
WRITE:/ 'Subrc method create_with_as_table:', sy-subrc.
WRITE:/ 'Lookup document with transaction OAOR.'.
WRITE:/ 'Class name = BKPF'.
WRITE:/ 'Class type = BO'.
WRITE:/ 'Execute report (F8)'.
WRITE:/ 'Leave all fields in popup screen blank'.
WRITE:/ 'This will give you all documents for object BKPF'.
https://www.sdn.sap.com/sdn/elearning.sdn?class=/public/videos/S9-ABAP_Design_time_demo.wmv
link is not working.
Thank you,
Jagadish
Hi,
We have configured smartform to view from Cprojects BSP application (Output Type in Smartform = XSF output+HTML). We are able view the font on BSP application layout that is applied from smartstyle (say Arial), but when downloaded the smartform applying the same smartstyle with only change in output type (Standard Output) the font in the pdf document is shown as Courier instead of Arial. Can any one suggest what is the reason for this, or do we need to make any settings for the font style.
Thanks in advance..
Regards,
Sumanth.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.