Skip to Content
0
Jun 01 at 04:10 PM

Note able to open the FBV2 PDF attachment. Show error as file can't open .

114 Views

I attached a PDF file from AL11(Application Server) to Parked Document. But while opening the Parked document in the attachment list the PDF file is displaying , but while trying to open, it is showing the the below error.

Below is the program and the source code i used it. Any error in that, Kindly suggest me.

OPEN DATASET lv_file FOR INPUT IN BINARY MODE.
READ DATASET lv_file INTO lv_xstring.
IF sy-subrc NE 0.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xstring
* APPEND_TO_TABLE = ' '
IMPORTING
output_length = lv_length
TABLES
binary_tab = lt_pdfout .
EXIT.
ENDIF.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xstring "ls_pdfout-line
* APPEND_TO_TABLE = ' '
IMPORTING
output_length = lv_length
TABLES
binary_tab = lt_pdfout .

CLOSE DATASET lv_file.

CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
* OWNER = ' '
region = 'B'
IMPORTING
folder_id = ls_fol_id
EXCEPTIONS
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
OTHERS = 5 .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

DATA(ls_object) = VALUE borident( objkey = ls_files2-name && ls_files1-name+0(14) objtype = 'BKPF' )."'FIPP' ).
DATA(lv_filename) = ls_files1-name.
DATA(lv_filepath) = p_dir.
SPLIT lv_filename AT '.' INTO DATA(lv_strip) DATA(lv_extension).
DATA(ls_obj_data) = VALUE sood1( objsns = 'O' objla = sy-langu objdes = ls_files1-name file_ext = lv_extension objlen = lv_length )."lines( lt_pdfout ) * 255 ).

TRANSLATE ls_obj_data-file_ext TO UPPER CASE.

* Insert data
CALL FUNCTION 'SO_OBJECT_INSERT'
EXPORTING
folder_id = ls_fol_id
object_type = 'EXT'
object_hd_change = ls_obj_data
IMPORTING
object_id = ls_obj_id
TABLES
objhead = ls_objhead
objcont = lt_pdfout
EXCEPTIONS
active_user_not_exist = 1
communication_failure = 2
component_not_available = 3
dl_name_exist = 4
folder_not_exist = 5
folder_no_authorization = 6
object_type_not_exist = 7
operation_no_authorization = 8
owner_not_exist = 9
parameter_error = 10
substitute_not_active = 11
substitute_not_defined = 12
system_failure = 13
x_error = 14
OTHERS = 15.

IF sy-subrc = 0 AND
ls_object-objkey IS NOT INITIAL.

DATA(ls_folmem_k) = VALUE sofmk( foltp = ls_fol_id-objtp folyr = ls_fol_id-objyr folno = ls_fol_id-objno
doctp = ls_obj_id-objtp docyr = ls_obj_id-objyr docno = ls_obj_id-objno ).

DATA(lv_ep_note) = ls_folmem_k.
DATA(ls_note) = VALUE borident( objtype = 'MESSAGE' objkey = lv_ep_note ).

* Link it
CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'
EXPORTING
obj_rolea = ls_object
obj_roleb = ls_note
relationtype = 'ATTA'
EXCEPTIONS
no_model = 1
internal_error = 2
unknown = 3
OTHERS = 4.
IF sy-subrc EQ 0.
COMMIT WORK.
WRITE:/ 'Attached successfully'.
ENDIF.
ELSE.
MESSAGE 'Error while opening file' TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.

Attachments

httox.png (18.5 kB)