Skip to Content

SAP_WAPI_WRITE_CONTAINER does not write to WF container from Program Exit

Dear helpful gurus:

Function module SAP_WAPI_WRITE_CONTAINER has no effect when called from my program exit.

SAP does not take into account when a workflow "requested end" deadline falls after working hours or on a weekend or holiday. In order to achieve this, I wrote an ABAP OO Class to write an adjusted reference date and time to the container.

The workflow task uses these 2 container variables as a reference so its requested end always falls within working hours. I call this class from a task program exit, using the interface IF_SWF_IFS_WORKITEM_EXIT. I need this to run before the task is created so the variables will be available when the requested end time is calculated.

I can successfully step through the entire process in the ABAP debugger. The local container is updated when I call SWC_SET_ELEMENT.

But when my class calls SAP_WAPI_WRITE_CONTAINER, the workflow container is not modified, even though the function returns successfully (sy-subrc = 0).

What am I doing wrong?

Aaron Ortiz

P.D. Here is my code:


    wiid         type SWW_WIID.

  swc_container wf_container.

  wiid     = me->contexto->get_workflow_id( ).

      WORKITEM_ID                    = wiid
*     LANGUAGE                       = SY-LANGU
*     USER                           = SY-UNAME
*     RETURN_CODE                    =
*     IFS_XML_CONTAINER              =
      SIMPLE_CONTAINER               = wf_container.
*     MESSAGE_LINES                  =
*     MESSAGE_STRUCT                 =

  SWC_SET_ELEMENT wf_container 'zc24fechabase' me->fecha_base.
  SWC_SET_ELEMENT wf_container 'zc24horabase' me->hora_base.

      WORKITEM_ID             = wiid
*     LANGUAGE                = SY-LANGU
*     ACTUAL_AGENT            = SY-UNAME
      DO_COMMIT               = 'X'
*     IFS_XML_CONTAINER       =
*     RETURN_CODE             =
      SIMPLE_CONTAINER        = wf_container.
*     MESSAGE_LINES           =
*     MESSAGE_STRUCT          =


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 27, 2008 at 08:04 PM


    I agree with Karri. You can use function module END_TIME_DETERMINE. That allows you to input a factory calendar.

    I just had a similar requirement and I did use END_TIME_DETERMINE. I didn't find an existing method so I just created my own and a task to insert it in my workflow. It worked perfectly.

    I hope this helps.


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 26, 2008 at 11:57 PM

    Hello Aaron,

    Please look at [this thread|Deadline with factory calendar; for some resources on what you're after. It should not be necessary to fiddle with containers.

    The problem with your code is the commit. If you're in the exit the WF system executes the workitem as a LUW and doing a commit in the middle of it can cause problems. Apart from that, you cannot easily change containers in an exit because the WF system will just overwrite your changes when it completes the workitem.



    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Aaron Ortiz


      Maybe you should create a step just before your current problematic step. In this new step you can calculate the exact deadline(s) and then deliver them to the following step. Not probably the most elegant solution due to the need for extra step in the workflow, but at least it should work and will be easy to implement.

      Then it would be possible to create your own custom class (or business object) with deadline attributes, but it becomes a bit more complex.



Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.