Skip to Content

Hints:  Better to have the below knowledge,

          Knowledge of component creation in Webdynpro.

          Basic Knowledge of Business Object Repository(BOR).

          Business work flow basic.

Go to se80->Create component called zwf_app.

                   Declare the node in component and track and paste in view using context mapping.

                   Declare the  variable for handle the visibility. Finally you context will look like below,

wf1.PNG

Create the layout like below,

wf2.PNG

Bind the visibility for the button,

wf3.PNG

wf4.PNG

Do the same binding as like Reject  for Approve button.

Go to-> SWO1->Give any name->then create as the below same structure.

wf5.PNG

Then goto swdd->to define the work item->Your design will look like below,

wf6.PNG

In the initial step click on-> Before that create two variable on work flow container like below screen shot,

wf7.PNG

To get the Employee number from the BOR and get the url from BOR event to work flow.

Now click on Header->Give the Basic data name and click on start event->Add your BOR which you are created just before.

Then click on bind and generate and activated that.

wf8.PNG

Then click back and create one activity->Create->task->then bind and assign the agent who receive the work item like below screen shot,

Save->check->Activate.

Now go to your BOR add the following code to the created method to get the url form webdynpor,

wf10.PNG

Go to->your webdynpro component->click on view->work flow->button action paste the below code,

DATA lo_nd_n_app TYPE REF TO if_wd_context_node.
   DATA lo_el_n_app TYPE REF TO if_wd_context_element.
   DATA ls_n_app TYPE wd_this->element_n_app.
   DATA LV_URL TYPE STRING.
   DATA LV_EMP TYPE STRING.
   DATA LV_NAME TYPE STRING.
* navigate from <CONTEXT> to <N_APP> via lead selection
   lo_nd_n_app = wd_context->get_child_node( name = wd_this->wdctx_n_app ).

* get element via lead selection
   lo_el_n_app = lo_nd_n_app->get_element( ).

* get all declared attributes
   lo_el_n_app->get_static_attributes(
     IMPORTING
       static_attributes = ls_n_app ).

CALL METHOD cl_wd_utilities=>construct_wd_url“Get the url
   EXPORTING
     application_name              = ‘ZWF_APP’
   IMPORTING
     out_absolute_url              = LV_URL.

LV_EMP = ls_n_appEMP_NO.

CALL METHOD cl_http_server=>if_http_server~append_field_url
   EXPORTING
     name   = ‘EMPID’“Give the parameter name which you want to append your url
     value  = LV_EMP
   changing
     url    = LV_URL.

DATA: LV_NUM TYPE I.
DATA: LT_DB TYPE STANDARD TABLE OF ZEMP_WF,
       LS_DB TYPE ZEMP_WF.

   CALL FUNCTION ‘NUMBER_GET_NEXT’
     EXPORTING
       nr_range_nr                   = ’01’
       object                        = ‘ZOBJ_SNRO’
    IMPORTING
      NUMBER                        = LV_NUM
    EXCEPTIONS
      INTERVAL_NOT_FOUND            = 1
      NUMBER_RANGE_NOT_INTERN       = 2
      OBJECT_NOT_FOUND              = 3
      QUANTITY_IS_0                 = 4
      QUANTITY_IS_NOT_1             = 5
      INTERVAL_OVERFLOW             = 6
      BUFFER_OVERFLOW               = 7
      OTHERS                        = 8
             .
   IF sysubrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.

   LV_NAME = LV_NUM.
CALL METHOD cl_http_server=>if_http_server~append_field_url
   EXPORTING
     name   = ‘EMPSNO’“Give the parameter name which you want to append your url
     value  = LV_NAME
   changing
     url    = LV_URL.

LS_DBEMP_SNO   = LV_NUM.
LS_DBEMP_NUMBER = ls_n_appemp_no.
LS_DBEMP_NAME = ls_n_appemp_name.
LS_DBEMP_RIDATE = ls_n_appemp_rim.
LS_DBREIM_AMOUN = ls_n_appdate.
LS_DBEMP_DESIG = ls_n_appEMP_DESIG.

MODIFY ZEMP_WF FROM LS_DB.

data empno type SWR_STRUCTOBJECT_KEY.
DATA: LT_INPUT_CONTAINER  TYPE TABLE OF SWR_CONT,
       LS_INPUT_CONTAINER TYPE  SWR_CONT .

   LS_INPUT_CONTAINERELEMENT = ‘IM_URLPE’.“Event parameter name
   LS_INPUT_CONTAINERVALUE = LV_URL.“pass the url
   APPEND LS_INPUT_CONTAINER TO LT_INPUT_CONTAINER.

empno = ls_n_appemp_no.
CALL FUNCTION ‘SAP_WAPI_CREATE_EVENT’
   EXPORTING
     object_type             = ‘ZWD_WF2’“Bor name swo1
     object_key              = empno “employee number
     event                   = ‘IM_URLE’“event parameter
  TABLES
    INPUT_CONTAINER         = LT_INPUT_CONTAINER.

In View Doinit method paste the below code. Then run your program,

DATA LV_STR TYPE STRING.
DATA LV_STR1 TYPE STRING.

LV_STR = WDR_TASK=>CLIENT_WINDOW->GET_PARAMETER( ‘EMPID’ ).“Read the empid from url

LV_STR1 = WDR_TASK=>CLIENT_WINDOW->GET_PARAMETER( ‘EMPSNO’ ).“Read the empno from url

       DATA lo_nd_n_visi TYPE REF TO if_wd_context_node.
       DATA lo_el_n_visi TYPE REF TO if_wd_context_element.
       DATA ls_n_visi TYPE wd_this->element_n_visi.
       DATA lv_visi TYPE wd_this->element_n_visivisi.
       DATA lv_visi1 TYPE wd_this->element_n_visivisi1.

*     navigate from <CONTEXT> to <N_VISI> via lead selection
       lo_nd_n_visi = wd_context->get_child_node( name = wd_this->wdctx_n_visi ).

*     get element via lead selection
       lo_el_n_visi = lo_nd_n_visi->get_element( ).

DATA lv_num type ZEMP_ID.
DATA lv_snum type ZEMP_SNO.

lv_num = LV_STR.
lv_snum = LV_STR1.
IF  LV_STR IS NOT INITIAL AND LV_STR1 IS NOT INITIAL.

*     set single attribute
       lo_el_n_visi->set_attribute(
         name `VISI`
         value 1 ).

*     set single attribute
       lo_el_n_visi->set_attribute(
         name `VISI1`
         value 2 ).

         DATA lo_nd_n_app TYPE REF TO if_wd_context_node.
         DATA lo_el_n_app TYPE REF TO if_wd_context_element.
         DATA ls_n_app TYPE wd_this->element_n_app.
         DATA lv_read TYPE wd_this->element_n_appread.
         DATA lv_db TYPE ZEMP_WF.

*       navigate from <CONTEXT> to <N_APP> via lead selection
         lo_nd_n_app = wd_context->get_child_node( name = wd_this->wdctx_n_app ).

*       get element via lead selection
         lo_el_n_app = lo_nd_n_app->get_element( ).

SELECT SINGLE * FROM ZEMP_WF into lv_db WHERE EMP_SNO = lv_snum AND
                                               EMP_NUMBER = lv_num.

   ls_n_appEMP_NO     = lv_dbEMP_NUMBER.
   ls_n_appEMP_NAME   = lv_dbEMP_NAME.
   ls_n_appEMP_RIM    = lv_dbEMP_RIDATE.
   ls_n_appDATE       = lv_dbREIM_AMOUN.
   ls_n_appEMP_DESIG  = lv_dbEMP_DESIG.

* set all declared attributes
   lo_el_n_app->set_static_attributes(
      static_attributes = ls_n_app ).

*       set single attribute
         lo_el_n_app->set_attribute(
           name `READ`
           value = ‘X’ ).
ELSE.
*     set single attribute
       lo_el_n_visi->set_attribute(
         name `VISI`
         value 2 ).

*     set single attribute
       lo_el_n_visi->set_attribute(
         name `VISI1`
         value 1 ).

ENDIF.

Your browser will look like below and fill the details click on button.

Open your work flow inbox it will display the subject with emp_id this is nothing but your entered emp_id. like below screen shots,

wf11.PNG

click on that inbox it will call the below browser using the url in the inbox,

wf12.PNG

Based on the the user action i.e if suppose user click on approve update the database as approve else reject.

Warm Regards,

John.


To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply