cancel
Showing results for 
Search instead for 
Did you mean: 

Change workflow container data from parent ID

Former Member
0 Kudos

I have requirement to change the workflow future levels of 'approvers' including current level.

I am calling the FM SWW_WI_CONTAINER_READ first then i will call the below FM to change the container data.

SWW_WI_CONTAINER_MODIFY is giving me runtime error i.e. conversion error. I am trying to modify using the workflow ID.

SAP_WAPI_WRITE_CONTAINER is giving me lv_return_code = 1, here i tried for both parent ID and workflow ID.

So not at all i am able to modify container data.

Please help me.....and suggest how to modify....

Accepted Solutions (1)

Accepted Solutions (1)

keohanster
Active Contributor
0 Kudos

Hi Anusha,

I am not sure I understand why you are trying to programmatically change the contents of the workflow container, including the current level. 

If you need to recalculate the approvers of a workitem, can't you write the appropriate method and call that?  What you are proposing - using SAP_WAPIs to modify the contents of the workflow container (assuming this is occurring outside the workflow) will negate any value that the workflow log has, which is considerable.

Can you explain the situation further?

Sue

Former Member
0 Kudos

Thanks a lot for your suggestion Susan.

I am trying this in a BAPI. The requirement here is in the application the user will be given option to change the approver levels at any point.

IF NOT pv_propid_text IS INITIAL.

       SELECT SINGLE wi_id parent_wi FROM swwwihead

                                     INTO (pv_workitem_id, pv_parent_wi)

                                     WHERE wi_text LIKE pv_propid_text

                                     AND wi_stat = 'READY'.

*   Check return value

       IF sy-subrc = 0.

        CALL FUNCTION 'SWW_WI_CONTAINER_READ'

           EXPORTING

             wi_id                    = pv_parent_wi

           TABLES

             wi_container             = pt_simple_container

           EXCEPTIONS

             container_does_not_exist = 1

             read_failed              = 2

             OTHERS                   = 3.

       ENDIF.

IF NOT lt_simple_container[] IS INITIAL.

          CASE lv_role_type.

          WHEN 'RECOM'.

          swc_get_element lt_simple_container 'RECOM_AGENT'  lv_recom_agent.

          swc_get_element lt_simple_container 'RECOM_MAILID' lv_recom_mailid.

          WHEN 'ILEVEL1'.

          swc_get_table   lt_simple_container 'LEVEL1_APP'  lt_level1_app.

          WHEN 'ILEVEL2'.

         SWC_GET_TABLE   lt_simple_container 'LEVEL2_APP'  lt_level2_app.

*        read table lt_simple_container into wa_simple_container with key element = 'LEVEL2_APP'.

          WHEN 'DECIDER'.

          swc_get_element lt_simple_container 'DECIDER_APP'  ls_decider_app.

          ENDCASE.

          ENDIF.

           PERFORM  validate_modify_userid  TABLES lt_return

                                            USING  lv_proposal_id

                                                   lv_mod_userid

                                                   lv_workitem_id

                                          CHANGING lv_mailid.

           CASE lv_role_type.

             WHEN 'RECOM'.

               lv_recom_agent  = lv_mod_userid.

               lv_recom_mailid = lv_mailid.

               swc_set_element lt_simple_container 'RECOM_AGENT'  lv_recom_agent.

               swc_set_element lt_simple_container 'RECOM_MAILID' lv_recom_mailid.

             WHEN 'ILEVEL1'.

             LOOP AT lt_level1_app INTO lw_level1_app WHERE num = lv_sequence.

              lw_level1_app-agent    = lv_mod_userid.

              lw_level1_app-fullname = lv_mailid.

              MODIFY lt_level1_app FROM lw_level1_app

                                   TRANSPORTING agent fullname.

             ENDLOOP.

             swc_set_table   lt_simple_container 'LEVEL1_APP'  lt_level1_app.

             WHEN 'ILEVEL2'.

             LOOP AT lt_level2_app INTO lw_level2_app. "WHERE num = lv_sequence.

*              lw_level2_app-agent    = lv_mod_userid.

*              lw_level2_app-fullname = lv_mailid.

*              MODIFY lt_level2_app FROM lw_level2_app

*                                    TRANSPORTING agent fullname.

             ENDLOOP.

             swc_set_table   lt_simple_container 'LEVEL2_APP'  lt_level2_app.

              WHEN 'DECIDER'.

              ls_decider_app-agent    = lv_mod_userid.

              ls_decider_app-fullname = lv_mailid.

               swc_set_element lt_simple_container 'DECIDER_APP'  ls_decider_app.

            ENDCASE.

IF NOT lv_workitem_id IS INITIAL AND NOT lt_simple_container[] IS INITIAL.

*

*      call function 'SAP_WAPI_WRITE_CONTAINER'

*      exporting

*           workitem_id      = lv_workitem_id

*           do_commit        = 'X'

*      OVERWRITE_TABLES_SIMPLE_CONT = 'X'

*      importing

*           return_code      = lv_return_code

*      tables

*           simple_container = lt_simple_container

*      exceptions

*           others           = 1.

*       COMMIT WORK.

        CALL FUNCTION 'SWW_WI_CONTAINER_MODIFY'

         EXPORTING

           wi_id               = lv_workitem_id

           do_commit           = 'X'

           merge_old_container = 'X'

         TABLES

           wi_container        = lt_simple_container.

    ENDIF.

The code is like this: First i will get the Ready status workflow Parent ID and workflow ID, then i will read the container and modify the approvers if required and then finally i will modify the workflow container using the above FM.

The problem here is Container Modify is giving me dump...conversion error and if i use SAP_WAPI_READ_CONTAINER for reading container value..i am getting syntax error for changing the multiline values for example Level 1 and Level 2 are multiline tables.

So it is becoming difficult for me to change the values if i use SAP_WAPI_READ_CONTAINER.

Please help!!!

anjan_paul
Active Contributor
0 Kudos

Hi,

   First share your screenshot of internal table data of lt_simple_container, after callin 'SWW_WI_CONTAINER_READ' and  'SWW_WI_CONTAINER_MODIFY'.

I think population of lt_simple_container properly internal table not done properly.

Answers (4)

Answers (4)

vishesh_malik
Participant
0 Kudos

Hi Anusha,

Few years back, I used below FM to update container elements using workitem ID:

CALL FUNCTION 'SAP_WAPI_WRITE_CONTAINER'

       EXPORTING

         WORKITEM_ID                        = LV_WKITEMID

      IMPORTING

        RETURN_CODE                        = LV_RETURN

      TABLES

        SIMPLE_CONTAINER                   = I_CONTAINER

.

               .

Till date it is working fine. Try it once.

Thanks,

Vishesh

keohanster
Active Contributor
0 Kudos

Maybe I am not grasping something here, but could this be accomplished with Object Type WF_TASK, method ALLAGENTSOFTASKGETANDDISPLATCH?

Just a thought.

former_member186746
Active Contributor
0 Kudos

Hi,

Seems a bit weird to fulfil you requirement in this way.

When something changes (like agent determination) and you pass that change on in production. In some cases you just handle the old workflows, maybe use SWIA to forward some items manually to the new users and in extreme cases change the workflow containers manually using the workflow log functionality.

In other cases it might be better to just kill (please read: set to logically delete) the started old workflows and then retrigger them using SWUE, this merhod is only ever usefull if the old workflows are waiting at their first step and nothing has happened to the database.

And in really specific cases it might be a good idea to create an abap that does that for you, select workitems, check if they can be retriggered, set to logically delete and retrigger them.

Kind regards, Rob Dielemans

former_member185167
Active Contributor
0 Kudos

Hello,

If you just want to change the approvers then perhaps it's easier to just forward the workitem.

Are you sure you want the users to determine the Approvers? Is there anything stopping them from setting themselves as Approvers?

regards

Rick Bakker

former_member185167
Active Contributor
0 Kudos

Hello,

I agree with Sue, this is something that you would only do in very special circumstances.

I've never found a need for it myself. Are you sure you have to do this?

But anyway...

I assume you're not trying to do this for a completed workitem. Maybe you could run it in debug and see exactly where SAP_WAPI_WRITE_CONTAINER goes wrong.

By the way, you should be using SAP_WAPI_READ_CONTAINER. Always use SAP_WAPI* when you can.

regards

Rick Bakker

Former Member
0 Kudos

Hi Rick,

Help me how to change the multiline table values if i use SAP_WAPI_READ_CONTAINER i am getting syntax error if i change like how i have mentioned in the above code. Then  i can use SAP_WAPI_WRITE_CONTAINER.

The status for my workflow is 'In process'...

One more question i have can we change the container data of the workflow my using Parent ID.