Adding links/Displaying forms/DMS documents in a workflow task using objects
Attached objects to a task will appear as links in the decision task workitem display. I find this way is easier and more flexible then using the SOFM attachments for adding data to workitems .and you can easily test the method by testing the object and do not have to use a task to create it.
let’s say we what to add a link to a url, doing so in the task description will be difficult the same as adding it as an attachment, however calling a url in a method is easy for example by using cl_gui_frontend_services=>execute. Calling an adobi form Example: Calling Forms in an Application Program (SAP Library – SAP Interactive Forms by Adobe) or a DMS document using CVAPI_DOC_VIEW and attaching a new object to the task is not difficult as well.
Here is an example for a DMS document, but this should work the same for all types of attachments.
Create a z-object (do not delegate this object to the original one if you created it as a sub-object) in the example it’s a sub-object of DRAW
In the new object create a method calling the DMS document. Pay attention that this method does not have an importing parameter
BEGIN_METHOD DISPLAYEASYDMS CHANGING CONTAINER.
CALL FUNCTION ‘CVAPI_DOC_VIEW‘
pf_dokar = object-key-DOCUMENTTYPE
pf_doknr = object-key-DOCUMENTNUMBER
pf_dokvr = object-key-DOCUMENTVERSION
pf_doktl = obejct-key-DOCUMENTPART
ERROR = 1
NOT_FOUND = 2
NO_AUTH = 3
NO_ORIGINAL = 4
OTHERS = 5.
Define this new method as the default object method
Now you can create this object as an attribute of the main workflow object (by delegation)
GET_PROPERTY DMSDOCUMENT CHANGING CONTAINER.
DATA: lo_dms_doc TYPE swc_object,
lv_dms_key TYPE sww_wi2obj-instid.
lv_dms_key = <use the obejct key to get the doc key>
swc_create_object lo_dms_doc ‘ZEASYDMSD’ lv_dms_key.
swc_set_element container ‘DMSDocument’ lo_dms_doc.
And in the decision task add the new object and transfer if to the task from the original object attribute.
The decision task will look like this:
And the added object will be a link to displaying the url/link/DMS etc.