Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

PDF file getting corrupted while creating document

Former Member
0 Likes
2,113

Dear experts ,

we are creating DMS document using BAPI_DOCUMENT_CREATE2 , its all working fine in DEV and Quality system but in production system in case of PDF file bapi is returning success message , but user is not able to display or see the document , getting an error saying 'There was an error opening this document. The file is damagedand could not be repaired'.

my fuction module getting call from java webdynpro application , I have doubt on the OPEN DATASET statments

I am using below code to transfer data to application server ,

IF iv_file_path IS NOT INITIAL.

SPLIT iv_file_path AT '.' INTO lv_filename lv_ext.

CALL FUNCTION 'CV120_DOC_GET_APPL'

EXPORTING

pf_file = iv_file_path

IMPORTING

pfx_dappl = lv_file_type.

TRANSLATE lv_file_type TO UPPER CASE.

OPEN DATASET log FOR OUTPUT IN BINARY MODE

TRANSFER lv_ext TO log.

ls_documentfiles-wsapplication = lv_file_type.

TRANSLATE ls_documentfiles-wsapplication TO UPPER CASE.

CONCATENATE

lv_filename

'.'

lv_ext

INTO lv_file_name.

CONDENSE lv_file_name NO-GAPS.

TRANSFER lv_file_name TO log.

OPEN DATASET lv_file_name FOR OUTPUT IN BINARY MODE MESSAGE lv_msg.

**Transfer Attachment Content to Application Server

TRANSFER iv_file_data TO lv_file_name.

CLOSE DATASET lv_file_name.

Please help

5 REPLIES 5
Read only

Former Member
0 Likes
1,234

After convert PDF file you have to use following FM the u send file.


DATA: pdf TYPE REF TO cl_hrasr00_pdf_generation.
  DATA : lt_data            TYPE solix_tab.

  OPEN DATASET filename FOR INPUT IN BINARY MODE.
  IF sy-subrc EQ 0.
    READ DATASET filename INTO filex.

  ENDIF.

  IF filex IS NOT INITIAL.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer        = filex
      IMPORTING
        output_length = file_length
      TABLES
        binary_tab    = gt_objbin.
  ENDIF.
  CLOSE DATASET filename.

Read only

0 Likes
1,234

Hi Kripaji , thnaks for reply ,

why you are usin 'SCMS_XSTRING_TO_BINARY function module in your code

In my case I am creating document using all type of file and not the only PDF , and getting document corruption error in standard transaction CV04n

Read only

0 Likes
1,234

Tell Which FM you use to convert into PDF?

Read only

0 Likes
1,234

I am uploading file to application server without converting it into PDF , then using bapi BAPI_DOCUMENT_CREATE2 to create document into DMS , and its working fine in development and qaulity system , but not in production

Read only

0 Likes
1,234

Hi All

any body has any that whene we write OPEN DATASET lv_file_name FOR OUTPUT IN BINARY MODE MESSAGE lv_msg

then in case of PDF file do we need to write somthing extra in open dataset command like ENCODING , CODE PAGE etc