on 02-22-2022 6:46 AM
Hi ,
Like we add attachments to user decision step in workflow , i need to add a comment entry which was created as a note in request screen comment section.
Using code shown below i am only able to add comments as a text file in attachment section.
Let me know if any issues in below code
*Add comments from request screen to workitem
DATA: lv_atthdr TYPE swr_att_header,
lv_return_code TYPE sy-subrc,
lv_wid TYPE swr_struct-workitemid,
lv_att_id TYPE swr_att_id,
lv_str TYPE string.
* CLEAR: lt_obj.
* construct attachment header
IF ls_wfh-reason IS NOT INITIAL.
lv_atthdr-file_type = 'T'.
lv_atthdr-file_name = 'Request comments by' && '' && ls_wfh-userid.
lv_atthdr-file_extension = 'TXT'.
lv_atthdr-language = sy-langu.
lv_str = ls_wfh-reason.
lv_wid = ls_wfh-wid.
CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
EXPORTING
workitem_id = lv_wid
att_header = lv_atthdr
att_txt = lv_str
document_owner = ls_wfh-userid
language = sy-langu
* do_commit = ' '
comment_semantic = 'X'
IMPORTING
return_code = lv_return_code
att_id = lv_att_id.
**& Creating sofm object
CALL FUNCTION 'SWO_CREATE'
EXPORTING
objtype = 'SOFM'
objkey = CONV swo_typeid( lv_att_id-doc_id )
IMPORTING
object = lo_sofmn
EXCEPTIONS
no_remote_objects = 1
OTHERS = 2.
IF sy-subrc = 0.
*& Prepare for attaching the object to container
ls_obj-header = 'OBJH'.
ls_obj-type = 'SWO'.
ls_obj-handle = lo_sofmn.
APPEND ls_obj TO lt_obj[].
ENDIF.
ENDIF.
IF lt_obj IS NOT INITIAL.
* *& Finally send the attachment details in the task container
TRY.
CALL METHOD lo_container->set
EXPORTING
name = '_ATTACH_OBJECTS'
value = lt_obj[].
CATCH cx_swf_cnt_container .
RAISE EXCEPTION TYPE cx_swf_ifs_workitem_exit_error.
ENDTRY.
ENDIF.
*& Commit the changes
CALL METHOD im_workitem_context->do_commit_work.
File name was changed from
lv_atthdr-file_name = 'Request comments by' && '' && ls_wfh-userid.
to
lv_atthdr-file_name = 'User Comments'.
After this comment is appearing with 'workflow-system's comment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.