Skip to Content
0

How to configure a custom approval in Fiori My inbox app which is having Activity type task.

May 10, 2017 at 06:11 AM

661

avatar image
Former Member

Hi All,

I am trying to configure SRM central contract approval in Fiori My Inbox app.

I have configured scenario definition in gateway system and Decision step configuration in SRM system.

As the task is not a user decision step, we have implemented the BADI /IWWRK/BADI_WF_BEFORE_UPD_IB for updating status in backend.

Now task is coming to inbox and we are able to approve or reject.

But the workflow is not moving to next step.

Could anyone help us on this.

Thanks in Advance,

Unnikrishnan P K

10 |10000 characters needed characters left characters exceeded
Former Member

Hi All,

Can anyone help me to implement the BADI /IWWRK/BADI_WF_BEFORE_UPD_IB.

Thanks and Regards,

Unnikrishnan P K

0
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Masayuki Sekihara
Jun 12, 2017 at 06:48 AM
0

Hi Unnikrishnan,,

Please check the function module /SAPSRM/FU_WF_RFC_DECISION.

CALL FUNCTION '/SAPSRM/FU_WF_RFC_DECISION'

    EXPORTING

      iv_header_guid   = lv_guid

      iv_mode          = lc_approval

      iv_wiid          = lv_workitem_id

      iv_decision      = lv_decision_cll

      iv_approver      = lv_approver

*     iv_approval_note = lv_comment_base64dec

      iv_approval_note = iv_comment

      iv_approval_type = /sapsrm/if_wf_process_c=>gc_offline_approval_on

    IMPORTING

      return_code      = lv_return_code

    TABLES

      message_lines    = lt_workflow_message

    EXCEPTIONS

      error_in_pdo     = 1.

Regards,

Masa

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Masa,

Thanks a lot.... it is working fine now. It is the perfect solution.

Regards,

Unnikrishnan P K

0
Former Member

Hi Masa,

We are using so_document_read_api1 to fetch comments by passing document_id,But it is throwing message as Document_id_doesnot_exist as the entry is not in sofm table.

I am using Attach_objects element value for this.Please help me here.

Thanks

swetha

0
Masayuki Sekihara
May 17, 2017 at 12:25 PM
0

Hi Unnikrishnan,

You need to look at the workflow log in the backend and find out the root cause.

Regards,

Masa

Show 10 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Masa,

I am attaching the workflow details, after the approve contract step it is going to wrong branch.

I have configured TS40007980 in scenario definition and WS40000016 and step no 293 in Maintain task names and Decision options configurations.

METHOD /iwwrk/if_wf_wi_before_upd_ib~before_update.
DATA:lv_objtype TYPE swr_struct-object_typ,
lv_objkey TYPE swr_struct-object_key,
lv_retcode TYPE sy-subrc.
DATA:ls_object TYPE swr_obj_2,
ls_container_line TYPE swr_cont,
ls_formabs TYPE swxformabs,
lv_boid TYPE string,
lv_name TYPE sy-uname,
l_subrc TYPE sy-subrc.
DATA :lt_container TYPE TABLE OF swr_cont,* DATA : ls_container_line TYPE swr_cont.
lt_msg_lines TYPE sapi_msg_lines,
lt_msg_struc TYPE sapi_msg_struc.DATA formnumber TYPE swxformabs-formnumber.
FIELD-SYMBOLS:
<lf_boid> TYPE swr_cont,
<lf_result> TYPE swr_cont,
<lf_approver> TYPE swr_cont.

CALL FUNCTION 'SAP_WAPI_GET_OBJECTS'EXPORTING
workitem_id = is_wi_details-wi_id* LANGUAGE = SY-LANGU* USER = SY-UNAME* BUFFERED_ACCESS = 'X'IMPORTING* LEADING_OBJECT =
return_code = lv_retcode
leading_object_2 = ls_objectTABLES* OBJECTS =
message_lines = lt_msg_lines
message_struct = lt_msg_struc.
*“3. Get document number
MOVE ls_object-instid TO formnumber.
*4. Get decision resultCALL FUNCTION 'SAP_WAPI_READ_CONTAINER'EXPORTING
workitem_id = is_wi_details-wi_idlanguage = sy-langu
user = sy-uname* IMPORTING* return_code = lv_retcode** IFS_XML_CONTAINER =** IFS_XML_CONTAINER_SCHEMA =TABLES
simple_container = lt_container
message_lines = lt_msg_lines
message_struct = lt_msg_struc** SUBCONTAINER_BOR_OBJECTS =** SUBCONTAINER_ALL_OBJECTS =.IF sy-subrc <> 0.ENDIF.
READ TABLE lt_container WITH KEY element = 'BOID' ASSIGNING <lf_boid>.IF <lf_boid> IS ASSIGNED.
lv_boid = <lf_boid>-value.ENDIF.*read table lt_container with key element = '_RULE_RESULT' assigning <lf_result>.READ TABLE lt_container WITH KEY element = 'AGENT' ASSIGNING <lf_approver>.read table lt_container with key element = '_WI_RESULT' assigning <lf_result>.
* “5. GET application DATASELECT SINGLE * FROM swxformabs INTO ls_formabs WHERE formnumber = lv_boid.
ls_formabs-approvby = sy-uname.
ls_formabs-approvdate = sy-datum.


*** “6. SET decision value to the container.* CASE iv_decision_key.
IF iv_decision_key = 0001.* WHEN 0001.** “approved
ls_container_line-value = 'A'.
ls_formabs-procstate = 'A'.* WHEN 0002.ELSE.** “rejected
ls_container_line-value = 'R'.
ls_formabs-procstate = 'R'.* ENDCASE.
ENDIF.

ls_container_line-element = '_WI_RESULT'.
ls_container_line-value = 'A'.

APPEND ls_container_line TO lt_container.

ls_container_line-element = '_WI_COMP_EVENT_NAME'.
ls_container_line-value = 'EXECUTED'.
APPEND ls_container_line TO lt_container.

ls_container_line-element = '_WI_COMP_EVENT_OBJTYPE'.
ls_container_line-value = '/SAPSRM/CL_WF_DSET_SBWF'.

APPEND ls_container_line TO lt_container.

ls_container_line-element = '_WI_COMP_EVENT_OBJKEY'.
ls_container_line-value = lv_boid.

APPEND ls_container_line TO lt_container.


ls_container_line-element = '_WI_COMP_EVENT_CATID'.
ls_container_line-value = 'CL'.


APPEND ls_container_line TO lt_container.
UPDATE swxformabs FROM ls_formabs.
*if <lf_result> is assigned.* <lf_result>-value = ls_formabs-procstate.* endif.
*CONCATENATE 'US' sy-uname INTO lv_name.
IF <lf_approver> IS ASSIGNED.
<lf_approver>-value = sy-uname.ENDIF.


* MODIFY lt_container INDEX 3 FROM ls_container_line TRANSPORTING value.


CALL FUNCTION 'SAP_WAPI_WRITE_CONTAINER'EXPORTING
workitem_id = is_wi_details-wi_idlanguage = sy-langu
actual_agent = sy-uname
do_commit = 'X'* IFS_XML_CONTAINER =* OVERWRITE_TABLES_SIMPLE_CONT = ' '* .TABLES
simple_container = lt_container
message_lines = lt_msg_lines
message_struct = lt_msg_struc.


*CALL FUNCTION 'SAP_WAPI_DECISION_COMPLETE'* EXPORTING* workitem_id = is_wi_details-wi_id** LANGUAGE = SY-LANGU** USER = SY-UNAME* decision_key = iv_decision_key* do_commit = 'X'** DECISION_NOTE =** CHECK_INBOX_RESTRICTION = ' '* IMPORTING* return_code = l_subrc** NEW_STATUS =* TABLES* message_lines = lt_msg_lines* message_struct = lt_msg_struc.
* ls_formabs-approvdate = sy-datum.* ls_formabs-approvby = sy-uname.*** UPDATE swxformabs FROM ls_formabs.CALL FUNCTION 'SAP_WAPI_WORKITEM_COMPLETE'EXPORTING
workitem_id = is_wi_details-wi_id.* actual_agent = sy-uname* language = sy-langu* do_commit = 'X'.** do_callback_in_background = 'X'**** do_commit = 'X'* IMPORTING** return_code = lv_retcode**** NEW_STATUS =* TABLES* simple_container = lt_container* message_lines = lt_msg_lines* message_struct = lt_msg_struc.*
* DATA : lv_return_code TYPE sy-subrc,* lv_event_id TYPE swr_struct-event_id,* lv_event TYPE swr_struct-event,* lt_input_container TYPE TABLE OF swr_cont,* lv_object_key TYPE swr_struct-object_key.**lv_event = 'Approved'.*lv_object_key = lv_boid.** CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'* EXPORTING* object_type = 'BUS2000113'* object_key = 'WS40000016'* event = lv_event** commit_work = 'X'** EVENT_LANGUAGE = SY-LANGU* language = sy-langu* user = sy-uname** IFS_XML_CONTAINER =* IMPORTING* return_code = lv_return_code* event_id = lv_event_id* TABLES* input_container = lt_input_container* message_lines = lt_msg_lines* message_struct = lt_msg_struc.* .****11. Set confirm*.** .* CALL FUNCTION 'SAP_WAPI_WORKITEM_CONFIRM'* EXPORTING* workitem_id = is_wi_details-wi_id.** ACTUAL_AGENT = SY-UNAME** LANGUAGE = SY-LANGU** do_commit = 'X'*** CHECK_INBOX_RESTRICTION = ' '** IMPORTING** return_code = lv_retcode*** NEW_STATUS =** TABLES** message_lines = lt_msg_lines.*** message_struct = lt_msg_struc.**ENDMETHOD.

Could you please help on this BADI implementation.

Thanks and Regards,

Unnikrishnan P K

0

Hi Unnikrishnan,

I see the BADI code does not handle the SRM contract object. So the root cause is your BADI code.

You can set external breakpoints and debug.

Regards,

Masa

0
Former Member

Hi Masa,

Could you please let me know if you have any sample code for this. What we have tried is using the BADI updating the container values comparing with the container values while approving from SRM portal.

And where I should make the changes in the BADI to handle SRM contract object.

Thanks and Regards,

Unnikrishnan P K

0

Hi Unnikrishnan,

You need to look at the ABAP code in the method of TS40007943.

Other reference is Note 2118812 - How to Extend SAP Fiori My Inbox.

Regards,

Masa

0
Former Member
Masayuki Sekihara



In task ts40007943 we have class

/SAPSRM/CL_WF_PROCESS_MGR_SBWF

but the code in the method workitem execute is commented

0
Former Member

Hi Masa,

I have followed the steps mentioned in the note. For us the basic SRM decision Task which is there in the workflow is TS40007943 at step no 293. And the Approve contract number task is TS40007943(configured in scenario definition).

And we have implemented the BADI for the step no 293, this step's outcome is events Decision Executed and Decision obsolete. Should we assign the values A and R for container line value?

When we approve the contract it is going to wrong step, as the decision is not got updated in the workflow. When workflow checks for the status it is getting 'Open' instead of approved.

Could you please suggest how to get the status of the contract correct.

Thanks and Regards,

Unnikrishnan P K

0

Hi Unnikrishnan,

Please share the BADI code.

I think TS40007943 is not the task with container operation. So A/R value does not make a sense.

Regards,

Masa

0
Former Member
Masayuki Sekihara

Hi Masa,

Thanks for the inputs.

Please see the code below:

DATA : lt_container TYPE TABLE OF swr_cont,
lt_msg_lines TYPE sapi_msg_lines,
lt_msg_struc TYPE sapi_msg_struc,
lt_cont type TABLE OF SWR_CONT.
DATA: lv_objkey TYPE swr_struct-object_key,
lv_retcode TYPE sy-subrc,
lv_event_cont TYPE swcont,
lv_container TYPE swr_cont,
ls_object TYPE swr_obj_2,
lv_objtype TYPE swr_struct-object_typ,
lv_boid TYPE swo_typeid,
lv_decset type swc_value,
lv_borvalue type SWC_VALUE,
ls_container_line TYPE swr_cont,
ls_cont type swr_cont.
DATA: c_us(2) TYPE c VALUE 'US',
lv_swhactor TYPE swhactor,
lt_event_cont TYPE TABLE OF swcont.

FIELD-SYMBOLS: <lf_boid> TYPE swr_cont,
<lf_result> TYPE swr_cont,
<lf_approver> TYPE swr_cont.

*“2. GET workitem ID
* CALL FUNCTION 'SAP_WAPI_GET_OBJECTS'* EXPORTING* workitem_id = is_wi_details-wi_id* IMPORTING** LEADING_OBJECT =* return_code = lv_retcode* leading_object_2 = ls_object* TABLES** OBJECTS =* message_lines = lt_msg_lines* message_struct = lt_msg_struc** OBJECTS_2 =.
*“3. GET document number
* MOVE ls_object-instid TO formnumber.

CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'EXPORTING
workitem_id = is_wi_details-wi_idlanguage = sy-langu
user = sy-uname
buffered_access = 'X'IMPORTING
return_code = lv_retcodeTABLES
simple_container = lt_container
subcontainer_all_objects = lt_cont
message_lines = lt_msg_lines
message_struct = lt_msg_struc..
READ TABLE lt_cont into ls_cont with key element = 'BOR_OBJECT'.if ls_cont-value is NOT INITIAL.
lv_borvalue = ls_cont-value.endif.READ TABLE lt_container WITH KEY element = 'BOID' ASSIGNING <lf_boid>.IF <lf_boid> IS ASSIGNED.
lv_boid = <lf_boid>-value.ENDIF.*read table lt_container with key element = '_RULE_RESULT' assigning <lf_result>.READ TABLE lt_container WITH KEY element = 'AGENT' ASSIGNING <lf_approver>.*read table lt_container with key element = '_WI_RESULT' assigning <lf_result>.READ TABLE lt_cont INTO ls_cont with key element = 'DECISIONSET'.If ls_cont-value is NOT INITIAL.
lv_decset = ls_cont-value.endif.**“6. SET decision value to the container.* CASE iv_decision_key. WHEN 0001. ls_container_line-value = 'A'.* ls_formabs-procstate = 'A'.* WHEN 0002.* ls_container_line-value = 'R'.* ls_formabs-procstate = 'R'.*** ENDCASE.*


**
ls_container_line-element = 'DECISIONSET'.
ls_container_line-value = lv_decset.APPEND ls_container_line TO lt_container.**
*
ls_container_line-element = '_wi_result'.
ls_container_line-value = 'A'.APPEND ls_container_line TO lt_container.****IF <lf_approver> IS ASSIGNED.
<lf_approver>-value = sy-uname.ENDIF.

.
**CALL FUNCTION 'SAP_WAPI_WRITE_CONTAINER'EXPORTING
workitem_id = is_wi_details-wi_idlanguage = sy-langu
actual_agent = sy-uname
do_commit = 'X'* IMPORTING* return_code = lv_retcodeTABLES
simple_container = lt_container
message_lines = lt_msg_lines
message_struct = lt_msg_struc.

*

CALL FUNCTION 'SAP_WAPI_WORKITEM_COMPLETE'EXPORTING
workitem_id = is_wi_details-wi_id
actual_agent = sy-unamelanguage = sy-langu
do_commit = 'X'
do_callback_in_background = 'X'* IMPORTING* return_code = lv_retcodeTABLES
message_lines = lt_msg_lines
message_struct = lt_msg_struc.




ENDMETHOD.

We are getting error as successor cannot be defined.

Thanks and Regards,

Unnikrishnan P K

0

Hi Unnikrishnan,

You need to set external break points and find the root cause in your program code.

Regards,

Masa

0
Former Member

Hi Masa,

When we are approving contract from portal we are not facing any issue and in Message tab we are getting message text as follows in approval subworkflow step:

Completing event '/SAPSRM/CL_WF_DSET_SBWF->EXECUTED' received

but from fiori we are not getting this message and workflow is not moving to the next step. Do we need to call any class or FM to terminate the event, As our object category is abap class we don't have any clue which method to use in this case. Could you please check ws40000016 workflow and suggest us the need ful?

In debugging we have not found any errors,So we are confused.

0
avatar image
Former Member Jun 07, 2017 at 10:02 AM
0

Hi Masa,

When we are approving contract from portal we are not facing any issue and in Message tab we are getting message text as follows in approval subworkflow step:

Completing event '/SAPSRM/CL_WF_DSET_SBWF->EXECUTED' received

but from fiori we are not getting this message and workflow is not moving to the next step. Do we need to call any class or FM to terminate the event, As our object category is abap class we don't have any clue which method to use in this case. Could you please check ws40000016 workflow and suggest us the need ful?

In debugging we have not found any errors,So we are confused.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jun 20, 2017 at 08:16 PM
0

Refer SAP Note 2401098. We have the same problem. This OSS Note solution is upgrade system to higher level and we are working on it. Our issue is also similar with Shopping cart Fiori approval.


Share
10 |10000 characters needed characters left characters exceeded