SAP ABAP - Custom Class For Send Email Notification From Purchase Requisition Workflow

 




Method AFTER_WI_CREATED


  METHOD AFTER_WI_CREATED.
    DATAWORKITEM_ID   TYPE SWR_STRUCT-WORKITEMID,
          LT_CONTAINER  TYPE TABLE OF SWR_CONT,
          LS_CONTAINER  TYPE SWR_CONT,
          ZBANFN        TYPE BANFN,
          LSEBAN        TYPE EBAN,
          LCL_V_WI_ID   TYPE SWW_WIID,  "Work Item ID
          WF_ID         TYPE SWW_WIID,
          LV_WID_TEXT   TYPE CHAR12,
          WF_ID_TEXT    TYPE CHAR50,
          SEND_REQUEST  TYPE REF TO CL_BCS,
          TEXT          TYPE BCSY_TEXT,
          BODY_TEXT     TYPE SO_TEXT255,
          DOCUMENT      TYPE REF TO CL_DOCUMENT_BCS,
          SENDER        TYPE REF TO CL_SAPUSER_BCS,
          RECIPIENT     TYPE REF TO IF_RECIPIENT_BCS,
          BCS_EXCEPTION TYPE REF TO CX_BCS,
          SENT_TO_ALL   TYPE OS_BOOLEAN,
          ZRELCODE      TYPE CHAR2.

    CALL METHOD WI_CONTEXT->GET_WORKITEM_ID
      RECEIVING
        RE_WORKITEM LCL_V_WI_ID.

    CLEARLV_WID_TEXTWF_ID_TEXTWORKITEM_ID.
    WORKITEM_ID LCL_V_WI_ID.

    CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
      EXPORTING
        WORKITEM_ID      WORKITEM_ID
      TABLES
        SIMPLE_CONTAINER LT_CONTAINER.

    CLEAR ZBANFNLS_CONTAINER.
    READ TABLE LT_CONTAINER INTO LS_CONTAINER WITH KEY ELEMENT '_WI_COMP_EVENT_OBJKEY'.

    IF SY-SUBRC 0.
      ZBANFN LS_CONTAINER-VALUE.
      CLEAR LSEBAN.
      SELECT SINGLE FROM EBAN INTO LSEBAN WHERE BANFN ZBANFN.
      IF LSEBAN-BANPR '08'"PR Rejected
        CLEAR LS_CONTAINER.
        READ TABLE LT_CONTAINER INTO LS_CONTAINER WITH KEY ELEMENT 'RELEASECODE'.
        ZRELCODE LS_CONTAINER-VALUE.

        IF ZRELCODE IS NOT INITIAL.
*          Send Email PR Rejected
        ENDIF.
      ELSEIF LSEBAN-BANPR '05'.
        ZBANFN LS_CONTAINER-VALUE.

        CLEAR LS_CONTAINER.
        READ TABLE LT_CONTAINER INTO LS_CONTAINER WITH KEY ELEMENT '_WI_COMP_EVENT_NAME'.
        IF LS_CONTAINER-VALUE 'SIGNIFICANTLYCHANGED'.
        ELSE.
*          Send Email Notification PR Release Completed
        ENDIF.
      ENDIF.
    ENDIF.

  ENDMETHOD.


Call This Class From Workflow (SWDD)  WS00000038 step Release requisition on Program Exits Tab




Comments

Popular posts from this blog

PHP MySql CRUD Dengan Konsep MVC

Laravel - Sistem Informasi Perpustakaan Sederhana Laravel

IT Asset Management Dengan PHP MySQL