Wednesday, 20 August 2014

WORK FLOW THROUGH REPORT

*&---------------------------------------------------------------------*
*& Report  ZVWORKFLOW_MAIL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZVWORKFLOW_MAIL.


TABLES SSCRFIELDS.

*--------------------------------------------------------------*
*Selection-Screen
*--------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : P_MDT AS CHECKBOX,
             P_MDLOAD AS CHECKBOX,
             P_MUPLAD AS CHECKBOX .
SELECTION-SCREEN:PUSHBUTTON /60(10) BUTTON1 USER-COMMAND but1,
                 PUSHBUTTON 75(10) BUTTON2 USER-COMMAND but2.
SELECTION-SCREEN END OF BLOCK b1.

*--------------------------------------------------------------*
*Initialization
*--------------------------------------------------------------*
INITIALIZATION.
  button1 = 'SEND'.
  button2 = 'CANCEL'.






**  *--------------------------------------------------------------*
*At Selection-Screen
*--------------------------------------------------------------*
AT SELECTION-SCREEN.
  CASE sscrfields.
    WHEN 'BUT1'.
      PERFORM mail.
      MESSAGE 'Mail Sent Succesfully' TYPE 'I'.
    WHEN 'BUT2'.
      MESSAGE 'Your Action Cancelled' TYPE 'I'.
  ENDCASE.







*&---------------------------------------------------------------------*
*&      Form  mail
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM mail .


IF p_mdt = 'X'.


DATA : lt_container TYPE TABLE OF swr_cont,
       ls_container TYPE swr_cont.

*test to get the value throught the pgm

ls_container-element = 'FLAG1'.
ls_container-value   = 'X'.
APPEND ls_container TO lt_container.

ls_container-element = 'FLAG2'.
ls_container-value   = 'Y'.
APPEND ls_container TO lt_container.

DATA : P_TASK TYPE swr_struct-task.
P_TASK = 'WS90000032'.




*****This function Module is to start the process
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
  EXPORTING
    task                      = p_task
*   LANGUAGE                  = SY-LANGU
*   DO_COMMIT                 = 'X'
*   USER                      = SY-UNAME
*   START_ASYNCHRONOUS        = ' '
*   DESIRED_START_DATE        =
*   DESIRED_START_TIME        =
*   DESIRED_START_ZONLO       = SY-ZONLO
*   IFS_XML_CONTAINER         =
* IMPORTING
*   RETURN_CODE               =
*   WORKITEM_ID               =
*   NEW_STATUS                =
 TABLES
   input_container           = lt_container
*   MESSAGE_LINES             =
*   MESSAGE_STRUCT            =
*   AGENTS                    =
          .
*This is to run the work flow

CALL FUNCTION 'EWW_WORKFLOW_START'
  EXPORTING
    x_task                = p_task
*   X_START_DATE          = NO_DATE
*   X_START_TIME          = NO_TIME
* IMPORTING
*   Y_WORKFLOW_ID         =
* TABLES
*   X_CONTAINER           =
*   X_AGENTS              =
* EXCEPTIONS
*   INVALID_TASK          = 1
*   NO_ACTIVE_PLVAR       = 2
*   START_FAILED          = 3
*   GENERAL_ERROR         = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
IF P_MDLOAD = 'X'.
  P_TASK = 'WS90000051'.



***
****This function Module is to start the process
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
  EXPORTING
    task                      = p_task
*   LANGUAGE                  = SY-LANGU
*   DO_COMMIT                 = 'X'
*   USER                      = SY-UNAME
*   START_ASYNCHRONOUS        = ' '
*   DESIRED_START_DATE        =
*   DESIRED_START_TIME        =
*   DESIRED_START_ZONLO       = SY-ZONLO
*   IFS_XML_CONTAINER         =
* IMPORTING
*   RETURN_CODE               =
*   WORKITEM_ID               =
*   NEW_STATUS                =
 TABLES
   input_container           = lt_container
*   MESSAGE_LINES             =
*   MESSAGE_STRUCT            =
*   AGENTS                    =
          .
*This is to run the work flow

CALL FUNCTION 'EWW_WORKFLOW_START'
  EXPORTING
    x_task                = p_task
*   X_START_DATE          = NO_DATE
*   X_START_TIME          = NO_TIME
* IMPORTING
*   Y_WORKFLOW_ID         =
* TABLES
*   X_CONTAINER           =
*   X_AGENTS              =
* EXCEPTIONS
*   INVALID_TASK          = 1
*   NO_ACTIVE_PLVAR       = 2
*   START_FAILED          = 3
*   GENERAL_ERROR         = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
  ENDIF.
  IF P_MUPLAD = 'X'.

P_TASK = 'WS90000052'.




*This function Module is to start the process
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
  EXPORTING
    task                      = p_task
*   LANGUAGE                  = SY-LANGU
*   DO_COMMIT                 = 'X'
*   USER                      = SY-UNAME
*   START_ASYNCHRONOUS        = ' '
*   DESIRED_START_DATE        =
*   DESIRED_START_TIME        =
*   DESIRED_START_ZONLO       = SY-ZONLO
*   IFS_XML_CONTAINER         =
* IMPORTING
*   RETURN_CODE               =
*   WORKITEM_ID               =
*   NEW_STATUS                =
 TABLES
   input_container           = lt_container
*   MESSAGE_LINES             =
*   MESSAGE_STRUCT            =
*   AGENTS                    =
          .
*This is to run the work flow

CALL FUNCTION 'EWW_WORKFLOW_START'
  EXPORTING
    x_task                = p_task
*   X_START_DATE          = NO_DATE
*   X_START_TIME          = NO_TIME
* IMPORTING
*   Y_WORKFLOW_ID         =
* TABLES
*   X_CONTAINER           =
*   X_AGENTS              =
* EXCEPTIONS
*   INVALID_TASK          = 1
*   NO_ACTIVE_PLVAR       = 2
*   START_FAILED          = 3
*   GENERAL_ERROR         = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
  ENDIF.
ENDFORM.                    " mail
*

No comments:

Post a Comment