Como continuación del ejemplo anterior, realizaremos unas pequeñas
modificaciones para que además de imprimir en un único spool, podamos tomarlo y
grabarlo en formato PDF.
*Variables Locales+
data: is_otf type c,
id_spool like tsp01-rqident.
id_spool like tsp01-rqident.
data: pdf_bytecount type i.
data: begin of it_pdf_output occurs 0.
include structure tline.
data: end of it_pdf_output.
data: begin of it_pdf_output occurs 0.
include structure tline.
data: end of it_pdf_output.
data: filename type string.
filename = 'C:\tmp\documento.pdf'.
filename = 'C:\tmp\documento.pdf'.
…
* Cierro el Spool
if ( p_accion eq 'C' ).
clear: r_job_output_info.
call function 'SSF_CLOSE'
importing
job_output_info = r_job_output_info
exceptions
formatting_error = 1
internal_error = 2
send_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.
else.
* Identifico el Numero del Spool generado
read table r_job_output_info-spoolids index 1 into id_spool.
message s499 with 'Orden de Spool Generada : ' id_spool.
* si se desea bajar a PDF
if ( p_down eq 'X' ). “Flag o pamametro
if ( p_accion eq 'C' ).
clear: r_job_output_info.
call function 'SSF_CLOSE'
importing
job_output_info = r_job_output_info
exceptions
formatting_error = 1
internal_error = 2
send_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.
else.
* Identifico el Numero del Spool generado
read table r_job_output_info-spoolids index 1 into id_spool.
message s499 with 'Orden de Spool Generada : ' id_spool.
* si se desea bajar a PDF
if ( p_down eq 'X' ). “Flag o pamametro
call function 'RSPO_GET_TYPE_SPOOLJOB'
exporting
rqident = id_spool
importing
is_otf = is_otf
exceptions
can_not_access = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
* Convierto el SPOOL a PDF
call function 'CONVERT_OTFSPOOLJOB_2_PDF'
exporting
src_spoolid = id_spool
importing
pdf_bytecount = pdf_bytecount
tables
pdf = it_pdf_output
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.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
* Genero la salida del documento pdf
call function 'GUI_DOWNLOAD'
exporting
bin_filesize = pdf_bytecount
filename = filename "
filetype = 'BIN' "'ASC'
tables
data_tab = it_pdf_output
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22.
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.
endif. " if ( P_DOWN eq 'X' )
endif. " if ( p_accion eq 'C' )
exporting
rqident = id_spool
importing
is_otf = is_otf
exceptions
can_not_access = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
* Convierto el SPOOL a PDF
call function 'CONVERT_OTFSPOOLJOB_2_PDF'
exporting
src_spoolid = id_spool
importing
pdf_bytecount = pdf_bytecount
tables
pdf = it_pdf_output
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.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
* Genero la salida del documento pdf
call function 'GUI_DOWNLOAD'
exporting
bin_filesize = pdf_bytecount
filename = filename "
filetype = 'BIN' "'ASC'
tables
data_tab = it_pdf_output
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22.
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.
endif. " if ( P_DOWN eq 'X' )
endif. " if ( p_accion eq 'C' )
…
Como
en todos los casos, si existe una forma mas fácil me cuentan.
Desarrollado
en version SAP ECC 6.0
M... Tal vez se pueda simplificar un poco, ya que es posible recuperar el OTF directamente de la función asociada al smartform, sin pasar por el spool de impresión.
ResponderEliminarEl OTF luego es convertido en PDF igual que aquí.
(Rodrigo)
Rodrigo:
ResponderEliminarSi eso es muy cierto, este caso en particular se ajusta a la generación de varios smartforms en un mismo spool, lo que se reduce a un solo PDF.
En el caso de ocupar la función del smartform, según yo se generarían varios PDF.
Ahora si puedes aportar con el ejemplo, se agradecería.