Este es un ejemplo extendido del método para llamar a un Smartform, con la variante de exportar a PDF o a Xstring (comentado porque la función no me trae la tabla llena, hay que cambiar de método dependiendo del requerimiento) y con la variante de HTML, pero aun no he experimentado con esa salida.
*&---------------------------------------------------------------------*
*& Form MUESTRA_REPORTE
*&---------------------------------------------------------------------*
FORM muestra_reporte USING get_pdf.
DATA resul TYPE xstring.
DATA lt_lines TYPE TABLE OF tline.
DATA bin_filesize TYPE i.
DATA lt_docs TYPE TABLE OF docs.
DATA lv_nombre_smartforms TYPE rs38l_fnam.
*& Form MUESTRA_REPORTE
*&---------------------------------------------------------------------*
FORM muestra_reporte USING get_pdf.
DATA resul TYPE xstring.
DATA lt_lines TYPE TABLE OF tline.
DATA bin_filesize TYPE i.
DATA lt_docs TYPE TABLE OF docs.
DATA lv_nombre_smartforms TYPE rs38l_fnam.
DATA formname TYPE tdsfname VALUE sy-repid.
DATA control_parameters TYPE ssfctrlop.
DATA output_options TYPE ssfcompop.
DATA job_output_info TYPE ssfcrescl.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = formname
IMPORTING
fm_name = lv_nombre_smartforms
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.
EXIT.
ENDIF.
* PARAMETROS DE CONTROL
control_parameters-no_dialog = 'X'.
* control_parameters-preview = 'X'.
** salida para PDF
control_parameters-getotf = get_pdf. "salida en job_output_info-otfdata
output_options-tdnewid = ' '.
output_options-tdimmed = ' '.
output_options-tddelete = ' '.
** salida para html
* output_options-xdfcmode = space.
* output_options-xdf = space.
* output_options-xsf = 'X'.
* output_options-xsfcmode = 'X'.
* output_options-xsfoutmode = 'A'.
* output_options-xsfformat = 'X'.
* PARAMETROS PARA IMPRESION
output_options-tdtitle = sy-title.
* output_options-tdnoprint = 'X'.
CALL FUNCTION lv_nombre_smartforms
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = control_parameters
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
output_options = output_options
* USER_SETTINGS = 'X'
IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = job_output_info
* JOB_OUTPUT_OPTIONS =
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.
ENDIF.
IF get_pdf = 'X'.
* CALL FUNCTION 'CONVERT_OTF'
* EXPORTING
* format = 'PDF'
** pdf_delete_otftab = 'X'
* IMPORTING
* bin_filesize = bin_filesize
* bin_file = resul
* TABLES
* otf = job_output_info-otfdata
* lines = lt_lines
* EXCEPTIONS
* err_max_linewidth = 1
* err_format = 2
* err_conv_not_possible = 3
* OTHERS = 4.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = job_output_info-otfdata
doctab_archive = lt_docs
lines = lt_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 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.
ELSE.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'Descarga de Archivos'
default_extension = 'PDF'
default_file_name = 'documento'
initial_directory = 'c:\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
IF ld_filename IS NOT INITIAL.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = bin_filesize
filename = ld_fullpath
filetype = 'BIN'
CHANGING
data_tab = lt_lines[]
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
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
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.
ENDFORM. " MUESTRA_REPORTE
DATA control_parameters TYPE ssfctrlop.
DATA output_options TYPE ssfcompop.
DATA job_output_info TYPE ssfcrescl.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = formname
IMPORTING
fm_name = lv_nombre_smartforms
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.
EXIT.
ENDIF.
* PARAMETROS DE CONTROL
control_parameters-no_dialog = 'X'.
* control_parameters-preview = 'X'.
** salida para PDF
control_parameters-getotf = get_pdf. "salida en job_output_info-otfdata
output_options-tdnewid = ' '.
output_options-tdimmed = ' '.
output_options-tddelete = ' '.
** salida para html
* output_options-xdfcmode = space.
* output_options-xdf = space.
* output_options-xsf = 'X'.
* output_options-xsfcmode = 'X'.
* output_options-xsfoutmode = 'A'.
* output_options-xsfformat = 'X'.
* PARAMETROS PARA IMPRESION
output_options-tdtitle = sy-title.
* output_options-tdnoprint = 'X'.
CALL FUNCTION lv_nombre_smartforms
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = control_parameters
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
output_options = output_options
* USER_SETTINGS = 'X'
IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = job_output_info
* JOB_OUTPUT_OPTIONS =
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.
ENDIF.
IF get_pdf = 'X'.
* CALL FUNCTION 'CONVERT_OTF'
* EXPORTING
* format = 'PDF'
** pdf_delete_otftab = 'X'
* IMPORTING
* bin_filesize = bin_filesize
* bin_file = resul
* TABLES
* otf = job_output_info-otfdata
* lines = lt_lines
* EXCEPTIONS
* err_max_linewidth = 1
* err_format = 2
* err_conv_not_possible = 3
* OTHERS = 4.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = job_output_info-otfdata
doctab_archive = lt_docs
lines = lt_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 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.
ELSE.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'Descarga de Archivos'
default_extension = 'PDF'
default_file_name = 'documento'
initial_directory = 'c:\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
IF ld_filename IS NOT INITIAL.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = bin_filesize
filename = ld_fullpath
filetype = 'BIN'
CHANGING
data_tab = lt_lines[]
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
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
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.
ENDFORM. " MUESTRA_REPORTE
No hay comentarios:
Publicar un comentario