Doubt in Workflows using Programming Exits on OO ABAP

I have a doubt on workflows:-
Let me brief you about my requirement:
I am trying to update some Master data using ABAP Methods through Programming Exits in a Workflow.
I managed to find an OO method that can fetch the workflow container values directly into the structure.
While testing the workflow:-
The OO ABAP method executes and successfully updates the master tables.
However, a calling method (that triggers this method indirectly), raises an exception called SWF_RUN_WIM_EXEC_INTERRUPTED.  
The exception is caught within the caller method and the workflow errors saying that “the method ABC… cannot be executed.”
The caller method is:-
CL_SWF_RUN_WORKFLOW_START
The exception is raised on execution of the following statement:-
CALL METHOD me->start_workitem( lh_wi_handle ).
One reason for this is that the workflow is still not completed and still in “READY” state.
Alternative method
Once the Master data is updated successfully,
I tried to use the FM SAP_WAPI_WORKITEM_COMPLETE to end the work item or tried another FM to suspend the workflow.
Now it gives an error saying that these FMs are restricted from use during run-time execution.
Query
Do you have an idea why the exception is raised and how to track/prevent the same?
Can you suggest any other alternative?  Your valuable advice is urgently needed.
Thanks a million in advance,
Best Regards,
Vinod

Check the code
      CLASS zcl_event_handler IMPLEMENTATION
CLASS zcl_event_handler IMPLEMENTATION.
Top-of-page event
  METHOD top_of_page.
    PERFORM event_top_of_page
            USING z_dyndoc_id.
  ENDMETHOD.   "METHOD top_of_page
Change Status Button
  METHOD handle_toolbar.
    IF NOT pa_prodr IS INITIAL.
      DATA: lz_toolbar  TYPE stb_button.
      CLEAR lz_toolbar.
      MOVE    'CHANGE_STATUS'  TO lz_toolbar-function.
      MOVE    text-001         TO lz_toolbar-text.
      APPEND  lz_toolbar       TO e_object->mt_toolbar.
    ENDIF.          "IF NOT pa_prodr IS INITIAL
  ENDMETHOD.   "METHOD handle_toolbar
Handle User Command
  METHOD handle_user_command.
    CASE e_ucomm.
      WHEN 'CHANGE_STATUS'.
        LOOP AT    it_output
             INTO  wa_output.
          IF wa_output-chk_box EQ kc_x.
            z_flag = 1.
            EXIT.
          ENDIF.          "IF wa_output-chk_box EQ kc_x
        ENDLOOP.      "LOOP AT it_output INTO  wa_output
        IF z_flag EQ 1.
          PERFORM display_selected_data.
        ELSE.
          MESSAGE i001(zzrefn01)
                  WITH text-023.
        ENDIF.       "IF z_flag EQ 1
    ENDCASE.      "CASE e_ucomm
  ENDMETHOD.   "METHOD handle_user_command
ENDCLASS.   "zcl_event_handler IMPLEMENTATION

Similar Messages

  • Whether Workflow Program Exit works in ABAP WebDynpro

    Hi,
    I have the custom  workflow in which in each task i have given a program exit to update the status into my custom tables.
    Now i'm in doing the change in workflow, that it should call the abap webdynpro screen, where the user decisions has to be made.
    I'm getting the Workitem id from the UWL and then it lauches the Web Dynpro to choose either Approve, Reject or Change etc along with some other travel expense information.
    Now once i complete the web dynpro by calling the method 'SAP_WAPI_WORKITEM_COMPLETE', the particular work item is completed.
    I want to ask whether before this FM is called,whether the Program Exit which i have written in the Class method and which is called in the Workflow, whether it triggers or not?
    Regards,

    It is calling the workflow program exit before the SAP_WAPI_WORKITEM_COMPLETE function module.
    So closing the thread.

  • Triggering workflow using user-exits

    Hi all,
    can anyone tel me how a workflow can be triggered using user-exits??
    thanks in advance

    Call function module SAP_WAPI_CREATE_EVENT (with COMMIT_WORK = space) to create an event, and use the event to start your workflow (triggering event). Alternatively, you can start the workflow directly using the corresponding SAP_WAPI function module for that purpose. My recommendation is that you normally don't start workflows directly as it is a less flexible solution (or you have to build that flexibility yourself instead of using what you get for free with triggering events).
    However, why are you asking this question? I started wondering after seeing you ask an almost identical question in [another thread|Triggering Workflow Using BADI; here.

  • Current Agent Value in Program Exit Workflow

    Hi Gurus,
    we are using program exit to send mail to outlook on user decsion step and it is working fine for Sequential approval but when we have to send mail for parallel approval(have used block for parallel approval) we are not able to fetch current agent.
    - Have store agent in workflow container 'Agent' and used it in Block in workflow for implementing parallel appoaval.
    - Created class implementing inetrface IF_SWF_IFS_WORKITEM_EXIT and put it under program exit of user decsion in workflow
    - Now in this class I have created method at work item created to trigger email for which i require runtime work item id and agent for it.
    - We are getting workitem id at runtime and based on it picking up approval agent from workflow container and send mail to it.
    - this workfs fine for sequential one as there is only one approver at a time but in parallel where all approver are maintained in one multiline container, it is sending mail to first person maintained in multiline container.
    Please find steps below what i have tried:-
    - i tried with  FM RH_USERS_OF_WI_READ to get current agent for particular work item id  but it is throwing dump no value found at   runtime but stangely gives value if we run standalone for same work item id.
    - Then,  I tried putting wait upto to see if it helps, but then also above fm is unable to fetch agent.
    - Tried by putting select on   SWWUSERWI table but that also is not giving current agent
    Question is:
    Why we are not able to get value of current agent through above FM or select from userwi table? How do we get current agent value at the time of work item creation event is triggered which further hits our custom method.
    Please help...
    Regards
    Ajit C

    Hi Ajit,
    Here you go.
    You must be having a multiline container (probably of type WFSYST-AGENT) in your workflow which holds all the user ids to whom work item must be going parellely. e.g if the multiline container name is AGENT.
    The current agent from that multiline container is referred by &AGENT[_AGENT_line_]&. This you must hast have put in your user decision step/activity as an agent also.
    Now in your user decision step/activity, create one single line container element of type WFSYST-AGENT e.g. current_agent. in workflow to task binding, bind &AGENT[_AGENT_line_]& to CURRENT_AGENT. This way you will have current agent in that task container.
    Finally use function module SAP_WAPI_READ_CONTAINER using WORKITEM id to read the value of CURRENT_AGENT in your program exit.
    Regards,
    Ibrahim

  • Import workflow container element to program exits

    Hi Friends
    Can you please let me know if we can import container elements from workflow to program exits in step?
    Regards
    Rajeev

    Hi Rajeev,
    Yes you can import container elements from the workitem (not the workflow) to the program exit. You need an element which references the container (if_swf_ifs_parameter_container). You probably have an attribute in you class which is a reference to IF_WAPI_WORKITEM_CONTEXT called M_CTX. This has a method called get_wi_container which will give you the workitem container. Now you not only have the option to read elements with method get in your container class, but there is also a method set which will allow you to fill or change values in the container.
    Regards,
    Martin

  • Program exit to change workitem text

    Hi All,
    I have a requirement to change work item text at runtime, i am using program exit to change the task contrainer variable which is being used to display work item text. i have written a code in program exit to update container element, but it's not reflected to change workitem text, when i check in ln workflow log the variable shows with updated value.
    Please help to solve issue.
    Many thanks,

    Hi Gupta,
    I used below code to update container element.
    CASE im_event_name.
         WHEN swfco_event_after_creation.
            CLEAR l_value.
           CALL METHOD l_wi_cont->get
             EXPORTING
               name  = 'LV_WITEXT'
             IMPORTING
               value = l_value.
             REPLACE '$' INTO l_value WITH lv_id.
           CALL METHOD l_wi_cont->set
             EXPORTING
               name  = 'LV_WITEXT'
               value = l_value.
    With above code LV_WITEXT is updated with new value, but same is not displayed as workitem text in inbox.
    After workitem displayed in inbox if i use FM SWL_REFRESH_WORKITEM_TEXT explicitly to refresh, workitem text getting refreshed.
    Many thanks.

  • Retrieve workflow container data in programming exit

    I am trying to use a programming exit in Workflow in order to amend the task container for the receipients field of a "Send Email" step. The reason why we are not determining the receipients in the usual way is because we hold the receipients (amongst other data) in a separate Z* table - this needs to stay this way.
    I created a class and copied method CHANGE_CONT_ELEMENT to base my altered code on. The method is triggered fine when testing the workflow. Here is what it now looks like:
    method CHANGE_CONT_ELEMENT .
      DATA: container TYPE REF TO if_swf_cnt_container,
            if_swf_cnt_container,
            cont TYPE REF TO IF_SWF_IFS_PARAMETER_CONTAINER,
            name TYPE swfdname,
            lh_wihandle TYPE REF TO if_swf_run_wim_internal,
            l_exception TYPE REF TO cx_swf_cnt_container,
            l_wiid TYPE sww_wiid,
            w_container type ref to IF_SWF_IFS_PARAMETER_CONTAINER,
            w_names type SWFDNAMTAB,
            wa_names type line of SWFDNAMTAB,
            w_value(30).
      w_container = me->m_ctx->GET_WI_CONTAINER( ).
      w_names = w_container->LIST_NAMES( ).
    data: w_name type SWFDNAME.
    w_name = 'TEST-NUMBER'.
    TRY.
      loop at w_names into wa_names.
        CALL METHOD w_container->get
         EXPORTING
          name       = wa_names.
      endloop.
    CATCH CX_SWF_CNT_ELEM_NOT_FOUND .
    CATCH CX_SWF_CNT_ELEM_TYPE_CONFLICT .
    CATCH CX_SWF_CNT_UNIT_TYPE_CONFLICT .
    CATCH CX_SWF_CNT_CONTAINER .
    ENDTRY.
    ENDMETHOD.
    Now w_names retrieves the names of the fields fine (including my "TEST" entry which I declared in the Workflow Builder), but the GET method causes a "CX_SWF_CNT_ELEM_NOT_FOUND" exception.
    Is this the correct way to retrieve data out of a Workflow container within a WF programming exit? What am I doing wrong?
    Kind regards,
    Michael Koch

    Hi Michael, Paolo & Other experts,
    I am trying to understand when, why and how to use a 'programming exit' in a SAP workflow.
    (1) Did you figure out the solution to your problem?
    (2) Is there any material / tutorial on use of a  'programming exit' in a workflow?
    Thanks
    Abaper

  • How do the Program exits in Workflow  work?

    hi all,
    there is a Program Exit available in Workflow tasks...and it says
    You can execute additional methods that you have programmed when predefined events occur. Add the ABAP classes that contain these methods. The ABAP classes added must support the IF_SWF_IFS_WORKITEM_EXIT interface.
    now i want to use this program exits in my workflow...so that this program exit(which is basically a class) will take input from Workflow container and gives back processed data <b>back to workflow</b>.
    so how to go about with these Program exits.
    thanks,
    subba

    hi
    good
    go throgh this links
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/82d03e23-0a01-0010-b482-dccfe1c877c4
    http://help.sap.com/saphelp_nw04/helpdata/en/1a/6b023c3f6aaf08e10000000a11402f/content.htm
    thanks
    mrutyun^

  • Has anyone implemented Program exits in Workflow?

    hi all,
    i know we can capture workflow container values in the program exits.
    but i need to manipulate/change the container values and pass the new container values back to the task from the class.
    so how should i implement the binding and the class.
    thanks,
    Subba

    for this you will have to create a dummy method of a class and use the macros from <cntn01> to modify the contents. Probably you know this.
    Note that only the variables created in workflow , that are not default can be set as export parameters.
    get the required parameters as import parameters and export parameters of the method you create. Create a task out of that and insert it in the workflow definition.
    Write logic inside the method such that... only if required, modify the contents else pass the same to export.. so that net effect is nil.
    This is one method of creating program exits.
    another method is what you are asking
    add the class, shd have the interface IF_SWF_IFS_WORKITEM_EXIT  in its definition.
    Define its methods.
    By default the task container will be available for the class to operate on. they will be public. so you can reference them in your method.
    regards,
    Sandeep Josyula
    *Mark helpful answers

  • Program Exit for Travel Expense approval workflow

    Dear Experts,
    When a travel expense request is raised from the portal, the requester can attach certain documents like Files, notes to the same  for the approver to see.
    But when the approver sees the request in his UWL, he is not able to see the documents that the requester attached while creating the request.
    I used a Program Exit for the same to happen, which creates a custom Event of a Custom BO, which in turn is attached to a standard task, that calls a method of an ABAP Class, that in turn attaches the document for that particular Employee and trip number.
    But I am not able to View the document in the UWL.
    Am I missing anything?
    Please help..
    Note: I reffered the following document (which was very helpful):
    http://scn.sap.com/docs/DOC-29492

    Try changing the behavior of the uwl when calling a SAP GUI from the default ITS to WIN GUI since you can't display documents on ITS:
    Content Administration->Portal Content->Portal Users->Standard Portal Users->Universal Worklist->UWL - Launch SAP Transaction
    Under Property Category choose Content - Transaction. Set the property SAP GUI Type to SAP GUI for Windows.

  • In running the datalgr example, I get the error NIDAQ32.dll cannot start.... then program exits. Version of NI DAQ is 6.9.2, using MS C++.

    In running the datalgr example, I get the error NIDAQ32.dll cannot start.... then program exits. Version of NI DAQ is 6.9.2, using MS C++.

    Since this is a DAQ question more than a Measurement Studio for VC++ question, I'd recommend you repost it to the DAQ forum.
    Cheers,
    Azucena

  • How to debug a program exit in a Workflow ?

    Hi experts,
                      How to debug a program exit in a workflow when the workflow is triggered ?
    thanks in advance
    regards
    Ashwin

    In 4.6c I did this by creating a function module and a table (zsm50_debug). In the table are just two fields: User name (key), and a flag (yes/no).
    The function module:
    FUNCTION zsm50_debug.
    *"*"Local interface:
    *"  IMPORTING
    *"     REFERENCE(Z_DEBUG_USER) LIKE  SY-UNAME
      DATA: z_exit,
            z_debug.
      CLEAR: z_debug.
      DATA: starttime   TYPE t,
            currenttime TYPE t,
            time_passed TYPE i.
      starttime = sy-uzeit.
    * Check if debugging is switched on
      SELECT SINGLE debug FROM  zsm50_debug
                          INTO  z_debug
                          WHERE uname = z_debug_user.
    * Debugging is switched on:
      IF z_debug = 'X'.
    *   Not an endless loop, but it will continue after approx. 1 minute...
    *   Plenty of time to go to SM50 to debug the program and continue!
        DO.
    *     Change the value of z_exit to 'X' to exit the loop an stay in
    *     debug mode.
          IF z_exit = 'X'.
            EXIT.
          ENDIF.
    *     To prevent an endless loop (if the user forgot that debugging was
    *     switched on in ZSM50_DEBUG, time is measured to allow the program
    *     to continue after 2 minutes
          GET TIME FIELD currenttime.
          time_passed = currenttime - starttime.
          IF time_passed > 120.
            WRITE: / '!!!==========================================!!!'.
            WRITE: / '!!!DEBUGGING STILL SWITCHED ON IN ZSM50_DEBUG!!!'.
            WRITE: / '!!!    Program was delayed by two minutes    !!!'.
            WRITE: / '!!!==========================================!!!'.
            EXIT.
          ENDIF.
        ENDDO.
      ENDIF.
    ENDFUNCTION.
    This FM reads the table and checks if the flag is switched on. If so, it loops for two minutes. After that, it continues regardless. If not flagged, it continues immediately.
    This way, you can debug any program that is running in the background.
    In every method I program I add this FM right in the beginning. With authorization for SM50, I can then debug the program (in production it may be difficult to get the correct server, if there are more).

  • How do I exit a java program based on condition can i use system.exit

    I have java program that is called by another program that I dont have control on. My program returns a bigdecimal... but if the ordernumber is empty in my program i dont wnat to do anything.. does system.exit work in that condition... i put it int he else if ordernumber is empty condition.. but i dont think that is the right approach..

    When software module is expected to bring some result, it should bring the result, positive or negative. I think you should check what your counterpart software expects as positive or negative result. And then implement your software this way. You can use System.exit, but this call is employed usually to indicate status with the software after it's completion and not to return any resulting value.
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#exit(int)

  • Programming exit tabpage

    Hi all,
    I have a requirement to implement some coding in a 'Program Exit' tab page in a Activity Step, and for some reason, I have to call a RFC function in this  area, like below:
    call function 'XXX' starting new TASK l_task
       exporting
    And I found some note in Library like below:
    ABAP classes that you use as programming exits must not use the following elements:
    ●      COMMIT WORK
    ●      ROLLBACK WORK
    ●      Calling of function module DB_COMMIT
    ●      Any type of RFC calls
    ●      Change a system element in the container
    Then I want to know, why shouldn't I use "Any type of RFC calls" here?
    Thanks a lot.
    Best Regards,
    Ivan

    Hi ivan zhao
      I think you can use RFC but not the ABAP statements like roll back, commit work. Check out this link it would be helpful to you.
    [Program Exits In Workflow |https://wiki.sdn.sap.com/wiki/display/ABAP/Program%20Exits%20In%20Workflow]
    Regards
    vijay

  • How to get data for current week and previous week using customer exit in Bex.

    Hi everyone,
    I have a scenario in which I need to display data for current week and previous week (based on "sy_datum" the program has to calculate current week and previous week) in Bex using  Customer exit. I have created one variable in Bex Query Designer and I have written code for the variable in CMOD. But it is not working fine, (I know that we can do the same by using offset value in Bex). Can some one guide me how to achieve my requirement using customer exit.
    Thanks in Advance,
    G S Ramanjaneyulu.

    Hi krishna,
    Thanks for your quick reply, can you have a look at my code,
    case i_vnam.
    WHEN 'ZPWK_CWK'.
    ranges : pre_week for sy-datum.
    data : start_date type DATS,
           end_date TYPE dats .
    ************FM TO GET FIRST DATE OF CURRENT WEEK ************************
    CALL FUNCTION 'BWSO_DATE_GET_FIRST_WEEKDAY'
      EXPORTING
        DATE_IN  = sy-datum
      IMPORTING
        DATE_OUT = start_date.   " WEEK FIRST DATE
    end_date = START_DATE + 6.   " WEEK LAST DATE
    END_DATE   = START_DATE - 1.   " PREVIOUS WEEK END DATE
    START_DATE = START_DATE - 7.   " PREVIOUS WEEK START  DATE
    **********PREVIOUS WEEK DATES IN PRE_WEEK******************
    pre_week-SIGN   = 'I'.
    pre_week-option = 'BT'.
    pre_week-LOW    = START_DATE.
    pre_week-HIGH   = END_DATE.
    APPEND  pre_week.
    CLEAR : START_DATE,END_DATE.
    endcase.
    Regards,
    G S Ramanjaneyulu.

Maybe you are looking for