on 04-19-2007 12:39 PM
Hello,
we have an application with many forms in SAPscript and in future we us Web Dynpro for ABAP. Of course, we want reuse the output of SAPscript and Smartforms.
In the Forum saw I some information about the printing with SAPscript in PDF format. I create following Test-Program on a System SAP ECC 6.0 (SAPKB70011) with SP11.
The output in a new window was only a line like this:
å¥äã¬ã®à¨î¥ì¿£àãã æ¼ æ©¢à¨ã°¼à¨å¯ç¹â¥ä¯æ¹¯ä´ç¥ç£ç©æ½´àµ²â¼çæ (and more)
What is the problem?
Can me anybody help or have an idea?
Regards, Joachim
=> onaction method
method pdf_druck .
.. same declarations
=> creat SAPcript output as OTF
data lx_pdf type xstring.
data lx_zeichen type string.
call function 'Z_VSP_FORM_WD4A'
exporting
i_tbnr = space
i_venr = stru_upl-venr
i_formid = stru_upl-part
importing
ex_pdf = lx_zeichen .
*
data:
lv_length type i,
l_ref_conv type ref to cl_abap_conv_out_ce.
clear:
lv_length, l_ref_conv.
Erzeugt Konvertiererinstanz........
try.
call method cl_abap_conv_out_ce=>create
EXPORTING
encoding = 'default'
encoding = 'UTF-8'
endian =
replacement = '#'
ignore_cerr = abap_false
receiving
conv = l_ref_conv .
catch cx_parameter_invalid_range .
catch cx_sy_codepage_converter_init .
endtry.
*
Konvertiert und fügt das Ergebnis an den Ausgabepuffer an....
=> input = string
try.
call method l_ref_conv->write
exporting
n = -1
data = lx_zeichen
view =
importing
len = lv_length .
catch cx_sy_codepage_converter_init .
catch cx_sy_conversion_codepage .
catch cx_parameter_invalid_type .
catch cx_parameter_invalid_range .
endtry.
*
Holt den Ausgabepuffers.....
=> output = xstring
try.
call method l_ref_conv->get_buffer
receiving
buffer = lx_pdf.
catch cx_root.
endtry .
*
Output PDF in a new Window
cl_wd_runtime_services=>attach_file_to_response(
i_filename = 'Formular.PDF'
i_content = lx_pdf
i_mime_type = 'application/pdf'
i_in_new_window = 'X'
i_inplace = 'X' ).
*
endmethod.
function z_vsp_form_wd4a.
""Globale Schnittstelle:
*" IMPORTING
*" VALUE(I_TBNR) TYPE YTMTBNR DEFAULT SPACE
*" VALUE(I_VENR) TYPE YTMVENR DEFAULT '0020000050'
*" VALUE(I_FORMID) TYPE YTMFORMID DEFAULT 'LOTF'
*" EXPORTING
*" VALUE(EX_PDF) TYPE STRING
=> handling
declarations
call function 'Y_YTM_VSP_OTF_LS'
*" IMPORTING
*" VALUE(DRUCK_PARM) LIKE YTM_YSAPP STRUCTURE YTM_YSAPP
*" EXPORTING
*" TABLES
*" EXCEPTIONS
=> make a otf File for SAPscrits
itcpo-tdgetotf = 'X'. "Format OTF
itcpo-tdnoprev = 'X'. "no Print preview
call function 'OPEN_FORM'
exporting
application = con_application_tx
archive_index = archive_index
archive_params = archive_params
device = x_device
dialog = space
form = lp_formnam
language = lp_spras
options = itcpo
importing
language = lp_spras
exceptions
canceled = 1
device = 2
form = 3
options = 4
unclosed = 5
others = 6.
WRITE_FORM
WRITE_FORM
WRITE_FORM
call function 'CLOSE_FORM'
importing
result = itcpp
tables
otfdata = lt_otf
exceptions
unopened = 01.
put otf into memory for later usage.....
call function 'SAVE_OTF_TO_MEMORY'
exporting
MEMORY_KEY = 'DEF_OTF_MEMORY_KEY'
memory_key = sy-uname
tables
otf = lt_otf .
endfunction Y_YTM_VSP_OTF_LS
call function 'READ_OTF_FROM_MEMORY'
exporting
MEMORY_KEY = 'DEF_OTF_MEMORY_KEY'
memory_key = sy-uname
tables
otf = lt_otf
exceptions
memory_empty = 1
others = 2.
*
call function 'CONVERT_OTF'
exporting
format = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
importing
bin_filesize = lf_filesize
BIN_FILE =
tables
otf = lt_otf
lines = lt_pdf
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
others = 5.
convert tline to xstring as needed in web dynpro
field-symbols .
data: st(268) type c,
l1 type i,
len type i,
maxline type i value 134.
l1 = 0.
loop at lt_pdf into tline.
clear st.
st+l1(maxline) = tline.
len = maxline + l1.
l1 = maxline - strlen( tline ).
ASSIGN st TO <x> TYPE 'X'. <= not possible
assign st to (len) into ex_pdf.
endloop.
endfunction z_vsp_form_wd4a.
Hi Kopp,
I am not understanding what you have written here. But for your case i can provide the solution so that you can go ahead with this alternative solution. I have the problem like when execute my report output will be displayed. I just take the spool number of that output and converted into PDF and displayed as PDF.
So in you case also, you pass the script to print and catch the spool number and then you can display as PDF output in Webdynpro ABAP. Here i am adding the code for PDF converting from the spool. This will definetly help to you.
<b>Code:</b>
method BUILD_PDF .
DATA:
pdf TYPE TABLE OF tline,
lv_spid type TSP01-RQIDENT,
lv_source TYPE xstring,
lv_tdformat TYPE xstring,
lv_tdline TYPE xstring,
pdf_bytecount TYPE i.
DATA:
node_pdf TYPE REF TO if_wd_context_node,
elem_pdf TYPE REF TO if_wd_context_element,
stru_pdf TYPE if_v_pdf=>element_pdf ,
item_source LIKE stru_pdf-source.
DATA: pdf_line LIKE LINE OF pdf,
output TYPE string.
FIELD-SYMBOLS: <p> TYPE x.
IF wd_comp_controller->mr_spooltype EQ 'S'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = wd_comp_controller->mr_spoolid
NO_DIALOG = NO_DIALOG
DST_DEVICE = DST_DEVICE
PDF_DESTINATION = PDF_DESTINATION
IMPORTING
pdf_bytecount = pdf_bytecount
TABLES
pdf = 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
.
ELSE.
for large documents
sy-batch = 'X'.
lv_spid = wd_comp_controller->mr_spoolid.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = lv_spid
NO_DIALOG = NO_DIALOG
DST_DEVICE = DST_DEVICE
PDF_DESTINATION = PDF_DESTINATION
IMPORTING
pdf_bytecount = pdf_bytecount
PDF_SPOOLID = PDF_SPOOLID
LIST_PAGECOUNT = LIST_PAGECOUNT
BTC_JOBNAME = BTC_JOBNAME
BTC_JOBCOUNT = BTC_JOBCOUNT
TABLES
pdf = pdf
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 = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12
.
ENDIF.
LOOP AT pdf INTO pdf_line.
ASSIGN pdf_line TO <p> CASTING TYPE x.
CONCATENATE lv_source <p> INTO lv_source IN BYTE MODE.
ENDLOOP.
node_pdf = wd_context->get_child_node( name = if_v_pdf=>wdctx_pdf ).
get element via lead selection
elem_pdf = node_pdf->get_element( ).
get single attribute
elem_pdf->set_attribute(
EXPORTING
name = `SOURCE`
value = lv_source ).
ENDMETHOD.
Warm Regards,
Vijay.
Message was edited by:
Vijaya Bhaskarudu Gangisetty
Message was edited by:
Vijaya Bhaskarudu Gangisetty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
79 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.