Difference between revisions of "SAP ABAP ADOBE FORMS"
From SapWiki
(Created page with "<pdf>File:Mini_manual_adobe_forms.pdf</pdf> <pdf>File:Insertar_imagenes_Adobe_Forms.pdf</pdf>") |
(→Notas) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | <pdf>File: | + | <pdf>File:Mini_manual_adobe_forms2.pdf</pdf> |
<pdf>File:Insertar_imagenes_Adobe_Forms.pdf</pdf> | <pdf>File:Insertar_imagenes_Adobe_Forms.pdf</pdf> | ||
+ | |||
+ | ==Ejemplo programa de impresión== | ||
+ | <nowiki>FORM print_pdf USING p_data TYPE zestruc_mi_formulario | ||
+ | CHANGING p_xstring TYPE xstring | ||
+ | p_subrc TYPE sy-subrc. | ||
+ | DATA: wa_output TYPE sfpoutputparams, | ||
+ | wa_result TYPE sfpjoboutput. | ||
+ | DATA: gs_fp_outputparams TYPE sfpoutputparams, | ||
+ | lv_fm_name TYPE rs38l_fnam, | ||
+ | lv_form_name TYPE fpwbformname, | ||
+ | wa_docparams TYPE sfpdocparams. | ||
+ | DATA ls_pdf_file TYPE fpformoutput. | ||
+ | |||
+ | *...Opciones de salida impresión | ||
+ | wa_output-device = 'PRINTER'. | ||
+ | * wa_output-dest = 'PDF1'. | ||
+ | wa_output-cover = 'D'. | ||
+ | wa_output-receiver = sy-uname. | ||
+ | wa_output-reqnew = abap_true. | ||
+ | wa_output-preview = abap_false. | ||
+ | * wa_output-getpdf = space. | ||
+ | wa_output-getpdf = abap_true. | ||
+ | |||
+ | wa_output-nopreview = abap_true. | ||
+ | wa_output-nodialog = abap_true. | ||
+ | wa_output-reqimm = abap_false. | ||
+ | |||
+ | |||
+ | CALL FUNCTION 'FP_JOB_OPEN' | ||
+ | CHANGING | ||
+ | ie_outputparams = wa_output | ||
+ | EXCEPTIONS | ||
+ | cancel = 1 | ||
+ | usage_error = 2 | ||
+ | system_error = 3 | ||
+ | internal_error = 4 | ||
+ | OTHERS = 5. | ||
+ | IF sy-subrc <> 0. | ||
+ | p_subrc = 1. | ||
+ | RETURN. | ||
+ | ENDIF. | ||
+ | |||
+ | TRY. | ||
+ | lv_form_name = 'Z_MI_FORMULARIO'. | ||
+ | CALL FUNCTION 'FP_FUNCTION_MODULE_NAME' | ||
+ | EXPORTING | ||
+ | i_name = lv_form_name | ||
+ | IMPORTING | ||
+ | e_funcname = lv_fm_name. | ||
+ | CATCH cx_fp_api_repository | ||
+ | cx_fp_api_usage | ||
+ | cx_fp_api_internal. | ||
+ | p_subrc = 2. | ||
+ | RETURN. | ||
+ | ENDTRY. | ||
+ | |||
+ | CALL FUNCTION lv_fm_name | ||
+ | EXPORTING | ||
+ | * /1bcdwb/docparams = wa_docparams | ||
+ | gs_datos = p_data | ||
+ | IMPORTING | ||
+ | /1bcdwb/formoutput = ls_pdf_file | ||
+ | EXCEPTIONS | ||
+ | usage_error = 1 | ||
+ | system_error = 2 | ||
+ | internal_error = 3 | ||
+ | OTHERS = 4. | ||
+ | IF sy-subrc NE 0. | ||
+ | p_subrc = 3. | ||
+ | RETURN. | ||
+ | ENDIF. | ||
+ | |||
+ | CALL FUNCTION 'FP_JOB_CLOSE' | ||
+ | IMPORTING | ||
+ | e_result = wa_result | ||
+ | EXCEPTIONS | ||
+ | usage_error = 1 | ||
+ | system_error = 2 | ||
+ | internal_error = 3 | ||
+ | OTHERS = 4. | ||
+ | IF sy-subrc <> 0. | ||
+ | p_subrc = 4. | ||
+ | RETURN. | ||
+ | ENDIF. | ||
+ | |||
+ | p_xstring = ls_pdf_file-pdf. | ||
+ | * READ TABLE wa_result-spoolids INTO DATA(wa_spoolids) INDEX 1. | ||
+ | * CHECK sy-subrc = 0. | ||
+ | * | ||
+ | ** Get merged document | ||
+ | * DATA l_xstring TYPE xstring. | ||
+ | * CLEAR l_xstring. | ||
+ | * CALL FUNCTION 'RSPO_GET_MERGED_PDF_FROM_SPOOL' | ||
+ | * EXPORTING | ||
+ | * spool_number = wa_spoolids | ||
+ | * IMPORTING | ||
+ | * merged_document = l_xstring | ||
+ | * EXCEPTIONS | ||
+ | * internal_error = 1 | ||
+ | * empty_job = 2 | ||
+ | * not_supported = 3 | ||
+ | * OTHERS = 4. | ||
+ | * IF sy-subrc = 0. | ||
+ | * p_xstring = l_xstring. | ||
+ | * ENDIF. | ||
+ | ENDFORM.</nowiki> | ||
+ | ===Ejemplo programa que genera PDF=== | ||
+ | <nowiki> | ||
+ | FORM print_pdf USING p_data TYPE zfi_st_cert | ||
+ | CHANGING p_xstring TYPE xstring | ||
+ | p_subrc TYPE sy-subrc. | ||
+ | DATA: wa_output TYPE sfpoutputparams, | ||
+ | wa_result TYPE sfpjoboutput. | ||
+ | DATA: gs_fp_outputparams TYPE sfpoutputparams, | ||
+ | lv_fm_name TYPE rs38l_fnam, | ||
+ | lv_form_name TYPE fpwbformname, | ||
+ | wa_docparams TYPE sfpdocparams. | ||
+ | DATA ls_pdf_file TYPE fpformoutput. | ||
+ | |||
+ | *...Opciones de salida impresión | ||
+ | wa_output-device = 'PRINTER'. | ||
+ | * wa_output-dest = 'PDF1'. | ||
+ | wa_output-cover = 'D'. | ||
+ | wa_output-receiver = sy-uname. | ||
+ | wa_output-reqnew = abap_true. | ||
+ | wa_output-preview = abap_false. | ||
+ | * wa_output-getpdf = space. | ||
+ | wa_output-getpdf = abap_true. | ||
+ | |||
+ | wa_output-nopreview = abap_true. | ||
+ | wa_output-nodialog = abap_true. | ||
+ | wa_output-reqimm = abap_false. | ||
+ | |||
+ | CALL FUNCTION 'FP_JOB_OPEN' | ||
+ | CHANGING | ||
+ | ie_outputparams = wa_output | ||
+ | EXCEPTIONS | ||
+ | cancel = 1 | ||
+ | usage_error = 2 | ||
+ | system_error = 3 | ||
+ | internal_error = 4 | ||
+ | OTHERS = 5. | ||
+ | IF sy-subrc <> 0. | ||
+ | p_subrc = 1. | ||
+ | RETURN. | ||
+ | ENDIF. | ||
+ | |||
+ | TRY. | ||
+ | lv_form_name = 'ZFI_AF_CERT'. | ||
+ | CALL FUNCTION 'FP_FUNCTION_MODULE_NAME' | ||
+ | EXPORTING | ||
+ | i_name = lv_form_name | ||
+ | IMPORTING | ||
+ | e_funcname = lv_fm_name. | ||
+ | CATCH cx_fp_api_repository | ||
+ | cx_fp_api_usage | ||
+ | cx_fp_api_internal. | ||
+ | p_subrc = 2. | ||
+ | RETURN. | ||
+ | ENDTRY. | ||
+ | |||
+ | CALL FUNCTION lv_fm_name | ||
+ | EXPORTING | ||
+ | i_cert_data = p_data | ||
+ | IMPORTING | ||
+ | /1bcdwb/formoutput = ls_pdf_file | ||
+ | EXCEPTIONS | ||
+ | usage_error = 1 | ||
+ | system_error = 2 | ||
+ | internal_error = 3 | ||
+ | OTHERS = 4. | ||
+ | IF sy-subrc NE 0. | ||
+ | p_subrc = 3. | ||
+ | RETURN. | ||
+ | ENDIF. | ||
+ | |||
+ | CALL FUNCTION 'FP_JOB_CLOSE' | ||
+ | IMPORTING | ||
+ | e_result = wa_result | ||
+ | EXCEPTIONS | ||
+ | usage_error = 1 | ||
+ | system_error = 2 | ||
+ | internal_error = 3 | ||
+ | OTHERS = 4. | ||
+ | IF sy-subrc <> 0. | ||
+ | p_subrc = 4. | ||
+ | RETURN. | ||
+ | ENDIF. | ||
+ | |||
+ | p_xstring = ls_pdf_file-pdf. | ||
+ | |||
+ | ENDFORM.</nowiki> | ||
+ | |||
+ | ===Para ver PDF generado=== | ||
+ | <nowiki>if lv_xstring is NOT INITIAL. | ||
+ | CALL FUNCTION '/IPRO/VIEW_PDF' | ||
+ | EXPORTING | ||
+ | iv_title = 'Certificado' | ||
+ | iv_content = lv_xstring. | ||
+ | endif.</nowiki> | ||
+ | |||
+ | ==Notas== | ||
+ | ===Verificar configuración Adobe en ABAP=== | ||
+ | Programa FP_TEST_00 | ||
+ | ===Para limpiar la caché de Adobe Form, puedes hacer lo siguiente:=== | ||
+ | *Activar Adobe Forms | ||
+ | *Ir a un nuevo modo en TRX SE37 | ||
+ | *Llamar al módulo de función IQS1_REFRESH_ALL |
Latest revision as of 20:56, 9 June 2024
Contents
Ejemplo programa de impresión
FORM print_pdf USING p_data TYPE zestruc_mi_formulario CHANGING p_xstring TYPE xstring p_subrc TYPE sy-subrc. DATA: wa_output TYPE sfpoutputparams, wa_result TYPE sfpjoboutput. DATA: gs_fp_outputparams TYPE sfpoutputparams, lv_fm_name TYPE rs38l_fnam, lv_form_name TYPE fpwbformname, wa_docparams TYPE sfpdocparams. DATA ls_pdf_file TYPE fpformoutput. *...Opciones de salida impresión wa_output-device = 'PRINTER'. * wa_output-dest = 'PDF1'. wa_output-cover = 'D'. wa_output-receiver = sy-uname. wa_output-reqnew = abap_true. wa_output-preview = abap_false. * wa_output-getpdf = space. wa_output-getpdf = abap_true. wa_output-nopreview = abap_true. wa_output-nodialog = abap_true. wa_output-reqimm = abap_false. CALL FUNCTION 'FP_JOB_OPEN' CHANGING ie_outputparams = wa_output EXCEPTIONS cancel = 1 usage_error = 2 system_error = 3 internal_error = 4 OTHERS = 5. IF sy-subrc <> 0. p_subrc = 1. RETURN. ENDIF. TRY. lv_form_name = 'Z_MI_FORMULARIO'. CALL FUNCTION 'FP_FUNCTION_MODULE_NAME' EXPORTING i_name = lv_form_name IMPORTING e_funcname = lv_fm_name. CATCH cx_fp_api_repository cx_fp_api_usage cx_fp_api_internal. p_subrc = 2. RETURN. ENDTRY. CALL FUNCTION lv_fm_name EXPORTING * /1bcdwb/docparams = wa_docparams gs_datos = p_data IMPORTING /1bcdwb/formoutput = ls_pdf_file EXCEPTIONS usage_error = 1 system_error = 2 internal_error = 3 OTHERS = 4. IF sy-subrc NE 0. p_subrc = 3. RETURN. ENDIF. CALL FUNCTION 'FP_JOB_CLOSE' IMPORTING e_result = wa_result EXCEPTIONS usage_error = 1 system_error = 2 internal_error = 3 OTHERS = 4. IF sy-subrc <> 0. p_subrc = 4. RETURN. ENDIF. p_xstring = ls_pdf_file-pdf. * READ TABLE wa_result-spoolids INTO DATA(wa_spoolids) INDEX 1. * CHECK sy-subrc = 0. * ** Get merged document * DATA l_xstring TYPE xstring. * CLEAR l_xstring. * CALL FUNCTION 'RSPO_GET_MERGED_PDF_FROM_SPOOL' * EXPORTING * spool_number = wa_spoolids * IMPORTING * merged_document = l_xstring * EXCEPTIONS * internal_error = 1 * empty_job = 2 * not_supported = 3 * OTHERS = 4. * IF sy-subrc = 0. * p_xstring = l_xstring. * ENDIF. ENDFORM.
Ejemplo programa que genera PDF
FORM print_pdf USING p_data TYPE zfi_st_cert CHANGING p_xstring TYPE xstring p_subrc TYPE sy-subrc. DATA: wa_output TYPE sfpoutputparams, wa_result TYPE sfpjoboutput. DATA: gs_fp_outputparams TYPE sfpoutputparams, lv_fm_name TYPE rs38l_fnam, lv_form_name TYPE fpwbformname, wa_docparams TYPE sfpdocparams. DATA ls_pdf_file TYPE fpformoutput. *...Opciones de salida impresión wa_output-device = 'PRINTER'. * wa_output-dest = 'PDF1'. wa_output-cover = 'D'. wa_output-receiver = sy-uname. wa_output-reqnew = abap_true. wa_output-preview = abap_false. * wa_output-getpdf = space. wa_output-getpdf = abap_true. wa_output-nopreview = abap_true. wa_output-nodialog = abap_true. wa_output-reqimm = abap_false. CALL FUNCTION 'FP_JOB_OPEN' CHANGING ie_outputparams = wa_output EXCEPTIONS cancel = 1 usage_error = 2 system_error = 3 internal_error = 4 OTHERS = 5. IF sy-subrc <> 0. p_subrc = 1. RETURN. ENDIF. TRY. lv_form_name = 'ZFI_AF_CERT'. CALL FUNCTION 'FP_FUNCTION_MODULE_NAME' EXPORTING i_name = lv_form_name IMPORTING e_funcname = lv_fm_name. CATCH cx_fp_api_repository cx_fp_api_usage cx_fp_api_internal. p_subrc = 2. RETURN. ENDTRY. CALL FUNCTION lv_fm_name EXPORTING i_cert_data = p_data IMPORTING /1bcdwb/formoutput = ls_pdf_file EXCEPTIONS usage_error = 1 system_error = 2 internal_error = 3 OTHERS = 4. IF sy-subrc NE 0. p_subrc = 3. RETURN. ENDIF. CALL FUNCTION 'FP_JOB_CLOSE' IMPORTING e_result = wa_result EXCEPTIONS usage_error = 1 system_error = 2 internal_error = 3 OTHERS = 4. IF sy-subrc <> 0. p_subrc = 4. RETURN. ENDIF. p_xstring = ls_pdf_file-pdf. ENDFORM.
Para ver PDF generado
if lv_xstring is NOT INITIAL. CALL FUNCTION '/IPRO/VIEW_PDF' EXPORTING iv_title = 'Certificado' iv_content = lv_xstring. endif.
Notas
Verificar configuración Adobe en ABAP
Programa FP_TEST_00
Para limpiar la caché de Adobe Form, puedes hacer lo siguiente:
- Activar Adobe Forms
- Ir a un nuevo modo en TRX SE37
- Llamar al módulo de función IQS1_REFRESH_ALL