Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member184958
Active Participant
0 Kudos
474

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,

Create the layout like below,

Bind the visibility for the button,

Do the same binding as like Reject  for Approve button.

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

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

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

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.

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,

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_app-EMP_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 sy-subrc <> 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_DB-EMP_SNO   = LV_NUM.
LS_DB-EMP_NUMBER = ls_n_app-emp_no.
LS_DB-EMP_NAME = ls_n_app-emp_name.
LS_DB-EMP_RIDATE = ls_n_app-emp_rim.
LS_DB-REIM_AMOUN = ls_n_app-date.
LS_DB-EMP_DESIG = ls_n_app-EMP_DESIG.

MODIFY ZEMP_WF FROM LS_DB.

data empno type SWR_STRUCT-OBJECT_KEY.
DATA: LT_INPUT_CONTAINER  TYPE TABLE OF SWR_CONT,
       LS_INPUT_CONTAINER TYPE  SWR_CONT .

   LS_INPUT_CONTAINER-ELEMENT = 'IM_URLPE'."Event parameter name
   LS_INPUT_CONTAINER-VALUE = LV_URL."pass the url
   APPEND LS_INPUT_CONTAINER TO LT_INPUT_CONTAINER.

empno = ls_n_app-emp_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_visi-visi.
       DATA lv_visi1 TYPE wd_this->element_n_visi-visi1.

*     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_app-read.
         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_app-EMP_NO     = lv_db-EMP_NUMBER.
   ls_n_app-EMP_NAME   = lv_db-EMP_NAME.
   ls_n_app-EMP_RIM    = lv_db-EMP_RIDATE.
   ls_n_app-DATE       = lv_db-REIM_AMOUN.
   ls_n_app-EMP_DESIG  = lv_db-EMP_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,

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

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

Warm Regards,

John.


4 Comments
Labels in this area