Skip to Content
avatar image
Former Member

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:

method ESCRIBIR_CONTAINER.

  data:
    wiid         type SWW_WIID.

  swc_container wf_container.

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

  CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
    EXPORTING
      WORKITEM_ID                    = wiid
*     LANGUAGE                       = SY-LANGU
*     USER                           = SY-UNAME
*   IMPORTING
*     RETURN_CODE                    =
*     IFS_XML_CONTAINER              =
*     IFS_XML_CONTAINER_SCHEMA       =
    TABLES
      SIMPLE_CONTAINER               = wf_container.
*     MESSAGE_LINES                  =
*     MESSAGE_STRUCT                 =
*     SUBCONTAINER_BOR_OBJECTS       =
*     SUBCONTAINER_ALL_OBJECTS       =

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

  CALL FUNCTION 'SAP_WAPI_WRITE_CONTAINER'
    EXPORTING
      WORKITEM_ID             = wiid
*     LANGUAGE                = SY-LANGU
*     ACTUAL_AGENT            = SY-UNAME
      DO_COMMIT               = 'X'
*     IFS_XML_CONTAINER       =
*   IMPORTING
*     RETURN_CODE             =
    TABLES
      SIMPLE_CONTAINER        = wf_container.
*     MESSAGE_LINES           =
*     MESSAGE_STRUCT          =

endmethod.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

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

    Aaron,

    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.

    Margaret

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Mike Pokraka

      Thanks Mike,

      This note looks like it's going to be the solution to the problem. I will get permission to apply it. Hopefully it will.

      thanks!

      Aaron Ortiz

  • 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.

    Cheers,

    Mike

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      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.

      Regards,

      Karri