on 10-19-2018 6:37 PM
I need help,
I'm trying to attach an adobe form pdf as "maintain order" attachment.I already did it but some PDF are correct and others are corrupt.
If I previsulized the pdf after generate it, all the documents looks right, but at the moment to transform the pdf to binary table for attach the document to an order, when I see the attachment some are corrupts.
I think is the problem is at the moment of convertion
Code:
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name = form
IMPORTING
e_funcname = fm_name.
CLEAR fp_outputparams.
** Set output parameters and open spool job
fp_outputparams-preview = space. " do not launch print preview
fp_outputparams-nodialog = 'X'. " suppress print dialog
fp_outputparams-dest = 'LP01'. " set del dispositivo de salida
fp_outputparams-getpdf = 'X'.
CLEAR sy-cprog.
CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
ie_outputparams = fp_outputparams
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 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.
* Now call the generated function module
CALL FUNCTION fm_name
EXPORTING
/1bcdwb/docparams = fp_docparams
i_salida = ls_salida
i_firma = gv_firma
i_fotos = gt_fotos
i_repuestos = lt_repuestos
i_servicios = lt_servicios
i_descripcion = lt_descripcion
IMPORTING
/1bcdwb/formoutput = fp_result
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
CALL FUNCTION 'FP_GET_LAST_ADS_ERRSTR'
IMPORTING
e_adserrstr = error_string.
IF NOT error_string IS INITIAL.
* we received a detailed error description
WRITE:/ error_string.
EXIT.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
* Close spool job
CALL FUNCTION 'FP_JOB_CLOSE'
EXCEPTIONS
usage_error = 1
system_error = 2
internal_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.
ENDIF.
"FIN ADOBE FORM
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = fp_result-pdf
TABLES
BINARY_TAB = lv_binary_file.
CALL FUNCTION 'ZPM_UPLOAD_COMPTRAB_PDF'
EXPORTING
i_aufnr = gv_num_orden
it_form = lv_binary_file. "li_content_hex.
COMMIT WORK AND WAIT.
*********************************************
--------------------------------------------------------------------
*"*"Interfase local
*" IMPORTING
*" REFERENCE(I_AUFNR) TYPE AUFNR
*" REFERENCE(IT_FORM) TYPE SOLIX_TAB
*"--------------------------------------------------------------------
* Include for BO macros
INCLUDE : <cntn01>.
* Load class.
CLASS cl_binary_relation DEFINITION LOAD.
CLASS cl_obl_object DEFINITION LOAD.
TYPES: BEGIN OF type_message_key,
foltp TYPE so_fol_tp,
folyr TYPE so_fol_yr,
folno TYPE so_fol_no,
doctp TYPE so_doc_tp,
docyr TYPE so_doc_yr,
docno TYPE so_doc_no,
fortp TYPE so_for_tp,
foryr TYPE so_for_yr,
forno TYPE so_for_no,
END OF type_message_key.
DATA: lc_doctype TYPE sibftypeid VALUE 'MESSAGE',
lc_message_type TYPE so_doc_tp VALUE 'EXT',
lc_relation_type TYPE oblreltype VALUE 'ATTA'.
* Binary contents
DATA: lt_data TYPE STANDARD TABLE OF solix WITH HEADER LINE,
lv_message_key TYPE type_message_key,
lo_message TYPE swc_object,
lv_filename_wo_ext TYPE string,
lv_file_doctype TYPE string.
**----------------------------------------------------------------*
*
** Create an initial instance of BO 'MESSAGE' - to call the
** instance-independent method 'Create'.
swc_create_object lo_message 'MESSAGE' lv_message_key.
** define container to pass the parameter values to the method call
** in next step.
swc_container lt_message_container.
** Populate container with parameters for method
swc_set_element lt_message_container 'DOCUMENTTITLE' 'Comprobante Trabajo'.
swc_set_element lt_message_container 'DOCUMENTLANGU' 'E'.
swc_set_element lt_message_container 'NO_DIALOG' 'X'.
swc_set_element lt_message_container 'DOCUMENTNAME' lc_doctype.
swc_set_element lt_message_container 'DOCUMENTTYPE' lc_message_type.
swc_set_element lt_message_container 'DOCUMENTTYPE' 'PDF'.
*swc_set_element lt_message_container 'DocumentContent' lt_doc_content.
swc_set_table lt_message_container 'Content_Hex' it_form.
swc_call_method lo_message 'CREATE' lt_message_container.
*
** Refresh to get the reference of create 'MESSAGE' object for attachment
swc_refresh_object lo_message.
*
** Get Key of new object
swc_get_object_key lo_message lv_message_key.
*
** Now we have attachment as a business object instance. We can now
** attach it to our main business object instance.
*
** Create main BO object_a
DATA: lo_is_object_a TYPE sibflporb.
lo_is_object_a-instid = i_aufnr.
lo_is_object_a-typeid = 'BUS2007'.
lo_is_object_a-catid = 'BO'.
*
** Create attachment BO object_b
DATA: lo_is_object_b TYPE sibflporb.
lo_is_object_b-instid = lv_message_key.
lo_is_object_b-typeid = lc_doctype.
lo_is_object_b-catid = 'BO'.
*
**TRY.
CALL METHOD cl_binary_relation=>create_link
EXPORTING
is_object_a = lo_is_object_a
* IP_LOGSYS_A =
is_object_b = lo_is_object_b
* IP_LOGSYS_B =
ip_reltype = lc_relation_type
* IP_PROPNAM =
* I_PROPERTY =
* IMPORTING
* EP_LINK_ID =
* EO_PROPERTY =
.
**CATCH CX_OBL_PARAMETER_ERROR .
**CATCH CX_OBL_MODEL_ERROR .
**CATCH CX_OBL_INTERNAL_ERROR .
**ENDTRY.
*
** Check if everything OK...who cares!!
COMMIT WORK.
*
ENDFUNCTION.<br>
never had issues with the xtring_to_binary function. Sure that everything is correct during processing the form? MAybe you can switch device-types.
I would recommend you save the xtring somewhere and try to get one case, where you have the unconverted file to see, if there is something special processed inside the form.
I had also some strange things in front, but always the reason was something coded inside the form.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Florian, inside the form the only thing that I never worked with is with images and for this opportunity we handle 3 or more images always.
Also when I tried to open a corrupt pdf in another adobe reader alternative software, in example Google Chrome, the pdf is opened and diplayed ok (everything looks in place).
I don't know what to do.
A question ... when you say device type, do you mean the printer??
Thanks
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.