cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger a workflow from ABAP Webdynpro

Former Member
0 Kudos

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

Thanks a lot in advance.

Best Regards,

Kiran

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Kiran,

To trigger the workflow from webdynpro application.

First create BOR object using transaction swo1 and then create your workflow. To trigger workflow use following code:

* Triggering workflow through BOR and passing the container IT_CONT to it

  CALL FUNCTION 'SWE_EVENT_CREATE'
    EXPORTING
      objtype           = 'ZFLM'
      objkey            = obj_key
      event             = 'ON_SUBMIT'
    IMPORTING
      event_id          = it_event_id
    TABLES
      event_container   = it_cont
    EXCEPTIONS
      objtype_not_found = 1
      OTHERS            = 2.

  IF it_event_id IS NOT INITIAL.
    COMMIT WORK.
  ENDIF.

Former Member
0 Kudos

SAP_WAPI_START_WORKFLOW.

Please make sure the workflow template's agent assignment is marked as general task..

For agent assignment follow the below steps...

1. Execute PFTC. Select task type as workflow template.. Mention the workflow ID...and open in Display mode.

2. ON menu click Addtional assignment ---> Agent Assignment -


> maintain ---> select GENERAL task... and save refresh the organizational environment..

Former Member
0 Kudos

Thank you Radhika & sagar.

As I said, am new to webdynpro and I have very little knowledge in workflow as well.

So, can you please explain more in detail like, where should i call that function module and how to handle the workflow from my webdynpro application.

Thanks,

Kiran

former_member628395
Active Participant
0 Kudos

Hi,

If you want to trigger the workflow on click of a button, for example, you need to write the FM call in the Click event of the button.

Regards,

Sagar

Former Member
0 Kudos

Thank you Sagar.

I only know that we might use BUS6035 to handle this posting. How do I get the information like OBJECT_TYPE, OBJECT_KEY & EVENT?

Do you have any sample codes which trigger workflows?

Thanks,

Kiran

Former Member
0 Kudos

Hello Kiran,

From what I have understood so far, I think what you need to do is use the function module SAP_WAPI_CREATE_EVENT in your web dynpro application to trigger an event which will start your workflow.

This function module needs to be called from an event handler method in your Web dynpro Application.

Lets say you have a save button on your Web dynpro application which triggers method OnActionSave. In this method OnActionSave, you can trigger the event that starts the workflow as follows:

CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'

EXPORTING

object_type = l_object_type "BUS6035

object_key = l_object_key " this would be the Acc Document Number

event = l_event " This is the event name that you use in the WF

COMMIT_WORK = 'X'

  • EVENT_LANGUAGE = SY-LANGU

IMPORTING

return_code = return_code

  • event_id = event_id

TABLES

input_container = input_container " this could contain the additional data that you wish to pass to your workflow

message_lines = message_lines

message_struct = message_struct.

I hope that this helps.

Regards,

Gaurav

Former Member
0 Kudos

Thank you Gaurav. How would I know the account document number(object_key) ahead, with out posting it into R/3?

Also, normally what additional data is passed to the workflow through input_container.

And when the event creation function module is called, will that also carry the data from the webdynpro form to the workflow?

Thanks,

Kiran

Former Member
0 Kudos

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

😎 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

Former Member
0 Kudos

Hi gaurav,

This is exactly what am looking at. Can you please detail me on point 2(doubts below) whileI go through the document in point 3.

1. What would be the table design

2. You mentioned that I should create the GUID initially and again read it in the window contoller. Am confused with this.

Note, as I mentioned am new to both webdynpro & workflow technologies. So please explain in detail. I appreciate your help and inputs.

Best Regards,

Kiran

Edited by: kiran dasari on Apr 9, 2010 4:52 AM

TomVanDoo
Active Contributor
0 Kudos

Why would you start the workflow from the webdynpro?

You're working on a standard object.

If you design your workflow so that it would start when a new instance of your standard object is created, this would fullfill your request. That way you don't have to cope with the hassle of using those workflow request, but you would let the standard handle it. (saves you bugs afterwards too)

object.created event is present in almost all (if not all) standard objects.

Former Member
0 Kudos

I don't see any EVENTS in the BUS6035, which I thought could handle this vendor invoice saving and posting.

Any more clues plz..

Regards,

Kiran

Edited by: kiran dasari on Jun 10, 2010 7:11 PM

Edited by: kiran dasari on Jun 15, 2010 5:31 PM

abhimanyu_lagishetti7
Active Contributor
0 Kudos

In that case create inherit the Business Object and create a custom object and deligate.

In the new Business Object create an event and find a suitable exit when save/post and fire that event.

Thanks

Abhi

former_member628395
Active Participant
0 Kudos

Hi,

IfI have understood the requirement correctly, I think you can use the function module 'SAP_WAPI_CREATE_EVENT' that would

trigger your workflow.

Regards,

Sagar