on 10-17-2008 12:20 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Aaron,
Please look at [this thread|; 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Mike,
I removed the DO_COMMIT from the function call, but I still get this error:
"Cannot call WAPI interface 'SAP_WAPI_WRITE_CONTAINER' in this context"
I had read the article you linked to already, it is a very helpful guide, thanks! But the problem is that the alerts I need to set need a granularity of hours, not days. That's the main reason I created the class.
For example, I have a task should take no longer than 6 hours, but often, since the workday is only 8 hours, I have to split the time between two working days, using the factory calendar. The class I wrote calculates an offset to use as the base time and date for the requested end of the workflow...but I can't write to the container from my code. Is there another way to do this?
Thanks for your help!
Aaron
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
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.