Skip to Content

Save PR Approval Remarks to ECC using /IWWRK/BADI_WF_BEFORE_UPD_IB

Dear Expert,

We are on S/4 HANA 1610.

We are using the BADI /IWWRK/BADI_WF_BEFORE_UPD_IB to update the comments entered by the approver back to PR transaction text at header level "B02".


The issue here is the code is executed with out any errors ,but unable to see the text in ME52N/ME54N ,kindly help us in resolving the issue here i am attaching the source code also.we have checked using an external break point the on giving comments the source code is triggered and executed with no failures .

READ TABLE it_wf_container_tab WITH KEY element = 'ACTION_COMMENTS'
INTO ls_wf_container.
IF sy-subrc = 0.
* ls_request-CURR_NOTICE = ls_wf_container-VALUE.
SPLIT ls_wf_container-value AT '#' INTO TABLE it_string .

"Access the workflow data
CALL FUNCTION 'SAP_WAPI_GET_OBJECTS'
EXPORTING
workitem_id = is_wi_details-wi_id
IMPORTING
leading_object_2 = ls_object.


* read existing text
l_thead-tdid = 'B02'.
l_thead-tdname = ls_object-INSTID.
l_thead-tdobject = 'EBANH'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = l_thead-tdid
language = sy-langu
name = l_thead-tdname
object = l_thead-tdobject
IMPORTING
header = l_thead
TABLES
lines = lt_tline
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.

*Initialize the text before updating.
CALL FUNCTION 'INIT_TEXT'
EXPORTING
id = l_thead-tdid
language = sy-langu
name = l_thead-tdname
object = l_thead-tdobject
IMPORTING
header = l_thead
TABLES
lines = lt_tline
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.

* append new text
LOOP AT it_string INTO wa_string .
at FIRST.
CONCATENATE 'USER-' sy-uname 'Date-' sy-datum+6(2) '.'
sy-datum+4(2) '.' sy-datum+0(4)
INTO l_tline-tdline SEPARATED BY space.
APPEND l_tline TO lt_tline.
clear l_tline.
ENDAT.
l_tline-tdline = wa_string-str.
APPEND l_tline TO lt_tline.
ENDLOOP.

* save text back to PR
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = l_thead
IMPORTING
function = l_txfunction
TABLES
lines = lt_tline
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc eq 0.
COMMIT WORK AND WAIT.
ENDIF.

ENDIF.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Jul 23, 2018 at 04:30 PM

    Hi Pavan,

    Please see code in below blog, we achieved adding approval comments to header text and its working fine. Hope it helps.

    https://blogs.sap.com/2018/07/23/fiori-my-inbox-app-custom-purchase-requisition-workflow/

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 25, 2018 at 04:37 AM

    Dear Kapil Changrani,

    Thanks your response ,we are using the different workflow scenario ,but the FM INSERT_TEXT_AFTER_COMMIT helped us to achieve the output.

    Replaced SAVE_TEXT with INSERT_TEXT_AFTER_COMMIT in my code.


    Regards,

    Pavan

    Add comment
    10|10000 characters needed characters exceeded