Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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.

replied

Hello Aaron,

You should be able to use a functional method to calculate the deadline. If you get syntax errors you probably need to apply [Note 1225337 - Workflow builder: Functional expressions return error WD 266|https://service.sap.com/sap/support/notes/1225337].

Cheers,

Mike

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question