INTRODUCTION

  • SES stands for SERVICE ENTRY SHEET. A Service Entry sheet is similar to the Good Receipt document and it uses services which are performed instead of materials.
  • The service entry sheet is created for a purchase order in the transaction ML81N.
  1. e.g. If a machine needs to go through maintenance for which the service entry sheet is created. The Service entry sheet contains services to maintain the machine.
    • This document will talk about the creation of SES which trigger the SES workflow and sends the work item to the approver.
    • Our requirement is when the SES is deleted before the approver approves the SES, the work item should be deleted from the approvers inbox.

REQUIREMENT

  • Create the Service Entry Sheet in the transaction ML81N. The SES workflow will be triggered and the work item will be send to the approver to approve the Service Entry Sheet.
  • Scenario is, before the service entry sheet is approved, the service entry sheet is deleted.
  • The work item should also be deleted from the approver’s inbox and there should be no work item left in the approver’s inbox.

Create Service Entry Sheet

  • Go to transaction ML81N.
  • Created a SES against PO 4400003513  with WO 40000168
  • SES 1000001563

          SES.png    

     The SES workflow is triggered on creation of the SES. The event Created actually gtes triggered from Business object      BUS2091 on creation of SES.

          SES workflow.png

     Below snapshot shows the work item gets generated with status of ‘ready’ for SES 1000001563 and t is in the approver’s      inbox.

     work item.png

Now before the approver approves the SES work item, the Service entry sheet is deleted as shown below.

Go back to the SES (ML81N) and delete it:

/wp-content/uploads/2014/09/deleted_551488.png


Once the SES is deleted, then you need to use below user exit which is trigger on save and place the code in it to delete the work item for the deleted SES.

USER EXIT: EXIT_SAPLMLSR_001

Include: ZXMLUU18

user exit.png

     user exit - 1.png


     See the attached Code(ZXMLUU18.TXT)


User Exit Code to delete the work item.

*Local Data Declartion.

DATA : lv_workitem      TYPE sww_wiid,

                        lv_text TYPE sww_witext.

* Local Constant declaration

CONSTANTS : lc_x        TYPE char1  VALUE ‘X’,

            lc_w        TYPE char1  VALUE ‘W’,

            lc_f        TYPE char1  VALUE ‘F’,

            lc_i        TYPE char1  VALUE ‘I’,

            lc_eq       TYPE char2  VALUE ‘EQ’,

            lc_perc     TYPE char1 VALUE ‘%’,

            lc_inproc   TYPE char7 VALUE ‘STARTED’,

            lc_ready    TYPE char5 VALUE ‘READY’.

* Ranges declaration

RANGES:     r_status FOR  swwwihead-wi_stat.

* Get the status in the range.

r_status-sign   = lc_i.

r_status-option = lc_eq.

r_status-low    = lc_ready.

APPEND r_status.

r_status-low    = lc_inproc.

APPEND r_status.

WAIT UP TO 5 SECONDS.

* If the Service Entery Sheet is deleted then run the below code.

IF i_essr-loekz EQ lc_x.

CLEAR: lv_workitem,

         lv_text.

CONCATENATE lc_perc i_essr-lblni lc_perc INTO lv_text.

* Get the workitem ID for the Service Entry Sheet.

SELECT wi_id UP TO 1 ROWS

INTO lv_workitem

FROM swwwihead

WHERE ( wi_type EQ lc_w OR

           wi_type EQ lc_f )

AND   wi_text LIKE lv_text

AND   wi_stat IN r_status.

ENDSELECT.

* Delete the workitem from approver’s inbox.

IF sy-subrc = 0 AND lv_workitem IS NOT INITIAL.

CALL FUNCTION ‘SWW_WI_ADMIN_CANCEL’

      EXPORTING

        wi_id                             = lv_workitem

* DO_COMMIT = lc_x

       authorization_checked             = ‘ ‘

       preconditions_checked             = lc_x

* CALLED_BY_PROXY = ‘ ‘

* IMPORTING

* NEW_STATUS =

EXCEPTIONS

       update_failed                     = 1

       no_authorization                  = 2

       infeasible_state_transition       = 3

       OTHERS                            = 4

              .

IF sy-subrc <> 0.

* Implement suitable error handling here

ENDIF.

ENDIF.

  1. ENDIF.

e_edit = ‘X’.

The above code can be used to delete the work item for the approver’s inbox for the deleted SES.

  • In the Use Exit, we need to first check if the SES is deleted or not.
  • If the SES is deleted only then the logic should run. The next step is to get the work item ID from the Service Entry Sheet.
  • Once work item received, Use the function ‘SWW_WI_ADMIN_CANCEL’ to delete the work item.

Once the SES is deleted, the delete sign can be seen as shown above.

Go back to the SBWP – now the work for SES 1000001563 is gone. The SES work item is also deleted when the SES was deleted.

work item- last.png















To report this post you need to login first.

1 Comment

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

Leave a Reply