Hi Workflow experts,
I am trying to add an xls attachment to workflow workitem id, later i want to send this attachment in the approval work item step.
I created an activity step and in the BO object method- "Add_attachment_to_wi" i have written below code.
*Get the workitem id
swc_get_element container 'WORKITEMID' lv_workitemid.
*Fetching the xls file template stored in Mime repository
DATA:lr_api TYPE REF TO if_mr_api.
* Read the file from Mime repository into XSTRING format
lr_api = cl_mime_repository_api=>get_api( ).
lr_api->get(
EXPORTING
i_url = lv_path
IMPORTING
e_content = lv_file_xstring
EXCEPTIONS
parameter_missing = 1
error_occured = 2
not_found = 3
permission_failure = 4
OTHERS = 5
).
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
* Fill Attachment Header
ls_att_header-file_name = 'xyz template'.
ls_att_header-file_type = 'B'. "Binary
ls_att_header-file_extension = 'XLS'.
ls_att_header-language = sy-langu.
* Add attachment
CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
EXPORTING
workitem_id = lv_workitemid
att_header = ls_att_header
att_bin = lv_file_xstring "Passing the document content which is in XSTRING format
document_owner = sy-uname
language = sy-langu
do_commit = 'X'
IMPORTING
return_code = lv_subrc
att_id = ls_att_id
TABLES
message_lines = lt_msglin
message_struct = lt_msgstr.
***************************************************
I am expecting the above piece of code will add attachment to workflow container _ATTACH_OBJECTS.
When i am executing my BO method to add attachment giving any existing workitem id of the workflow instance, then it is successfully
adding the entry in _ATTACH_OBJECTS container of that workflow instance.
But in my workflow instance, it is not adding the attachment into the workflow container _Attach_objects.
When i check the output message lt_msglin, this shows an error message
"No attachment specified" Message class SWR Message number 217. This message will be raised inside function module SAP_WAPI_ATTACHMENT_ADD when the Header of the document is blank.
In my case i am filling the document header details in input structure "ls_att_header" but dont know why it is still giving this error message saying Header details are blank and not adding the attachment to workitem.
Please suggest.... it is very strange issue which i am facing.
Regards,
Chetan S K