cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with attaching pdf in work item

Former Member
0 Kudos

Dear Friends,

I am trying to attach Adobe form output to a work item and send it in for approval. I have converted the Adobe form output to binary format inside the program using function module 'SCMS_XSTRING_TO_BINARY and passed it to the workflow container while starting the workflow and then inside the workflow i used the below code inside a method convert the binary to xstring format and then attach it to the workitem. But when I open the attachment from business workplace I am getting an error that There was an error opening this document, the file is damaged and could not be repaired.

I tried to debug the method and found that everything seems to be fine, even I checked the Adobe output by sending it as an email attachment and I am able to open the same Adobe form attachment in the email. So I suspect that I am doing something wrong while converting the same(binary to xstring) in the workflow. Please advise what would be wrong with the below code.

DATA: wid TYPE swwwihead-wi_id,

op_len TYPE wsuser-wsuserinstanceno,

it_solix_tab TYPE solix-line OCCURS 0.

DATA : zswr_att_header TYPE swr_att_header,

zswr_att_id TYPE swr_att_id,

lo_sofm TYPE swc_object,

zxstring TYPE xstring.

swc_get_element container 'WID' wid.

swc_get_element container 'OP_LEN' op_len.

swc_get_table container 'IT_SOLIX_TAB' it_solix_tab.

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

EXPORTING

input_length = op_len

IMPORTING

buffer = zxstring

TABLES

binary_tab = it_solix_tab.

zswr_att_header-file_type = 'B'.

zswr_att_header-file_name = 'Attachment.pdf'.

zswr_att_header-file_extension = 'PDF'.

zswr_att_header-language = 'EN'.

BREAK-POINT.

CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'

EXPORTING

workitem_id = wid

att_header = zswr_att_header

att_bin = zxstring

IMPORTING

att_id = zswr_att_id.

swc_create_object lo_sofm 'SOFM' zswr_att_id-doc_id.

swc_set_element container 'SOFM' lo_sofm.

Accepted Solutions (0)

Answers (3)

Answers (3)

Kishore
Participant
0 Kudos

Hi,

Were you able to solve this issue?

I am having the same problem.

Thanks,

Kishore.

Former Member
0 Kudos

Hi SAPTechies,

now i am the same problem, how did you fix it?

if you have solved it

thank's

Daniele

bpawanchand
Active Contributor
0 Kudos

Hi

I feel like this part of teh code might be creating a a problem.


zswr_att_header-file_type = 'B'.
zswr_att_header-file_name = 'Attachment.pdf'.   "<------ Just give the name of the file , no extension needed as .pdf"
zswr_att_header-file_extension = 'PDF'.              " <---- Since here you are already specifying the type of file.
zswr_att_header-language = 'EN'. 

Regards

Pavan