Linking DMS documents to invoice approval workflow
Invoice approval workflows have a starting weakness. they start, in most cases, form the DMS document – the scanned invoice. And the workflow which is linked to the invoice in most cases needs to be linked to the DMS document .the process looks a lot of times something like this:
- A physical invoice is received and scanned to a DMS document
- An invoice is created in SAP and parked – only now you have an object key
- The invoice is linked to the DMS document
- The invoice is pre-posted and sent to approval
- The invoice is approved and parked
Now the steps may change a bit from organization to organization but the problem in all cases is linking the DMS document to the invoice workflow. The first problem is actually not a workflow one – there is no standard DMS object link to invoices. This can be overcomed in two way, create a Z DMS object type for the invoice or use classification where the attributes are the invoice number and year.
The second problem is raising an event for the workflow invoice object when a DMS object is linked, I will show a solution based on the classification option, but the same logic should work well for a z DMS object.
- Create a receiver function module for the DRAW BOR object changed and created events. You can set a check function module to limit it only to the relevant DMS document type.
- Check if the object was linked to an invoice:
CALL FUNCTION ‘BAPI_OBJCL_GETDETAIL’
objectkey = lv_obj_key
objecttable = ‘DRAW’
classnum = <your dms class>
classtype = ‘017’
allocvaluesnum = lt_values_num
allocvalueschar = lt_values_char
allocvaluescurr = lt_values_curr
return = lt_return.
IF lt_values_char IS NOT INITIAL.
READ TABLE lt_values_char WITH KEY charact = ‘LOGINV’
lv_inv_num = ls_value_char–value_char.
(Repeat for the ‘year’ character)
- Raise an event for the invoice object (in this case I also transferred the DMS object key for use in the invoice workflow):
IF lv_inv_num IS NOT INITIAL AND lv_inv_year IS NOT INITIAL.
CONCATENATE lv_inv_num lv_inv_year INTO lv_inv_obj_key
ls_simple_container–element = ‘DMSKEY’.
ls_simple_container–value = objkey.
APPEND ls_simple_container TO lt_simple_container.
CALL FUNCTION ‘SAP_WAPI_CREATE_EVENT’
object_type = ‘BUS2081’
object_key = lv_inv_obj_key
event = ‘SCANNED’
input_container = lt_simple_container.
- It’s also a good idea to display the DMS document directly from the approval workflow task, you can now create a DRAW object and link it to the workflow approval task or even create a z-object which default method opens the scanned document directly and not transaction cv03n.
There are solutions for a more automated process such as Invoice Management Software | Procurement | SAP