Skip to Content
author's profile photo Former Member
Former Member

Workflow Agent Function Module

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...)

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 02:00 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.