Excel attachment not attached in Workflow
Florin Wach
florin.wach at gmx.net
Tue Apr 28 02:10:27 EDT 2009
Hi Arghadip,
you'll need to use the new key word
READ DATASET v_fileName INTO i_solix ACTUAL LENGTH i_bytes_read.
The sy-subrc = 0 when 255 could be fully read, otherwise it is 4. So the condition IF sy-subrc = 0 shouldn't be used with binary mode.
IF i_bytes_read > 0.
APPEND i_solix.
ELSE.
CLOSE DATASET v_fileName.
EXIT. "from DO-loop
ENDIF.
To calculate the bytes fully read, us the following statement.
DESCRIBE TABLE i_solix LINES sy-tfill.
i_filesize = ( sy-tfill - 1 ) * 255.
ADD i_bytes_read TO i_filesize.
More-or-less: This should do the work.
Best wishes,
Florin
-------- Original-Nachricht --------
> Datum: Mon, 27 Apr 2009 16:02:32 -0700 (PDT)
> Von: arghadip kar <arghadipkar at yahoo.com>
> An: sap-wug at mit.edu
> Betreff: Excel attachment not attached in Workflow
> Hi
>
> I have a strange case where the excel attachment that I am retriveing from
> the Portal is not getting attached to workflow properly. the Bytesize is
> getting truncated with a multiple of 255. Here is the small portion of the
> code attached.
>
> * retrieve the file from app server that was saved by portal
> open dataset v_filename for input in binary mode.
> if sy-subrc eq 0.
> do.
> read dataset v_filename into i_solix.
> if sy-subrc eq 0.
> append i_solix.
> else.
> exit.
> endif.
> enddo.
> close dataset v_filename.
> endif.
> * get the index of the binary table
> clear v_tab_lines.
> describe table i_solix lines v_tab_lines. "get index
> read table i_solix into v_wa_solix index v_tab_lines.
>
> "read last line into buffer
> * determine the total file size in birnary format
> v_doc_size = ( 255 * v_tab_lines ). "whole lines
> * convert binary to xstring
> call function 'SCMS_BINARY_TO_XSTRING'
> exporting
> input_length = v_doc_size
> importing
> buffer = v_xstring
> Tables
> binary_tab = i_solix.
> document file attributes
> get the extension name
> v_offset = strlen( v_docname_only ) - 3.
> v_doc_extension = v_docname_only+v_offset(3).
> v_att_header-file_type = 'B'.
> v_att_header-file_name = v_docname_only.
> v_att_header-file_extension = v_doc_extension.
> v_att_header-language = sy-langu.
> call function 'SAP_WAPI_ATTACHMENT_ADD'
> exporting
> workitem_id = v_workitemid
> att_header = v_att_header
> ATT_TXT =
> att_bin = v_xstring
> DOCUMENT_OWNER = SY-UNAME
> LANGUAGE = SY-LANGU
> DO_COMMIT = 'X'
> importing
> * RETURN_CODE =
> att_id = v_att_id
> * TABLES
> * MESSAGE_LINES =
> * MESSAGE_STRUCT =
> .
> * pass attachment id and internal document number for SOFM
> swc_set_element container 'ATT_ID' v_att_id.
> swc_set_element container 'SOFM' v_att_id-doc_id.
> endif.
>
> Suppose the Byte size is 18992 the v_doc_size is 18870. Can you please
> check what is the issue.When we try to read the attachment we get the file is
> damaged and on cancelling the file appears but the byte size is truncated.
>
> Thanks
> Arghadip
> SAP Workflow Expert
> IBM India
>
>
>
More information about the SAP-WUG
mailing list