Read workitem Container Value in Terminating event Check Function Module

Hi
I have some problems reading work item data / values of a work item container element in a check function module on a terminating event – Do any of you know if this is possible, and if so, how it’s done ?
In My scenario I have created a multiline approval step for my business document, one task pr Line Owner.  The Event Approved is defined as a terminating event for this task, and the line owner is passed to the task container.
Now, when I raise the event, with the line owner as an event parameter, I would like to check if the line owner on the raised event, matches the line owner in the task container in question in a check fm. But here I faced the problem, that only event data, and not work item data, are passed to the Check Function module.
Regards,
Morten Nielsen

Hello Morten, hello Arghadip,
in the instance linkage's check function module (entered via transaction SWEINST) you'll have the workitem-id in the system event parameter EVTRECEIVER_ID
With this number you can use the frame work in order to read the work item container.
This is a sample coding, how you access the correct work item container using SAP Enterprise and it's new OO frame work, which checks on the terminating event of BUS2105.Released the correct release code for a work item.
INCLUDE <cntn01>.
INCLUDE <SWFCNTN01>.
INCLUDE RSWEINCL.
*** Read workitem instance and container from event
       DATA: wi_id            TYPE swwwihead-wi_id.
       swc_get_element EVENT_CONTAINER evt_receiver_id wi_id.
       IF sy-subrc <> 0.
          MESSAGE E015(ZPREL) WITH evt_receiver_id
                                       RAISING wrong_call.
       ENDIF.
       DATA: lv_wi_handle    TYPE REF TO if_swf_run_wim_internal.
       DATA: ls_context      TYPE sww_wimctx.
       DATA: lv_wi_container TYPE REF TO if_swf_cnt_container.
*    - set context
       ls_context-do_commit  = ' '.
       ls_context-called_btc = 'X'.
       ls_context-exec_user  = sy-uname.
       ls_context-fbname     = 'Z_CHECK_RELEASE_CODE'.
       CLEAR lv_wi_handle.
       CALL METHOD cl_swf_run_wim_factory=>initialize( ).
       CALL METHOD cl_swf_run_wim_factory=>find_by_wiid
               EXPORTING
                  im_wiid             = wi_id
                  im_read_for_update  = ' '
*                 im_enqueue_owner    = fb_name
*                 im_wait_for_enqueue = 'X'
                  im_context          = ls_context
               RECEIVING
                  re_instance         = lv_wi_handle.
*** This check is only done for workitem linkage TS90100081
       IF lv_wi_handle->m_sww_wihead-wi_rh_task <> 'TS90100081'. "#EC_SYNTEXT
          EXIT. "Let event pass, as this is an instance linkage to another workitem
       ENDIF.
       DATA: releaseCode_wi        TYPE t16fc-frgco.
*    - read releaseCode from workitem container
       lv_wi_container = lv_wi_handle->get_wi_container( ).
*    - perform binding event container -> workitem container
       swf_get_element lv_wi_container 'RELEASECODE' releaseCode_wi.
      DATA: e             TYPE REF TO cx_swf_run_wim.
      CATCH cx_swf_run_wim INTO e.
         RAISE WORKFLOW_RUNTIME_ERROR.
   ENDTRY.
*** From here on, the variable releaseCode_WI hold the
*** container element RelaseCode of the work item, that
*** is going to be terminated...
*** Further coding from here as appropriate...
Best regards,
Florin

Similar Messages

  • Check Function Module is not working

    Hi All Expert,
    I'm new in workflow and  develop custom workflow for Transaction FB65 ( Vendor Credit Memo) and using business object FIPP , event CREATED.
    Actually  requirement is that when user  click on park button in FB65 then should  be trigger workflow only for particular vendor code .
    Now my workflow is working fine for all vendor code.
    For particular vendor code, I have created an new entries in  SWE2 and assigning a check function module to that
    Refer Link :         http://www.****************/Tutorials/Workflow/checkfunctionmodule/demo.htm
    and also same entries create in SWETYPV But Check Function Module is not working before workflow trigger.
    Appreciate your help and support.
    Regards
    Saurabh

    Hi
    : Check FM  : ZWF_DR_CR_MEMO 
    SourceCode :
    FUNCTION ZWF_DR_CR_MEMO.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(OBJTYPE) LIKE  SWETYPECOU-OBJTYPE
    *"     VALUE(OBJKEY) LIKE  SWEINSTCOU-OBJKEY
    *"     VALUE(EVENT) LIKE  SWETYPECOU-EVENT
    *"     VALUE(RECTYPE) LIKE  SWETYPECOU-RECTYPE
    *"  EXPORTING
    *"     REFERENCE(RESULT) TYPE  C
    *"  TABLES
    *"      EVENT_CONTAINER STRUCTURE  SWCONT
    *"  EXCEPTIONS
    *"      NOT_TRIGGERED
    BREAK-POINT.
    TABLES : VBSEGK.
      DATA : LV_VEND TYPE VBSEG-LIFNR.
      CLEAR : LV_VEND.
      SELECT SINGLE  LIFNR FROM  VBSEGK INTO LV_VEND WHERE BELNR EQ OBJKEY.
        if sy-subrc eq 0
          IF LV_VEND = '0000120510'.
            RAISE NOT_TRIGGERED.
          ENDIF
      endif.
    ENDFUNCTION.

  • Doubt in Check Function module

    Hi all,
    I have created a parameter(mulitline) for an event (in SW01) and I am using a check function module to check the conditions.
    My problem is I am able to get the '_EVT_OBJECT' (object instance) in the check FM and not able to get the event's parameter (which i created for that event) in the check FM. In the log it says, "Container element xxxx doesnot exists".
    May I know whether is it possible to send the event parameter to the Event_container of the check FM. Please help in this regard. As I am placing a breakpoint in the check FM but it doesnot stops.
    P.S. I am using ZBUS2012 (delegation of BUS2012) and I redefined the event "Changed" and I added a multiline parameter with respect to DB field.
    Regards,
    V Kumar

    Hi,
    I am using a macro.
    SWC_GET_TABLE EVENT_CONTAINER 'IM_NETWR' T_NETWR.
    IM_NETWR is my mutiline element for the event "Changed". It will have the old and new value of the net price. I need to trigger the workflow if there is a change in price.
    I Know it is possible with SWEC, but i need to validate some condition, which i am not able to give in SWEC, so I am using Check FM. Please help.
    If i use both SWEC and check FM whether it will give any problem?
    Regards,
    V Kumar
    Edited by: V Kumar on Aug 14, 2009 1:37 PM

  • Issue in Check Function Module

    Hi All,
    Am doing a custom Workflow for Goods Movement.
    In my Workflow am using the Triggering event "created" of Business Object "/SAPCEM/02".
    I need to trigger my Workflow only for specific "Movement Type" (Eg. 551).
    The Event Container is having only the values Material Document & Year. I have created a check function module in which I built the logic to get the MovementType(BWART) from table MSEG for the Material Document & raising exception in case of other than 551.
    But the function module is not working as I expected. The problem is the MSEG table is not getting updated with the new Material Doc, while the Check Function Module is being called. (MSEG is updated after Check FM, it seems).  So no record in MSEG for our MaterialDoc during the call to check function module. So the query always fails.
    I need to restrict my workflow for specific Movement Types(MSEG-BWART).
    Could you please advice me in this ?
    Regards,
    Anbarasan K

    I have absolutely no idea if this works, but you could try to place a check FM on the event only in transaction SWEINST with a wait up to 1 second statement in it.
    Maybe, just maybe then you can properly use the check FM on the event-->WF in SWE2.
    Alternatively if you are of the opinion that the data should be updated when the event is triggered you could raise an OSS message (obviously search OSS first to see if this has come up previously)
    Kind regards, Rob Dielemans

  • How do I "see" a check function module in the debugger?

    I am correctly starting a custom workflow based on an event raised by standard SAP code in transaciton QE51N.
    I have to write a check function module to interrogate the event and start/not start
    the workflow because the same event is raised by SAP code in transaction QA02, and I have to be sure to start the workflow only if the event is raised in QE51N, not QA02.  (I also have to check some other properties of the QALS row for the inspection lot.)
    I know how to code the check function module, but if I need to debug it, how do I "set-up" for seeing the check function module in the debugger?
    I'm sure this is an obvious question and that I'm missing something simple.
    So thanks in advance for the answer.
    djh

    Dear DJH,
    Put a break-point in the function module and process the transaction. It will stop at runtime.
    Hope this will help.
    Regards,
    Naveen.

  • Start conditions and check function modules

    Hi,
    When we apply start conditions to any particular even linkage you will find check function module as SWB_2_CHECK_FB_START_COND_EVAL. However, what if i want to implement both a custom check function module AND start conditions ?
    My requirement is to implement both start conditions and check function module.
    Is this possible ?
    Thank you,
    Nikhil.

    Hi,
    You can use both of the things, however its advisable to check all start conditions if you are using check FM.
    This is interface for custom  check FM,once you have the key value, you can put all the checks here
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(OBJTYPE) TYPE  SWETYPECOU-OBJTYPE
    *"     VALUE(OBJKEY) TYPE  SWEINSTCOU-OBJKEY
    *"     VALUE(EVENT) TYPE  SWETYPECOU-EVENT
    *"     VALUE(RECTYPE) TYPE  SWETYPECOU-RECTYPE
    *"  EXPORTING
    *"     REFERENCE(REFERENCE) TYPE  C
    *"  TABLES
    *"      EVENT_CONTAINER STRUCTURE  SWCONT
    *"  EXCEPTIONS
    *"      NOT_TRIGGERD
    Hope this helps.
    Regards,
    Sangvir Singh

  • CU65 Variant Function cannot be released - check function module interface

    Hi ,
    Getting this error while Releasing the variant Function in CU66. Function Module trigerred by this function is of the same name as well as correctly acitvated and released , but while releasing the Function I get this error :  'Function cannot be released - check function module interface' . Following are two characeteristics that are maintained in the variant function :
    1. Customer_Type
    2. Maintenance_Contract
    While executing the Function Module alone I get Raise Inernal Exception i.e it is not identifying the argument name 'Maintenance_Contract' in the FM 'CUOV_GET_FUNCTION_ARGUMENT' exception
    Below is the code for reference . Pls point out if any mistakes :
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(GLOBALS) TYPE  CUOV_00
    *"  CHANGING
    *"     REFERENCE(ZQUERY) TYPE  ZQUERY
    *"     REFERENCE(ZMATCH) TYPE  ZMATCH
    *"  EXCEPTIONS
    *"      FAIL
    *"      INTERNAL_ERROR
    " Data Declaration
    DATA : l_main LIKE CUOV_01-atwrt,
             l_cust LIKE CUOV_01-atwrt.
    " Get value of Input Characteristic Maintenance Contract
      call function 'CUOV_GET_FUNCTION_ARGUMENT'
        exporting
          argument            = 'MAINTENANCE_CONTRACT'
       IMPORTING
          SYM_VAL             = l_main
        tables
          query               = ZQUERY
        EXCEPTIONS
          ARG_NOT_FOUND       = 1
      if sy-subrc <> 0.
      RAISE INTERNAL_ERROR.
      endif.
      " Get value of Input Characteristic Customer Type
      call function 'CUOV_GET_FUNCTION_ARGUMENT'
        exporting
          argument            = 'CUSTOMER_TYPE'
       IMPORTING
          SYM_VAL             = l_cust
       tables
          query               = ZQUERY
        EXCEPTIONS
          ARG_NOT_FOUND       = 1
      if sy-subrc <> 0.
      RAISE INTERNAL_ERROR.
      endif.
       IF l_main EQ 'NO'.
        IF l_cust EQ 'CURRENT'.
          l_cust = 'NEW'.
        ELSEIF l_cust EQ 'VAR CURRENT'.
          l_cust = 'VAR NEW'.
         ENDIF.
         ENDIF.
    " Set value for the output characteristic
         call function 'CUOV_SET_FUNCTION_ARGUMENT'
           exporting
             argument                      = 'CUSTOMER_TYPE'
             vtype                         = 'CHAR'
             SYM_VAL                       = l_cust
           NUM_VAL                       =
           tables
             match                         = ZMATCH
           EXCEPTIONS
             EXISTING_VALUE_REPLACED       = 1

    ZMATCH and ZQUERY are two table types created in SE11 , both of type CUOV_01.

  • Error messages in CRM2007 web ui from check function module

    Hi Experts,
    I want to display a warning/error in CRM webUI from my check function module. Moreover, in CRM GUI if i write a message like
    MESSAGE ID 'ZCRM' TYPE 'W' NUMBER '000'
                    WITH 'Warning Message'.
    it exits the transaction.
    Can anyone please suggest how do I go about this.
    Warm Regards,
    Abdullah

    Hi Dhawani,
    Hi Pavan,
    Can you please elaborate...how this will help??
    Thanks
    Dhwani
    I dont know the specific reason but internally there may some inconsistancy but i faced the same error and i tried with saving it in the package.
    Thanks

  • How to use Check Function Module???

    Hi Friends,
    How to use Check Function Module in Workflow???
    My requirement is to trigger the workflow at the last line item of the Material Document.
    Rewards for sure for helpful answer.
    -Satish

    Hi Satish,
    You know, the real power of forums like these is the search functionality. First you locate the correct forum, you succeeded in that and then you locate the search field and type in your question. In your case "check function module"
    I suggest you do this right away and be amazed at all of the answers about his topic. Maybe you'll even find some topic about exactly the same issue with a different solution than check function modules and on top of that you learn something this way. Talk about win-win situation
    Kind regards, Rob Dielemans

  • How to pass multi value selection parameter to SAP Function Module?

    Hi ,
    Anyone know how to pass CR multi value parameter - array to SAP Function module ?
    eg  multi selection of customer in CR
    and then pass to Function module
    in SAP FM,  the SQL select these customer only
    How should the import parameter / table of SAP Function module designed?
    and how should CR pass the data to SAP FM
    thx
    John

    Moved to Integration Kit forum

  • Check function module & start condition

    Dear friends
    Could any1 of u tel me th exact diff bet th both..
    In whic case u go for check FM and in whic case u ll go for start condition.
    regards
    sakthi

    Hi Sakthi,
    Basically both serve the same purpose that is perform some checks based on conditions which when satisfied trigger the workflow.
    However, a start condition is configured within the header of the workflow itself. Hence, the fields which we can use as part of the start condition are what are available in the workflow containers, mostly attributes of the business object being used.
    Whereas in a check function module, we can program very complicated calculations and validations, by using SELECT queries etc. which are not possible in start conditions.
    Hence basically, difference between them is the start condition is restricted in its use and can implement simple checks, whereas a check function module can be more complex.
    Cheers,
    Aditya

  • Check function module

    hi friends
    what does the check function module and receiver function module do?
    what is the usage of these function module?
    Explain details
    Regards
    vijay

    Hi,
    Using check function module you can trigger the work flow under some conditions.
    For example you are using PO workflow. If plant 1000 means only you want to trigger the work flow means you can write the code in ordinary Function module and then you can make it as a check function module.
    Start condition and the check function module has the same functionlity.
    SWW_WI_CREATE_VIA_EVENT is the Receiver function module, which is responsible for triggering the workflows (for all Workflows in SWE2). This will be assigned automatically when the linkage (SWE2) is created. This function module is common for all.
    Edited by: Viji on Mar 27, 2008 1:37 PM

  • Difference between check function module and start condition

    Hello Rob,
    In  previous answer u said thr is no difference between check function module and startcondition but there is a difference between checkfunction module and start condition.
    Before the workflow is triggering can u able to check the conditions in startcondition.The startcondition can check the condition only after the workflow has been triggered.
    But in check function module u can check the condtion before the workflow got triggered.

    Kjetil,
    Dont' fall for it, these two (unless deephak and catherina are the same person...)  are just spamming the forum.
    <a href="https://forums.sdn.sap.com/click.jspa?searchID=1763105&messageID=3206751">https://forums.sdn.sap.com/click.jspa?searchID=1763105&messageID=3206751</a>
    <a href="https://forums.sdn.sap.com/click.jspa?searchID=1763105&messageID=3206440">https://forums.sdn.sap.com/click.jspa?searchID=1763105&messageID=3206440</a>
    <a href="https://forums.sdn.sap.com/click.jspa?searchID=1763105&messageID=3207214">https://forums.sdn.sap.com/click.jspa?searchID=1763105&messageID=3207214</a>
    <a href="https://forums.sdn.sap.com/click.jspa?searchID=1763105&messageID=3207179">https://forums.sdn.sap.com/click.jspa?searchID=1763105&messageID=3207179</a>
    As you've correctly established, even the SAP documentation contradicts their nonsense. A start condition is implemented as a check function, so there is no difference; and NO workflow is started at any time if they fail.
    Cheers,
    Mike

  • Parameter passing by value or by reference in function module

    hi everybody:
    Im a beginner for abap.
    Below description is described in online help.
    In function module, the CALL FUNCTION statement can pass import, export, and changing parameters either by value or by reference. Table parameters are always transferred by reference.
    I understand parameters passing by value means values carried by parameters are transferred, but I do not understand what is "by reference".
    Please kindly give me a explanation.
    Regards.
    Andy

    hi,
    Function modules are modular units with interfaces. The interface can contain the following elements:
    Import parameters are parameters passed to the function module. In general, these are assigned
    standard ABAP Dictionary types. Import parameters can also be characterized as optional.
    Export parameters are passed from the function module to the calling program. Export parameters
    are always optional and for that reason do not need to be accepted by the calling program.
    Changing parameters are passed to the function module and can be changed by it. The result is
    returned to the calling program after the function module has executed.
    Exceptions are used to intercept errors. If an error triggers an exception in a function module, the
    function module stops. You can assign exceptions to numbers in the calling program, which sets the
    system field SY-SUBRC to that value. This return code can then be handled by the program.
    By reference Passes a pointer to the original memory location.  Very efficient
    By value Allocates a new memory location for use within the subroutine. The memory is freed when the subroutine ends.  Prevents changes to passed variable
    By value and result Similar to pass by value, but the contents of the new memory is copied back into the original memory before returning.  Allows changes and allows a rollback
    When you pass a parameter by reference, new memory is not allocated for the value. Instead, a pointer to the original memory location is passed. All references to the parameter are references to the original memory location. Changes to the variable within the subroutine update the original memory location immediately.
    1  report ztx1804.
    2  data f1 value 'A'.
    3
    4  perform s1 using f1.
    5  write / f1.
    6
    7  form s1 using p1.
    8      p1 = 'X'.
    9      endform.
    The code in Listing produces the following output:
    X
    Hope this helps, Do reward.

  • What is the difference using start condition and check function module

    what is the difference  between using start condition and check function module

    That's new to me, I thought a start condition was evaluated before the workflow started, and thus now workflow work item is available. That's why I think the only situation in which start conditions/check functions can't be used, is when the availability of a workflow log for investigation of exactly what stopped the workflow is a requirement.
    I suppose the <a href="http://help.sap.com/saphelp_46c/helpdata/en/4c/86bf43feca11d2a64f0060087a79ea/frameset.htm">SAP documentation</a> is in need of an update.

Maybe you are looking for

  • Bing is taking over Firefox - auto starts on start, or grabs the home page if I start it - how do I stop this? Go to Safari?

    Every few months, Bing takes control of Firefox: When I start the computer, Bing autostarts FF and then makes itself the home page. If I quickly close FF - I am really upset about this Bing thing and will never use it, so I shut down the autostart FF

  • Inbound delivery got stuck in EWM Queue

    Hi, I have an Inbound delivery got stuck in the inbound queue, which is from EMW. The error which it failed is "Enter SLED", but the point is material is serial number managed and not batch managed. I have compared with the successful serial number a

  • Feedback: not so smart

    Hi there, I found something on the forum that was fretful for me: Guests don't have the possibility to post - not even here in the "feedback about Discussions" section. Imagine now a guy (e.g. me) has problems to login into the apple discussions. Who

  • Connecting iPod Classic to new computer

    I recently changed computers and want to set up my iPod on the new one. The last time I changed computers, I lost all of my iPod contents. Is there a secret to setting up a new computer and being able to sync my iPod to that new computer without a lo

  • Red shift

    I'm sure my question has been asked before but I can't find a reference to it using the forum search function. I'd be grateful to know how I can avoid images returning to CS4 showing a red tint. It happens, for example, when I make a screen grab of a