How to trigger workflow from abap program

Hi Experts,
i have a user developed screen in which there is an option to approve (not a std tcode)
for which there is no event created.
i am very new to workflow ,
now how to create an event and also how to trigger the workflow

Hi,
You can run a ABAP report or call a transaction from the BOR's Method directly.
Check this link for more info.
http://help.sap.com/saphelp_nw2004s/helpdata/en/80/9a3cb3971c11d194c60000e82dec10/frameset.htm.
In order to trigger an event programmatically, we would use the function module SWE_EVENT_CREATE.
BUS1001006 ( Standard Material )
here is the sample code.
DATA: key LIKE sweinstcou-objkey.
key = '68." Material Number (hard-coded)
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = 'BUS1001006'
objkey = key
event = 'CREATED'
CREATOR = ' '
TAKE_WORKITEM_REQUESTER = ' '
START_WITH_DELAY = ' '
START_RECFB_SYNCHRON = ' '
NO_COMMIT_FOR_QUEUE = ' '
DEBUG_FLAG = ' '
NO_LOGGING = ' '
IDENT =
IMPORTING
EVENT_ID =
TABLES
EVENT_CONTAINER =
EXCEPTIONS
OBJTYPE_NOT_FOUND = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
WRITE 'Event Triggered'.
ENDIF.
COMMIT WORK.
In order to test whether the event is getting triggered or not, we can make use of Event Trace. Switch on the event trace using the transaction SWELS.
Press ‘Switch On”.
Now execute the program developed earlier. Now switch-off the event trace using the same transaction SWELS.
Now go to transaction SWEL. Here you can list out the events triggered in the particular period of time. Here is the event-trace list:
Regards

Similar Messages

  • Call workflow from ABAP program

    created a zbusiness object (ZPRODH)with
    one key field product hierarchy,
    one attribute level number and
    one method display.
    I tested that zobject and using this object created workflow to display product hierarchy ,it is displaying it. now I have to call it from one abap program.
    In the abap program I am calling the funcion module, I
    CALL FUNCTION 'SWW_WI_START_SIMPLE'
    EXPORTING
    TASK = TASK
    IMPORTING
    WI_ID = WI_ID
    TABLES
    AGENTS = AGENTS
    WI_CONTAINER = WI_CONTAINER.
    It is calling the workflow and subrc is 0, but not passing the value to the workflow. Because of that the method is not working, any idea?
    Thanks in advance

    ttpa,
    Please check this thread:
    Re: Workflow from abap program
    Also check that your Fm do requires any explicit commit or not?
    Hope it will help u
    Cheers
    Jai

  • How to trigger MDM Workflow  from ABAP Program.

    HI
    I have requriment  to trigger MDM Workflow(Design in MDM) from My Module pool program. Suggest how to do it?
    Thanks in Advance.
    Regards,
    Shyam Babu Sah.

    Hi,
    This question is for forum SAP Netweaver --> Workflow. There are functions and programmes that SAP delivers for this.
    [Example here|Re: How can I trigger workflow from my report]

  • How to trigger workflow from WDA and read workflow container into WDAscreen

    Dear Expert,
      Please suggest the solution for the following requirement:
       1. Create 1 leave request from WDA and submit for approval
       2. When User press "submit" button in WDA screen, workflow will be triggered for processing approval  .
       3. When 1 request is sent to approver, he logon into portal and access to UWL to process task himself.
       4. After he press approval link, the system will call WDA screen to process approval ( this screen will contain full information of requester.)
       5. After finishing process, the result will return workflow and end of process.
    Please send simple example for step 1 and one for get data from workflow into WDA screen at step4
    Any help would be appreciated
    Thanks and best regards,
    DucTV.

    Hi,
      I am not sure for what reasons you are developing a application but SAP has its own standard workflow process for applying leave from ESS portal..
    1. AS soon as you click on the submit button of the applicaiton then you need to trigger a workflow right in that case you make sure that you need to pass some data to the workflow container I hope you might be using either SAP_WAPI_CREATE_EVENT or SAP_WAPI_START_WORKFLOW to start the workflow  in both the function module you have to fill this table in Order to pass the values from ABAP    program to workflow container.
      The answer to your question is it depends on the type of the work item ID you are passing to the SAP_WAPI_READ_CONTAINER if you are passing a top work item ID  then you will have workflow container in LT_CONTAINER if you are passing any of the child or dependent work item ids of the top work item id then you have that respective task container value.
    2. You can make use of the any foreground activity or a decision step, it depends on how you want to get back the result, if you use a foreground activity step then in that case you have to populate the result back to the task container and if let say you are using a decision step then in that case you do not have to populate the result there will be standard  container element _RESULT in the decision step it will be filled.
    Make sure if you are expecting some work item in UWL and as soon as you click on the work item your application should open then configure in SWFVISU transaction and maintain DTD in UWL any portal consultant can perform this steps in few seconds.
    3. When the workflow is started then the work item which you are able to get back is the one which helps to identify dependent work item ids it is the TOP or PARENT work item ID.
    Regards
    Pavan

  • Workflow from abap program

    I created one workflow with a zbusines object. I did not create any event for the business object. only key fields and method.
    now my question is, how can I call or trigger the workflow from the abap program. please adive

    Hi Mat,
    u can use FM SAP_WAPI_START_WORKFLOW.
    Please find sample coding
    data: z_bus2080 type swc_object.
    data: begin of bus2080_key,
    id like viqmel-qmnum,
    end of bus2080_key.
    data: wf_cont type SWR_CONT occurs 0 with header line.
    parameters: qmnum like viqmel-qmnum.
    bus2080_key-id = qmnum.
    swc_create_object z_bus2080 'BUS2080' bus2080_key.
    Populate first container element - object type BUS2080
    clear wf_cont.
    move: 'BUS2080' to wf_cont-element,
    z_bus2080 to wf_cont-value.
    append wf_cont.
    Populate second container element - char variable USERNAME
    clear wf_cont.
    move: 'USERNAME' to wf_cont-element,
    sy-uname to wf_cont-value.
    append wf_cont.
    Call WAPI function
    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
    EXPORTING
    TASK = 'WS94600159' "<-- Your workflow ID
    LANGUAGE = SY-LANGU
    IMPORTING
    RETURN_CODE =
    WORKITEM_ID =
    TABLES
    INPUT_CONTAINER = wf_cont
    MESSAGE_LINES =
    MESSAGE_STRUCT =

  • How to trigger workflow from changes in Sales Order in CRM?

    Hi Experts,
    I want to trigger event at the time of saving the changes in sales order (TCODE- CRMD_ORDER).
    I have found one BO - BUS2000115 but it is getting triggered only after new creation of sales order.And there is no BO available when we change the sales order.For this reason I have created one customize event in BO(BUS2000115).
    Now my question is How should I link this customize event so that it will trigger after saving the changes ?
    I have seen SWEC transaction but was not able to find anything to link this customize event.
    Please help ....!!!
    Good response will be rewarded.
    Thanks
    Snehasish Das
    Edited by: Snehasish Das on Feb 14, 2008 2:31 PM

    In SWEC, actually you link the change document object to a Business object and its corresponding event , to which workflow should react to.
    If yo udo not find the entry then, yo unedd to create one with finding out the respective chage documnet object.
    Hope that helps.
    Regds,
    Akshay

  • Trigger workflow from ABAP webdynpro (having an adobe form)

    Hello All,
    I have developed an Webdynpro (for ABAP) component that has an Adobe Form integrated within it. Now I have been given a requirment that the form (once filled out on the portal) needs to be routed to 2-3 persons for approval and then submitted (or processed in SAP). The approving personnel will look at their UWL on the portal and approve/dissapprove.
    I do not have much hands on experience on such a Workflow scenario as above. I have already completed the adobe form part and the webdynpro section.
    I will really appreciate it if anyone can advise as to how I need to proceed here.
    Thanks in advance, Liz

    Hi Liz,
    You can use the FM SAP_WAPI_START_WORKFLOW. In webdynpro you have the button like "Submit" right? All the process has done, the user can click the submit button to get the approval. Under the button you can call this FM.
    Create one workflow based on your scenario, and pass the workflow number to this FM. So once the submit button is clicked then in back end workflow will getting triggered.
    For more Informations, please have a look at following links.
    SAP_WAPI_START_WORKFLOW doesn't start workflow...
    SAP_WAPI_START_WORKFLOW
    SAP_WAPI_START_WORKFLOW help
    Thanks.

  • Trigger workflow from ABAP webdynpro and attach an Adobe interactive form

    I have a need to create an ABAP Webdynpro that will upload a completed Adobe interactive form and then route the form to multiple approvers thru workflow.  I am having trouble finding any documentation or examples of passing the Adobe form in the workflow.  Do I have to save the content of every field on the form to an internal table and then have every workitem call an ABAP webdynpro to render the form?  Any help or suggestions would be greatly appreciated.

    Hi Joyce,
    This can be done as follows :
    [pdf as an attachment|https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/60ff6ad3-729b-2b10-6582-fedc82680a29&overridelayout=true]
    Regards,
    Geet

  • How to trigger GP workflow through ABAP Program.

    Hi All.
    i have one scnerio , i want to create BOM through Custom Ztransaction that will be developed in ABAP Modulepool.
    User will create BOM  from this ztransaction through  Transactional Iview in PORTAL,Once the user save transaction , i want to trigger a GP(Guided Procedure ) workflow,from ABAP Program.
    is it possible to trigger GP workflow?
    if yes how  to  do it , please suggest the way out.
    Regards,
    Shyam.

    Hi lingana,
    As u see in my requriment that, Workflow is not designed within SAP , But the Workflow will be designing
    in SAP Netweaver, its a GP Workflow. And Ztransaction(Developed by ABAP) will  be seen by user through portal  and
    he save transaction on PORTAL, In backend  ABAP program will run , and after meeting certain condition, it should create
    or(Initiate) GP workflow(process).
    So my question is , how ABAP Program will call GP workflow, How the connection will be made in between ABAP Code and GP workflow framework.
    If any doubt regarding requriment let me know,
    Regards,
    Shyam.

  • How can i trigger workflow from report

    hi i create one report and workflow. i want to trigger workflow from report, how can i do this one, please send me any code you have.
    Thanks & Regards
    Sankar

    Hi Sankar,
    There is another sample code...
       REPORT ZRGEVTCR.
    INCLUDE <CNTN01>.
    DATA: OBJKEY  LIKE SWEINSTCOU-OBJKEY,
          EVENTID LIKE SWEDUMEVID-EVTID.
    DATA: BEGIN OF EVENT_CONTAINER OCCURS 0.
            INCLUDE STRUCTURE SWCONT.
    DATA: END OF EVENT_CONTAINER.
    PARAMETERS:
      OBJTYPE  LIKE SWETYPECOU-OBJTYPE DEFAULT 'ZRGMARA',
      MATERIAL LIKE MARA-MATNR,
      EVENT    LIKE SWETYPECOU-EVENT   DEFAULT 'CREATED',
      VOLEH    LIKE MARA-VOLEH,
      LED      LIKE SY-DATUM           DEFAULT '19971231'.
    OBJKEY = MATERIAL.
    CLEAR EVENT_CONTAINER. REFRESH EVENT_CONTAINER.
    set input parameters for CREATED event.
    remark: to be more general, we had to use fm SWO_QUERY_PARAMETERS
    IF EVENT EQ 'CREATED'.
      SWC_SET_ELEMENT EVENT_CONTAINER 'LatestChangeDate' LED.
      SWC_SET_ELEMENT EVENT_CONTAINER 'VolumeUnit' VOLEH.
    ENDIF.
    CALL FUNCTION 'SWE_EVENT_CREATE'
         EXPORTING
              OBJTYPE           = OBJTYPE
              OBJKEY            = OBJKEY
              EVENT             = EVENT
         IMPORTING
              EVENT_ID          = EVENTID
         TABLES
              EVENT_CONTAINER   = EVENT_CONTAINER
         EXCEPTIONS
              OBJTYPE_NOT_FOUND = 1.
    IF SY-SUBRC NE 0.
      WRITE : / 'Object type', OBJTYPE, 'not found in object repository'.
    ELSE.
      IF EVENTID NE 0.
        WRITE : / 'At least one receiver was found'.
        COMMIT WORK.
      ELSE.
        WRITE : / 'No receivers found'.
      ENDIF.
    ENDIF.
    Hope this will help you to solve your problem that how to trigger workflow from the report.
    Thanks,
    Pramod

  • Trigger rfc from abap  porxy

    hi all;
    how to trigger rfc from abap  porxy

    Hi Mehra,
    check this link and just check for only how proxy is being used/...
    https://websmp208.sap-ag.de/%7Esapidb/011000358700011142902001E/HOWTosendxmldatatobw.doc
    And u can check one more document related to the above link in Services.sap.com (How to push data from BW to XI PDF)
    If not Give me u r mail id i will forward it...
    Regards,
    sridhar
    Message was edited by: sridhar reddy kondam

  • HOW TO TRIGGER AN WORKFLOW FROM A PROGRAM ?

    HELLO THERE ,
    CAN ANYBODY PLZ TELL ME HOW TO TRIGGER AN WORKFLOW FROM AN PROGRAM AND TO PAS THE VALUE TO THE CONTAINER ?

    Hello Neon,
    If you want to trigger the workflow directly, use the FM, SWU_START_WORKFLOW
    CALL FUNCTION 'SWU_START_WORKFLOW'
      EXPORTING
        task                  =
    *   LANGUAGE              = SY-LANGU
        user                  =
    *   SENDER_ID             =
    * IMPORTING
    *   RETURN_CODE           =
    *   WORKITEM_ID           =
      tables
    *   CONTAINER             =
    *   MESSAGE_LINES         =
        attachment_list       =
    A workflow can also be triggered by and event which is in turn triggered by a program.
    By the FM, SWE_CREATE_EVENT
    Example:
    w_key = 'Connie'.
      w_creator-otype = 'US'.
      w_creator-objid = 'SAPDEV02'.
      CALL FUNCTION 'SWE_EVENT_CREATE'
        EXPORTING
          objtype                       = 'YH_BUDDIES'
          objkey                        = w_key
          event                         = 'event'
         creator                        = w_creator
    *     TAKE_WORKITEM_REQUESTER       = ' '
    *     START_WITH_DELAY              = ' '
    *     START_RECFB_SYNCHRON          = ' '
    *     NO_COMMIT_FOR_QUEUE           = ' '
    *     DEBUG_FLAG                    = ' '
    *     NO_LOGGING                    = ' '
    *     IDENT                         =
    *   IMPORTING
    *     EVENT_ID                      =
    *   TABLES
    *     EVENT_CONTAINER               =
       EXCEPTIONS
         objtype_not_found              = 1
         OTHERS                         = 2
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        WRITE: / 'EVENT TRIGGERED'.
      ENDIF.
      COMMIT WORK.
    Hope it helps you.
    Regards
    Indu.

  • Trigger a workflow from ABAP Webdynpro

    My Scenario:
    Step 1: When a user hits the SAVE button on the webdynpro form, check if that data is consistent only and trigger a message(I have a BAPI to handle this check).
    Step 2: If the data is consistent, then trigger a workflow to send an alert to an agent along with the data user entered on the form.
    Step 3: AGENT shall review the data(Same form from step 1 should appear here) and will have the option to SUBMIT / POST or REJECT. If SUBMITTED, data will be posted to R/3(I have a 2nd BAPI to handle this). If REJECTED, send an alert back to the USER who entered data in step 1.
    I checked lots of threads from the forum, none gave me a complete idea. Can any one give me a good documentation to trigger workflow from webdynpro to handle my requirement.
    I am new to webdynpro.
    I checked this blogs & articles also...
    /people/ginger.gatling/blog/2005/12/14/create-new-uis-for-existing-workflow-tasks-with-abap-web-dynpro-and-universal-worklist
    http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/wd%20java/wdjava%20archive/using%20web%20dynpro%20java%20and%20web%20dynpro%20abap%20applications%20in%20universal%20work%20list.pdf
    Thanks a lot in advance.
    Best Regards,
    Kiran

    Hello Kiran,
    I slightly misunderstood you requirement earlier. But if I am not wrong this time, here is what you need to do:
    1) The Web dynpro form that you are creating is only for data entry purpose. But the agent who is going to review the data will need an access to this form. So this means that you need to save the content of this form to the database and provide a URL in the workflow workitem which the agent can use to open the web dynpro application with the form data on it.
    2) To access the correct form, you need to save the form data in a Z-table with a GUID attached to it. Generate this GUID using GUID_CREATE function module. In the window controller of the Web dynpro component, there will be a handleDefault method where you can read the parameter'GUID' from the incoming request and use it to read the form data from the database to display the form.
    3) You can use Object Oriented programming approach for creating Workflow. Check the following article to learn how to do that:
    [http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0409e6c-d213-2d10-3cb6-c12d417626c1?quicklink=index&overridelayout=true]
    4) Create a Z-class and use this class as object type in your workflow (instead of BOR object).
    5) In the constructor of this class, pass a parameter GUID, which would be passed when you create an object of this class in the Web Dynpro forms "OnActionSave" method.
    6) Create a method in this class which will do the task of calling the BAPI to save the Acct Document. This method will be used in a Background task in a workflow step (after the agent approves the workitem).
    7) Create a method in the class which generates the URL to the webdynpro application with the GUID passed as parameter.
    (for eg: http://urltoserver/appname?GUID='guidoftheform').
    8) In your save method of WD application, call the method to raise event that triggers the workflow (using OO)
    lv_guid    = '04AE4546EED7101DE10000000A424026'. "use GUID_CREATE
           lv_objtype = 'ZWFCLASS'. " create a Z-class of your own
       TRY.
          CALL METHOD cl_swf_evt_event=>raise
            EXPORTING
              im_objcateg = 'CL'
              im_objtype  = lv_objtype
              im_event    = 'FORM_APPROVE' " this event needs to be defined in ZWFCLASS
              im_objkey   = lv_guid.
        CATCH: cx_swf_evt_exception.
      ENDTRY.
    Please read through the workflow using Object Oriented document in the URL that I have mentioned above before you read through these instructions.
    There would be a way to do this using BOR objects, but this is the way that I have tried and tested to use trigger workflows from Web dynpro applications.
    Best Regards,
    Gaurav
    Edited by: Gaurav Salkar on Apr 6, 2010 6:13 PM

  • Procedure to Call Workflow Object from ABAP program in Se38

    Hi All,
    I have one scenario like i have to call one Workflow object from ABAP program in SE38.The scenario is like below.....
    I have to select some records from database table.For example there are 100 records in the internal table.
    For all that records i have to invoke Workflow for getting approval from the authorized persons. Once Approval has come to program, It will post one document in SAP and process ends.
    Please suggest me how to move forward with this scenario.
    Regards
    Manas Ranjan Panda

    Hi,
    So you want to start a workflow from an ABAP, if an event exists for that particular workflow then the best way is to use fm SAP_WAPI_CREATE_EVENT,
    to start a workflow from an ABAP you can use fm SAP_WAPI_START_WORKFLOW.
    Kind regards, Rob Dielemans

  • How i can acces to web ( with login) from abap program?

    Hello.
    I need to acces to web that have user/password from abap program. Is there any function to do this?
    And, is it possible, to do this in background process?
    Regards.
    Antonio.

    Hi Antonio,
    Yes this is possible. Check out class cl_http_client, particularly method IF_HTTP_CLIENT~AUTHENTICATE in which you can provide the user credentials. Here's some example code:
    DATA:  client    TYPE REF TO if_http_client,
                 l_url       TYPE string,
                 l_content TYPE string.
    CALL METHOD cl_http_client=>create_by_url
      EXPORTING
        url    = l_url
      IMPORTING
        client = client
      EXCEPTIONS
        OTHERS = 1.
    client->request->set_header_field( name  = '~request_method'
                                       value = 'GET' ).        "#EC *
    CALL METHOD client->authenticate
      EXPORTING
    *    proxy_authentication = ' '
    *    client               =
        username             = 'user'
        password             = 'password'
    *    language             =
    ****Make the call
    client->send( ).
    ****Receive the Response Object
    CALL METHOD client->receive
      EXCEPTIONS
        http_communication_failure = 1
        http_invalid_state         = 2
        http_processing_failed     = 3
        OTHERS                     = 4.
    ****Get the response content in Character format
    l_content = client->response->get_cdata( ).
    Hope this helps you!
    Cheers, Roel

Maybe you are looking for

  • Photoshop cs6 won't allow me to highlight my existing text layers. Does anyone have experience with this problem?

    Photoshop cs6 won't allow me to highlight my existing text layers. I select the text tool and the text layer I want to edit, hover over text and each time I attempto to edit a new layer is created. Does anyone have experience with this problem?

  • Mac OS X Server : cannot login

    I have a Mac OS X server 10.9.5. Since a recent update of the Server App, I have the following problems : - cannot login via imap and smtp to my server - cannot "connect as" my self in Finder any more to see my home directory on the server from an Im

  • Transfering photos from an Adobe pdf file

    They were sent to me via email and they were opened in one file via Neo Office.I then created an adobe file with them would now like to share them in facebook and a forum i visit but cant figure out how.I thought if i transferred them into my iPhoto

  • Menu bar location

    Hello All: I am using JMenuBar to create a menu bar, and the menu bar is supposed to be displayed by an applet. Could someone tell me how the menu bar can be relocated? In other words, I would like to move around the menu bar and to be able to change

  • How to determine Component materials for PO line item Materials.

    Hello friends, I woluld like to know the table name for getting the component Materials of a Purchase Order line item material. There is a table called RESB, which is containing the component materials for the PO line item materials. But this table i