cancel
Showing results for 
Search instead for 
Did you mean: 

Delete attachment from _Attach_Objects

0 Kudos

In a step of a custom workflow the agent must complete a dialog screen with data to be used to create a smart form. The form is then printed and retrieved as OTC, converted and attached to the work item as a PDF using SAP_WAPI_ATTACHMENT_ADD. In subsequent steps the PDF can be opened and viewed. Later on in the workflow the smart form must be changed with approvers' data. The current attachment is then removed in a separate step using SAP_WAPI_ATTACHMENT_DELETE and a new form is created and attached using the same process.

Problem: Although the attachment is removed, it is still in "_Attach_object " container element and it is still displayed in the subsequent steps as an attachment to the work items. If I click on the link I am informed that the object does no longer exist. I tried using SWW_WI_OBJECTHANDLE_DELETE but this also does not work. The container element "_Attach_object " is a multiline object type of type SOFM.   How can I manipulate this container element and remove the link so that it is not displayed in the subsequent work items?

I did try using the parent Workflow ID and also the id's of the steps were the attachment is actually attached, without success. I cannot remove all attachments at once because some office notes and other objects must stay as attachments.

The objects are defined in "_Attach_object " as SOFM:FOL2800000000004EXT40000000002443.  I have the attachment key and can instantiate such

SOFM object. If I use the method DELETE within a step/method will it delete the attachment?

I tried to use SAP_WAPI_ATTACHMENT_ADD without the commit to enable me to get the attachment id and then to create an SOFM object and assign this to a workflow element. I then assign and overwrite this object in the subsequent steps but even though I do not commit, the attachment link is again available in the subsequent steps and work items.  I only need the current (last) document as an attachment.

Hope everything is clear. Please help as a matter of urgency. Thank you.

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Thank You to Rick and Modak.  I could not get this to work and changed my approach. I added a secondary method to each dialog step that will or should display a screen that resembles the smart form. This works well as the screen is displayed in a separate session. Now I have run into another problem. I have to pass the data structures and 1 table with data used in the screen to the secondary method. I have defined all these structures and table as container elements and linked them from the workflow container to the main task container. The secondary method does not have a linkage option therefor I created same name elements in the method used in the secondary method as I hoped that the attributes and their values will be passed automatically to the secondary method were I can then use them to populate the screen that must be displayed in the separate session. Unfortunately this does not work. The attributes return initial values.

Any ideas?

I042439
Employee
Employee
0 Kudos

Hi

A workaround can be to write the Workflow Workitem ID to the memory using SET PARAMETER using a program exit (in event BEFORE_EXECUTION...plugged in your dialog step) and then reading the same in the secondary method using GET PARAMETER . Using the workflow workitem ID, you can then get the container data using FM SAP_WAPI_READ_CONTAINER.

Regards,

Modak

former_member185167
Active Contributor
0 Kudos

Hello,

Interesting issue. Do you see the same problem if you make a simple test workflow, use SAP_WAPI_ATTACHMENT_ADD and then later SAP_WAPI_ATTACHMENT_DELETE?

You can still see the document in the workflow container?

One thing you could try is to make a step to which you pass _Attach_objects and in the method called by that step you remove it yourself and then pass it back to the workflow.

regards

Rick

0 Kudos

I did just that. I tried to manipulate the container element _Attach_objects in a method and then pass it back but either I do not do it correctly or it does not work. I can GET the container element from the step container and assign it to a variable. How do you think this table variable should look? _Attach_objects is defined as a container element of BOR SOFM multiple type. In the method code we need a variable to GET the container element into. What should this table be defined as? Maybe like the following;

Data: lt_atthobj standard table of swc_object.

former_member185167
Active Contributor
0 Kudos

Hello,

I would try  SWC_GET_TABLE and a table of SWC_OBJECT types.

Let us know what works.

regards

Rick

I042439
Employee
Employee
0 Kudos

Hello

I suppose you are going against the standard functionality of the workflow architecture.

Attachments from previous steps are not to be deleted - SAP_WAPI_ATTACHMENT_DELETE does not contains this check before deleting the attachments.

Refer Note 2010600 on this behavior:

http://service.sap.com/sap/support/notes/2010600

Regards,

Modak

0 Kudos

I checked the note and I expected that this was the case. I need to progressively complete this form and in between the changes it should be visible to the agents of the subsequent work items.  If I cannot use SAP_WAPI_ATTACHMENT_DELETE what do you suggest?

I042439
Employee
Employee
0 Kudos

Could not figure out a way !!

I Tried using  SAP_WAPI_WRITE_CONTAINER does not actually helps us delete _ATTACH_OBJECT data!!

Will get back if I find a solution..... but really, don't wait for it please....!!

regards,

Modak