Hi,
I hope somebody can help me with my problem. I need to copy an attachment from one workflow and then attach it to a different workflow. So far, here's what i have done:
1. I used SAP_WAPI_GET_ATTACHMENTS to get the attachment from the 1st workflow. -
successful
2. I used SO_OBJECT_READ to read the contents of the 1st workflow. -
successful
3. I used SAP_WAPI_ATTACHMENT_ADD to attach the file -
i can't seem to make this FM work, i cant figure out the input to this FM using the data gathered from SO_OBJECT_READ
Here's my code for reference:
DATA: lt_attachments TYPE TABLE OF swr_object,
wa_attachments TYPE swr_object.
DATA: wa_folder_id TYPE soodk,
wa_object_id TYPE soodk,
lt_objcont TYPE TABLE OF soli,
wa_objcont TYPE soli,
lt_objhead TYPE TABLE OF soli,
wa_objhead type soli.
DATA: ly_att_header TYPE SWR_ATT_HEADER,
ly_att_txt TYPE STRING,
ly_att_bin TYPE XSTRING,
ly_att_bin2 TYPE string.
DATA: ly_return_code LIKE sy-subrc.
CALL FUNCTION 'SAP_WAPI_GET_ATTACHMENTS'
EXPORTING
workitem_id = '21433'
USER = SY-UNAME
LANGUAGE = SY-LANGU
TABLES
attachments = lt_attachments.
READ TABLE lt_attachments INTO wa_attachments INDEX 1.
wa_folder_id = wa_attachments-object_id+20(17).
wa_object_id = wa_attachments-object_id+37(17).
CALL FUNCTION 'SO_OBJECT_READ'
EXPORTING
folder_id = wa_folder_id
object_id = wa_object_id
IMPORTING
OBJECT_FL_DISPLAY =
OBJECT_HD_DISPLAY =
OBJECT_RC_DISPLAY =
TABLES
objcont = lt_objcont
objhead = lt_objhead.
LOOP AT lt_objcont INTO wa_objcont.
CONCATENATE ly_att_bin2 wa_objcont INTO ly_att_bin2.
ENDLOOP.
ly_att_bin = ly_att_bin2.
ly_att_txt = 'test'.
ly_att_header-FILE_TYPE = 'B'.
ly_att_header-FILE_NAME = 'Test_Attachment'.
ly_att_header-FILE_EXTENSION = 'XLS'. "------CHANGE!
ly_att_header-LANGUAGE = sy-langu.
CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
EXPORTING
workitem_id = '21510'
att_header = ly_att_header
att_txt = ly_att_txt
att_bin = ly_att_bin
DO_COMMIT = 'X'
IMPORTING
RETURN_CODE = ly_return_code.
Thanks in advance.
Regards,
Dexter