Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow Agent Function Module

Former Member
0 Kudos

I am trying to develop a workflow for the approval of CATS time entries. Users will enter their time data and specify a receiving maintenance work order (CATSD-RAUFNR). The approver of the CATS time entry should be the user ID identified in the Partner tab of the maintenance work order identified in the CATS record.

I am trying to determine the agent in a workflow task based on a default rule for agent assignment. My idea was to capture the work order number (stored in table AUFK) from the CATS entry, then reference plant maintenance partners table (IHPA) to get the user id to use as the agent in the workflow.

I have developed a function module that works when testing it in the function builder, but when I try to test it in the "Maintain Rule" transaction (PFAC_CHG), it does not work. Can anyone let me know how to make this code work in the Maintain Rule simulation?

Here is my code for the function module:

FUNCTION Z_GET_WO_PARTNER.

*"----

-


""Local Interface:

*" IMPORTING

*" VALUE(ORDER_NUMBER) TYPE AUFNR OPTIONAL

*" TABLES

*" ACTOR_TAB STRUCTURE SWHACTOR

*" AC_CONTAINER STRUCTURE SWCONT

*" EXCEPTIONS

*" NOBODY_FOUND

*"----

-


*INCLUDE .

TYPES: BEGIN OF PLANT_MAINT,

OBJECT TYPE IHPA-OBJNR,

PARTFUNC TYPE IHPA-PARVW,

PARTNER TYPE IHPA-PARNR,

END OF PLANT_MAINT.

TYPES: BEGIN OF ORDER_MASTER,

ORDER TYPE AUFK-AUFNR,

OBJECTN TYPE AUFK-OBJNR,

END OF ORDER_MASTER.

DATA: WA_MAINT TYPE PLANT_MAINT.

DATA: WA_ORDER TYPE ORDER_MASTER.

DATA: ITABIHPA TYPE STANDARD TABLE OF PLANT_MAINT.

DATA: ITABAUFK TYPE STANDARD TABLE OF ORDER_MASTER.

DATA: PARTNERVAR TYPE STRING.

DATA: OBJN TYPE STRING.

  • Get object number from order master

SWC_GET_ELEMENT AC_CONTAINER 'OrderNumber' ORDER_NUMBER.

CLEAR: ACTOR_TAB.

REFRESH: ACTOR_TAB.

SELECT SINGLE AUFNR OBJNR FROM AUFK INTO WA_ORDER

WHERE AUFNR = ORDER_NUMBER.

IF SY-SUBRC NE 0.

RAISE nobody_found.

ENDIF.

OBJN = WA_ORDER-OBJECTN.

*get Partner field (system user id) from Plant Maintenance: Partners table

SELECT SINGLE OBJNR PARVW PARNR FROM IHPA INTO WA_MAINT

WHERE OBJNR = OBJN AND PARVW = '§G'.

IF SY-SUBRC NE 0.

RAISE nobody_found.

ELSE.

ACTOR_TAB-OTYPE = 'US'.

ACTOR_TAB-OBJID = WA_MAINT-PARTNER.

APPEND ACTOR_TAB.

ENDIF.

ENDFUNCTION.

(sorry about the poor ABAP code...)

1 ACCEPTED SOLUTION

Former Member
0 Kudos

To my guess, the function module interface is incorrect. The function module should contain only the following interface:

""Local Interface:

*" TABLES

*" ACTOR_TAB STRUCTURE SWHACTOR

*" AC_CONTAINER STRUCTURE SWCONT

*" EXCEPTIONS

*" NOAGENT_FOUND

*"----


You seem to be passing an order number. you need pass container elements using the table AC_Container and cannot send it directly. For further information, look at the following tutorial:

http://www.saptechnical.com/Tutorials/Workflow/Rules/Create.htm

Hope this helps

SS

1 REPLY 1

Former Member
0 Kudos

To my guess, the function module interface is incorrect. The function module should contain only the following interface:

""Local Interface:

*" TABLES

*" ACTOR_TAB STRUCTURE SWHACTOR

*" AC_CONTAINER STRUCTURE SWCONT

*" EXCEPTIONS

*" NOAGENT_FOUND

*"----


You seem to be passing an order number. you need pass container elements using the table AC_Container and cannot send it directly. For further information, look at the following tutorial:

http://www.saptechnical.com/Tutorials/Workflow/Rules/Create.htm

Hope this helps

SS