Binding from Task to Custom Method

My workflow is largely based on template WS2000040 - Approve Trip. 

The standard is a two step approval process with 2 decision tasks sent out 
1) Check Trip Facts 
2) Approve Trip. 

I've copied and changed the flow to have a slightly different approval process again 2 decision tasks are sent out. 
1) Approve Trip 
2) Settle Trip (Custom code) 

The workflow is based on business object BUS2089. 
I've created a subtype of BUS2089 and named it ZBUS2089, and created a method ZEmployeeTrip.ZTripSettle which calls a function module (FM) to carry out the settle process (submit's a SAP standard program RPTTEC00 (TCODE PREC)). 

The FM has the following parameters 
EMPLOYEENUMBER LIKE BAPIEMPL-PERNR Optional Passes Value Personnel Number 
TRIPNUMBER LIKE BAPITRVXXX-TRIP Optional Passes Value Trip number 

The code works correctly stand alone. I've tried to implement it in a similar manner to BUS2089-APPROVE. 


My problem is that when called from the workflow the parameters for my method are always blank and the container of the method is also blank. 

This is a view of the flow (bottom up). 

14:23:11 B STARTED TS90100002 Settle Trip 
14:22:59 W COMPLETED TS00008267 Settle Trip of Test Test rr 04.01.2003 1000004552 
14:22:58 B COMPLETED TS20000130 Set trip 1000004552 status to approved 
14:22:46 W COMPLETED TS20000131 Approve trip of Test Test/rr/04.01.2003/1000004552 
14:22:45 F STARTED WS90100002 Custom Employee Expenses 

The informations I need is stored in element TRIP. The fields that are key and the ones that I need passed through into my method are 
employeenumber like pskey-pernr, 
tripnumber like bapitrip-tripno, 

These fields are sucessfully passed from the workflow container into my role to determine the agent of task TS20000131 and subsequently task TS00008267. 

I'm pretty sure my problems relate to the binding between the task container and the method container. TS00008267 <-> ZBUS2089-ZTRIPSETTLE. And possibly my binding throughout the workflow template. 

I'm getting several binding errors that raise the following questions: 

1) When I attempt to activate the workflow template I'm told some values are not used or some values are for read purposes only. I can see these values in my workflow container and when attempting to delete them from the workflow container I get the message: 'Inherited elements may not be deleted'. 

2) As I mentioned I'm trying to implement this like BUS2089-APPROVE is implemented by SAP. When I click on my object binding within task TS90100002 I always see the key parameters to my function module called by my method ZBUS2089-ZTRIPSETTLE and I am unable to change this.  However when I look at BUS2089-APPROVE it does not work like that and in the method code it takes it's values from object-key-employeenumber and object-key-tripnumber. 

I've tried using this method in my code and also using swc_get_element ac_container 'EmployeeTrip' z_tripno. swc_get_element ac_container 'EmployeeNumber' z_person but in both cases I have no values populated. 


First thing to check is see if your method works on its own. you can do this from the swo1 transaction. click test, instantiate the object and execute the method. if it works correctly, then you will have to straighten out the binding betn the task and the method. While testing your method thru swo1, you can put a hard break-point in your method code and execute the method that way you can check if the values are being read by the method. 



When I switch on container debugging I'm getting binding errors and my target container (the method) is empty. 

I realise there are binding problems but I don't know how to repair them. Primarily because of the error messages (re: original posting) I receive during my attempts to repair the binding. 


It's definitely a binding problem - under no circumstances should the global data field 'object' be empty in your method code. 

In your workflow container, you should have an instantiated business object ('trip'?), which contains the fields you're interested in. 

What you need to do is bind this element from the workflow container to that of your standard task, which you do at the activity step level in the workflow builder. The container element 'trip' should be bound to the task element '_WI_OBJECT_ID'. Once that's in place, this should feed down into your method automatically, but by all means check this at PFTC standard task level. 

When you've done this correctly, you can access your element NOT through the workflow container using 'SWC_GET_ELEMENT', but through the business object key. 

i.e. object-key-pernr etc... 

Finally, make sure you're delegated your subtype 'ZBUS2089' system-wide to BUS2089 using SWO6 - you shouldn't be creating a standard task based on ZBUS2089, which can cause problems too. The standard task should be based on object type BUS2089, method ZTRIPSETTLE. 


The business object is &TRIP& and is instantiated to begin with i.e. the value get's passed to the first task. I believe also to the second task as I'm writing those values out in the workitem line item text. 


Resolution 

1) 'The container element 'trip' should be bound to the task element '_WI_OBJECT_ID'.' 
2) Created standard task based on BUS2089. 

Get help for your SAP WF problems 
Do you have a SAP WorkFlow Question?

SAP Books
SAP WorkFlow Certification, Interview Questions and Configuration Reference Books

SAP WorkFlow Tips
SAP Business WorkFlow Tips and WF Discussion Forum

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.