Friday, April 17, 2020

Descrie all user exit for (MV45AFZZ) creating a sales order.


All user exit and also describe code as per the requirements MV45AFZZ (This is implicit user exit).



This is included here all code put related to sales order creation while creating a sales order

VA03 this exit trigger so as per your requirement .Describe all code here and also listed different type exit as per the real requirement you find the code and develop your business scenario.

INCLUDE MV45AFZZ .

TYPES: BEGIN OF ty_vbak,
          KVGR1 TYPE vbak-KVGR1,
          KVGR2 TYPE vbak-KVGR2,
        END OF ty_vbak.

DATA: ls_vbak TYPE ty_vbak.
IF sy-tcode = 'VA02' and sy-uname = 'XYZ'.


*SELECT SINGLE KVGR1 KVGR2
*  FROM vbak
*  INTO ls_vbak
* WHERE vbeln = vbak-vbeln.
*
*IF vbak-KVGR1 <> ls_vbak-KVGR1 or vbak-KVGR2 <> ls_vbak-KVGR2.
*  VBAK-FAKSK = '05'.
*ENDIF.

IF YVBAK-faksk IS INITIAL.
  vbak-faksk = '05'.
ENDIF.
ENDIF.

ENDENHANCEMENT.

ENHANCEMENT 1  ZSALES_CHANGE_MOVE_VBAK.    "active version

DATA : Lv_kvgr1 TYPE VBAK-kvgr1.
DATA : lv_kvgr2 TYPE vbak-kvgr2.
DATA : FAKSK TYPE vbak-faksk.
DATA : kvgr1 TYPE flag.     "FLG_KVGR1 TYPE FLAG.
DATA : kvgr2  TYPE flag.  "FLG_KVGR2 TYPE FLAG.
  if sy-tcode = 'VA02' AND SY-uname = 'XYZ'.
      SELECT SINGLE kvgr1
    FROM vbak
    INTO LV_KVGR1
    WHERE vbeln = vbak-vbeln.

   SELECT SINGLE kvgr2
    FROM vbak
    INTO LV_KVGR2
    WHERE vbeln = vbak-vbeln.

   IF LV_KVGR1 <> xvbak-kvgr1.
     kvgr1 = 'X'.

     EXPORT kvgr1 FROM kvgr1 TO MEMORY ID 'KVGR1'.
   ENDIF.

  IF LV_KVGR2 <> xvbak-kvgr2.
    kvgr2 = 'X'.
   EXPORT kvgr2 FROM kvgr2 TO MEMORY ID 'KVGR2'.
  ENDIF.
ENDIF.
ENDENHANCEMENT.
ENHANCEMENT 1  ZSALES_CH_WRKF_MB.    "active version
*break-point.
if sy-tcode = 'VA02' AND SY-uname = 'XYZ'.
      SELECT SINGLE kvgr1
    FROM vbak
    INTO LV_KVGR1
    WHERE vbeln = vbak-vbeln.

   SELECT SINGLE kvgr2
    FROM vbak
    INTO LV_KVGR2
    WHERE vbeln = vbak-vbeln.

   IF LV_KVGR1 <> xvbak-kvgr1.
     kvgr1 = 'X'.

     EXPORT kvgr1 FROM kvgr1 TO MEMORY ID 'KVGR1'.
   ENDIF.

  IF LV_KVGR2 <> xvbak-kvgr2.
    kvgr2 = 'X'.
   EXPORT kvgr2 FROM kvgr2 TO MEMORY ID 'KVGR2'.
  ENDIF.
ENDIF.

ENDENHANCEMENT.
ENHANCEMENT 1  ZSM_WF_TRIGGER.    "active version

*  BREAK XYZ.
*  IF sy-tcode = 'VA02' and sy-uname = ‘XYZ’.
*  data :lv_ord type vbeln_va,
*        lv_new type BNAME_V.
*  lv_ord = xvbak-vbeln.
*  select single bname from vbak into lv_new where vbeln = lv_ord.
*
* IF lv_new NE vbak-bname.   "xvbak-bname.
*data wa_vbak type vbak.
*select single * from vbak into wa_vbak where vbeln = lv_ord.
*
**  if sy-subrc = 0.
**    wa_vbak-augru = '460'.
**    modify vbak from wa_vbak.
**    UPDATE vbak set augru = '460' where vbeln = lv_ord.
**    endif.
*    endif.
*    endif.

ENDENHANCEMENT.
ENHANCEMENT 1  ZVBAK_WF_K.    "active version
*

  DATA: gs_vbak TYPE vbak.
  DATA: gs_vbkd TYPE vbkd.
  DATA: flag_zterm(1) type c,
        flag_kvgr1(1) TYPE c,
        flag_kvgr2(1) TYPE c.

IF sy-tcode = 'VA02' and sy-uname = 'XYZ'.
   SELECT SINGLE *
    FROM vbak
    INTO gs_vbak
    WHERE vbeln = vbak-vbeln.
IF gs_vbak-kvgr1 <> xvbak-kvgr1.
  flag_kvgr1 = 'X'.
ENDIF.

IF gs_vbak-kvgr2 <> xvbak-kvgr2.
  flag_kvgr2 = 'X'.
ENDIF.

EXPORT flag_kvgr1 FROM flag_kvgr1 TO MEMORY ID 'KVGR1'.
EXPORT flag_kvgr2 FROM flag_kvgr2 TO MEMORY ID 'KVGR2'.


ENDIF.

ENDENHANCEMENT.
*$*$-End:   (3)---------------------------------------------------------------------------------$*$*

*  vbak-zzfield = xxxx-zzfield2.

ENDFORM.
*eject

*---------------------------------------------------------------------*
*       FORM USEREXIT_MOVE_FIELD_TO_VBAP                              *
*---------------------------------------------------------------------*
*       This userexit can be used to move some fields into the sales  *
*       dokument item workaerea VBAP                                  *
*                                                                     *
*       SVBAP-TABIX = 0:  Create item                                 *
*       SVBAP-TABIX > 0:  Change item                                 *
*                                                                     *
*       This form is called at the end of form VBAP_FUELLEN.          *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_VBAP.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
$"$\SE:(4) Form USEREXIT_MOVE_FIELD_TO_VBAP, Start                                                                                                           A
*$*$-Start: (4)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 2  ZIMPLENTATION.    "active version
*BREAK-POINT.
ENDENHANCEMENT.
ENHANCEMENT 1  ZSALES_CHANGE_MOVE_VBAP.    "active version

ENDENHANCEMENT.
*$*$-End:   (4)---------------------------------------------------------------------------------$*$*

*  VBAP-zzfield = xxxx-zzfield2.

ENDFORM.
*eject

*---------------------------------------------------------------------*
*       FORM USEREXIT_MOVE_FIELD_TO_VBEP                              *
*---------------------------------------------------------------------*
*       This userexit can be used to move some fields into the sales  *
*       dokument schedule line workaerea VBEP                         *
*                                                                     *
*       SVBEP-TABIX = 0:  Create schedule line                        *
*       SVBEP-TABIX > 0:  Change schedule line                        *
*                                                                     *
*       This form is called at the end of form VBEP_FUELLEN.          *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_VBEP.

*  VBEP-zzfield = xxxx-zzfield2.

ENDFORM.
*eject

*---------------------------------------------------------------------*
*       FORM USEREXIT_MOVE_FIELD_TO_VBKD                              *
*---------------------------------------------------------------------*
*       This userexit can be used to move some fields into the sales  *
*       dokument business data workaerea VBKD                         *
*                                                                     *
*       SVBKD-TABIX = 0:  Create data                                 *
*       SVBKD-TABIX > 0:  Change data                                 *
*                                                                     *
*       This form is called at the end of form VBKD_FUELLEN.          *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_VBKD.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(5) Form USEREXIT_MOVE_FIELD_TO_VBKD, Start                                                                                                           A
*$*$-Start: (5)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZENHANCE_VBKD.    "active version



*IF sy-tcode = 'VA02' and sy-uname = 'XYZ'.
*  DATA : lv_bstkd TYPE bstkd.
*
*  IMPORT lv_bstkd FROM MEMORY ID 'bstkd'.
*  vbkd-bstkd = lv_bstkd.
*
*ENDIF.
*
*IF sy-tcode = 'VA02' and sy-uname = 'XYZ'.
*
*TYPES : BEGIN OF it_vbak,
*          vbeln TYPE vbeln_va,
*          kvgr1 TYPE kvgr1,
*          kvgr2 TYPE kvgr2,
*        END OF it_vbak.
*
*DATA : lt_vbak TYPE STANDARD TABLE OF it_vbak,
*       ls_vbak TYPE it_vbak,
*       lv_bstkd TYPE bstkd.
*
*SELECT vbeln kvgr1 kvgr2
*  FROM vbak
*  INTO TABLE lt_vbak
* WHERE vbeln = vbak-vbeln.
**
*READ TABLE lt_vbak INTO ls_vbak WITH KEY vbeln = vbak-vbeln.
*  IF sy-subrc = 0.
*    IF vbak-kvgr1 NE ls_vbak-kvgr1 or vbak-kvgr2 NE ls_vbak-kvgr2.
*       VBKD-BSTDK+6(2) = VBKD-BSTDK+6(2) + 2.
*       lv_bstkd = VBKD-BSTDK.
*       EXPORT lv_bstkd TO MEMORY ID 'bstkd'.
*    ENDIF.
*  ENDIF.
*ENDIF.



*DATA : lv_zterm TYPE dzterm,
*       flag_zterm TYPE flag.
*IF sy-tcode = 'VA02'.
*  SELECT SINGLE zterm FROM vbkd
*    INTO lv_zterm
*    WHERE vbeln = vbak-vbeln.
*  IF vbkd-zterm <> lv_zterm.
*    flag_zterm = 'X'.
*    EXPORT flag_zterm FROM flag_zterm TO MEMORY ID 'SY-UCOMM'.
*  ENDIF.
*ENDIF.
*DATA :lt_container TYPE STANDARD TABLE OF swr_cont,
*      ls_container TYPE swr_cont.
*IF sy-tcode = 'VA02'.
*  SELECT SINGLE zterm FROM vbkd
*    INTO lv_zterm
*    WHERE vbeln = vbak-vbeln.
*  IF vbkd-zterm = lv_zterm.
*  ELSE.
**    PERFORM call_workflow.
*    flag_zterm = 'X'.
*    ls_container-element = 'DOC_NO'.
*    ls_container-value = vbak-vbeln.
*    APPEND ls_container TO lt_container.
*    CLEAR : ls_container.
*
*    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*      EXPORTING
*        task                      = 'WS99900499'
*        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                    =
*              .
*    IF sy-subrc = 0.
*      EXPORT flag_zterm FROM flag_zterm TO MEMORY ID 'SY-UCOMM'.
*    ENDIF.
*  ENDIF.
*ENDIF.
ENDENHANCEMENT.
ENHANCEMENT 2  ZSALES_CHANGE_MOVE_VBAK.    "active version

DATA : Lv_kvgr1 TYPE VBAK-kvgr1.
DATA : lv_kvgr2 TYPE vbak-kvgr2.
DATA : FAKSK TYPE vbak-faksk.
DATA : kvgr1 TYPE flag.     "FLG_KVGR1 TYPE FLAG.
DATA : kvgr2  TYPE flag.  "FLG_KVGR2 TYPE FLAG.

if sy-tcode = 'VA02' AND SY-uname = 'XYZ'.
      SELECT SINGLE kvgr1
    FROM vbak
    INTO LV_KVGR1
    WHERE vbeln = vbak-vbeln.

   SELECT SINGLE kvgr2
    FROM vbak
    INTO LV_KVGR2
    WHERE vbeln = vbak-vbeln.

   IF LV_KVGR1 <> xvbak-kvgr1.
     kvgr1 = 'X'.

     EXPORT kvgr1 FROM kvgr1 TO MEMORY ID 'KVGR1'.
   ENDIF.

  IF LV_KVGR2 <> xvbak-kvgr2.
    kvgr2 = 'X'.
   EXPORT kvgr2 FROM kvgr2 TO MEMORY ID 'KVGR2'.
  ENDIF.
ENDIF.

ENDENHANCEMENT.
ENHANCEMENT 1  ZSALES_CHANGE_MOVE_VBKD.    "active version

  DATA : gs_zterm TYPE VBKD-zterm.
  DATA : zterm  TYPE flag.

  IF SY-tcode = 'VA02' AND SY-uname = 'XYZ'.
    SELECT SINGLE zterm
      FROM vbkd
      INTO gs_zterm
      WHERE vbeln = vbak-vbeln.
    IF gs_zterm <> xvbkd-zterm.
      zterm  = 'X'.
      EXPORT zterm  FROM zterm TO MEMORY ID 'ZTERM'.
    ENDIF.
  ENDIF.


ENDENHANCEMENT.
ENHANCEMENT 1  ZSALES_CH_ZTERM_WRKF_MB.    "active version
*break-point.
  IF SY-tcode = 'VA02' AND SY-uname = 'XYZ'.
    SELECT SINGLE zterm
      FROM vbkd
      INTO gs_zterm
      WHERE vbeln = vbak-vbeln.
    IF gs_zterm <> xvbkd-zterm.
      zterm  = 'X'.
      EXPORT zterm  FROM zterm TO MEMORY ID 'ZTERM'.
    ENDIF.
  ENDIF.
ENDENHANCEMENT.
ENHANCEMENT 2  ZVBAK_WF_K.    "active version
*

*data : lv_zterm TYPE vbkd-zterm.
*if sy-tcode = 'VA01' or sy-tcode = 'VA02'.
*
*  CLEAR : sy-ucomm.
*  if vbkd-zterm ne 'ZXYZ' .
*    MESSAGE 'You Can enter Only One Payment term : ZXYZ' TYPE 'E' DISPLAY LIKE 'I'.
*   endif.
*  ENDIF.
******
******DATA: flag_zterm(1) type c,
******      gs_vbkd TYPE vbkd.

******IF sy-tcode = 'VA02' and sy-uname = 'XYZ'.
******  SELECT SINGLE *
******      FROM vbkd
******      INTO gs_vbkd
******      WHERE vbeln = vbak-vbeln.
******     IF gs_vbkd-zterm <> xvbkd-zterm.
******       flag_zterm = 'X'.
******     ENDIF.
******EXPORT flag_zterm FROM flag_zterm TO MEMORY ID 'ZTERM'.
******ENDIF.



ENDENHANCEMENT.
*$*$-End:   (5)---------------------------------------------------------------------------------$*$*

*  VBKD-zzfield = xxxx-zzfield2.

ENDFORM.
*eject









*---------------------------------------------------------------------*
*       FORM USEREXIT_NUMBER_RANGE                                    *
Modify Screen VA01/VA02/VA03
- February 27, 2020
ENHANCEMENT 1  ZENH.    "active version

**data : lv_zterm TYPE vbkd-zterm.
**if sy-tcode = 'VA01' or sy-tcode = 'VA02'.
**  vbkd-zterm = 'ZXYZ'.
**  ENDIF.
*  IF sy-tcode = 'VA02'.
*  CASE screen-name.
*    LOOP AT xkomv.
*      IF xkomv-kschl = 'ZADD'.
*        BREAK bijalc.
**        screen-input = 0.
*        MODIFY SCREEN.
*      ENDIF.
*    ENDLOOP.
*  ENDCASE.
*ENDIF.
*  CASE screen-name.
*    WHEN xkomv-kbetr.
*      screen-input = 0.
*      MODIFY SCREEN.
*  ENDCASE.






Export some Field Value To While creating Sales Order
- February 27, 2020
Exporting Some Value While Creating Sales Order

IF sy-uname = 'XYZ'.
*  BREAK XYZ.
DATA : lv_pltyp TYPE pltyp.
  CLEAR : lv_pltyp.
  SELECT SINGLE pltyp
    FROM vbkd
    INTO lv_pltyp
    WHERE vbeln = vbak-vbeln.

    IF lv_pltyp <> vbkd-pltyp.
      xvbak-name_flg = 'X'.
*      yvbak-name_flg = 'X'.
      vbak-name_flg = 'X'.
*      xvbak-augru = '000'.
*      vbak-augru = '000'.
    ENDIF.
ENDIF.


if sy-ucomm = 'HEAD'.
export xvbak-auart to MEMORY id 'SAUR'.
export xvbap-werks to MEMORY id 'SWER'.
endif.


*BREAK XYZ.
*DATA : lv_kvgr2 TYPE kvgr2,
*       flag_kvgr2 TYPE flag.
*IF sy-tcode = 'VA02'.
*  SELECT SINGLE kvgr2 FROM vbak
*    INTO lv_kvgr2
*    WHERE vbeln = vbak-vbeln.
*  IF vbak-kvgr2 <> lv_kvgr2.
*    flag_kvgr2 = 'X'.
*    EXPORT flag_kvgr2 FROM flag_kvgr2 TO MEMORY ID 'SY-UNAME'.
*  ENDIF.
*ENDIF.
*
*
*DATA : lv_audat TYPE sy-DATUM,
*       flg_audat TYPE flag.
*IF sy-tcode = 'VA02' and sy-UNAME = 'XYZ'.
*  SELECT SINGLE audat FROM vbak
*    INTO lv_audat
*    WHERE vbeln = vbak-vbeln.
*  IF vbak-audat <> lv_audat.
*    flg_audat = 'X'.
*    EXPORT flg_audat FROM flg_audat TO MEMORY ID 'FLG_AUDAT'.
*  ENDIF.

*ENDIF.


INCLUDE MV45AFZZ .

TYPES: BEGIN OF ty_vbak,
          KVGR1 TYPE vbak-KVGR1,
          KVGR2 TYPE vbak-KVGR2,
        END OF ty_vbak.

DATA: ls_vbak TYPE ty_vbak.
IF sy-tcode = 'VA02' and sy-uname = 'XYZ'.


*SELECT SINGLE KVGR1 KVGR2
*  FROM vbak
*  INTO ls_vbak
* WHERE vbeln = vbak-vbeln.
*
*IF vbak-KVGR1 <> ls_vbak-KVGR1 or vbak-KVGR2 <> ls_vbak-KVGR2.
*  VBAK-FAKSK = '05'.
*ENDIF.

IF YVBAK-faksk IS INITIAL.
  vbak-faksk = '05'.
ENDIF.
ENDIF.

ENDENHANCEMENT.
ENHANCEMENT 1  ZSALES_CHANGE_MOVE_VBAK.    "active version

DATA : Lv_kvgr1 TYPE VBAK-kvgr1.
DATA : lv_kvgr2 TYPE vbak-kvgr2.
DATA : FAKSK TYPE vbak-faksk.
DATA : kvgr1 TYPE flag.     "FLG_KVGR1 TYPE FLAG.
DATA : kvgr2  TYPE flag.  "FLG_KVGR2 TYPE FLAG.
  if sy-tcode = 'VA02' AND SY-uname = 'XYZ'.
      SELECT SINGLE kvgr1
    FROM vbak
    INTO LV_KVGR1
    WHERE vbeln = vbak-vbeln.

   SELECT SINGLE kvgr2
    FROM vbak
    INTO LV_KVGR2
    WHERE vbeln = vbak-vbeln.

   IF LV_KVGR1 <> xvbak-kvgr1.
     kvgr1 = 'X'.

     EXPORT kvgr1 FROM kvgr1 TO MEMORY ID 'KVGR1'.
   ENDIF.

  IF LV_KVGR2 <> xvbak-kvgr2.
    kvgr2 = 'X'.
   EXPORT kvgr2 FROM kvgr2 TO MEMORY ID 'KVGR2'.
  ENDIF.
ENDIF.
ENDENHANCEMENT.
ENHANCEMENT 1  ZSALES_CH_WRKF_MB.    "active version
*break-point.
if sy-tcode = 'VA02' AND SY-uname = 'XYZ'.
      SELECT SINGLE kvgr1
    FROM vbak
    INTO LV_KVGR1
    WHERE vbeln = vbak-vbeln.

   SELECT SINGLE kvgr2
    FROM vbak
    INTO LV_KVGR2
    WHERE vbeln = vbak-vbeln.

   IF LV_KVGR1 <> xvbak-kvgr1.
     kvgr1 = 'X'.

     EXPORT kvgr1 FROM kvgr1 TO MEMORY ID 'KVGR1'.
   ENDIF.

  IF LV_KVGR2 <> xvbak-kvgr2.
    kvgr2 = 'X'.
   EXPORT kvgr2 FROM kvgr2 TO MEMORY ID 'KVGR2'.
  ENDIF.
ENDIF.

ENDENHANCEMENT.
ENHANCEMENT 1  ZSM_WF_TRIGGER.    "active version

*  BREAK XYZ.
*  IF sy-tcode = 'VA02' and sy-uname = ‘XYZ’.
*  data :lv_ord type vbeln_va,
*        lv_new type BNAME_V.
*  lv_ord = xvbak-vbeln.
*  select single bname from vbak into lv_new where vbeln = lv_ord.
*
* IF lv_new NE vbak-bname.   "xvbak-bname.
*data wa_vbak type vbak.
*select single * from vbak into wa_vbak where vbeln = lv_ord.
*
**  if sy-subrc = 0.
**    wa_vbak-augru = '460'.
**    modify vbak from wa_vbak.
**    UPDATE vbak set augru = '460' where vbeln = lv_ord.
**    endif.
*    endif.
*    endif.

ENDENHANCEMENT.
ENHANCEMENT 1  ZVBAK_WF_K.    "active version
*

  DATA: gs_vbak TYPE vbak.
  DATA: gs_vbkd TYPE vbkd.
  DATA: flag_zterm(1) type c,
        flag_kvgr1(1) TYPE c,
        flag_kvgr2(1) TYPE c.

IF sy-tcode = 'VA02' and sy-uname = 'XYZ'.
   SELECT SINGLE *
    FROM vbak
    INTO gs_vbak
    WHERE vbeln = vbak-vbeln.
IF gs_vbak-kvgr1 <> xvbak-kvgr1.
  flag_kvgr1 = 'X'.
ENDIF.

IF gs_vbak-kvgr2 <> xvbak-kvgr2.
  flag_kvgr2 = 'X'.
ENDIF.

EXPORT flag_kvgr1 FROM flag_kvgr1 TO MEMORY ID 'KVGR1'.
EXPORT flag_kvgr2 FROM flag_kvgr2 TO MEMORY ID 'KVGR2'.


ENDIF.

ENDENHANCEMENT.
*$*$-End:   (3)---------------------------------------------------------------------------------$*$*

*  vbak-zzfield = xxxx-zzfield2.

ENDFORM.
*eject

*---------------------------------------------------------------------*
*       FORM USEREXIT_MOVE_FIELD_TO_VBAP                              *
*---------------------------------------------------------------------*
*       This userexit can be used to move some fields into the sales  *
*       dokument item workaerea VBAP                                  *
*                                                                     *
*       SVBAP-TABIX = 0:  Create item                                 *
*       SVBAP-TABIX > 0:  Change item                                 *
*                                                                     *
*       This form is called at the end of form VBAP_FUELLEN.          *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_VBAP.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(4) Form USEREXIT_MOVE_FIELD_TO_VBAP, Start                                                                                                           A
*$*$-Start: (4)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 2  ZIMPLENTATION.    "active version
*BREAK-POINT.
ENDENHANCEMENT.
ENHANCEMENT 1  ZSALES_CHANGE_MOVE_VBAP.    "active version

ENDENHANCEMENT.
*$*$-End:   (4)---------------------------------------------------------------------------------$*$*

*  VBAP-zzfield = xxxx-zzfield2.

ENDFORM.
*eject

*---------------------------------------------------------------------*
*       FORM USEREXIT_MOVE_FIELD_TO_VBEP                              *
*---------------------------------------------------------------------*
*       This userexit can be used to move some fields into the sales  *
*       dokument schedule line workaerea VBEP                         *
*                                                                     *
*       SVBEP-TABIX = 0:  Create schedule line                        *
*       SVBEP-TABIX > 0:  Change schedule line                        *
*                                                                     *
*       This form is called at the end of form VBEP_FUELLEN.          *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_VBEP.

*  VBEP-zzfield = xxxx-zzfield2.

ENDFORM.
*eject

*---------------------------------------------------------------------*
*       FORM USEREXIT_MOVE_FIELD_TO_VBKD                              *
*---------------------------------------------------------------------*
*       This userexit can be used to move some fields into the sales  *
*       dokument business data workaerea VBKD                         *
*                                                                     *
*       SVBKD-TABIX = 0:  Create data                                 *
*       SVBKD-TABIX > 0:  Change data                                 *
*                                                                     *
*       This form is called at the end of form VBKD_FUELLEN.          *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_VBKD.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(5) Form USEREXIT_MOVE_FIELD_TO_VBKD, Start                                                                                                           A
*$*$-Start: (5)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZENHANCE_VBKD.    "active version



*IF sy-tcode = 'VA02' and sy-uname = 'XYZ'.
*  DATA : lv_bstkd TYPE bstkd.
*
*  IMPORT lv_bstkd FROM MEMORY ID 'bstkd'.
*  vbkd-bstkd = lv_bstkd.
*
*ENDIF.
*
*IF sy-tcode = 'VA02' and sy-uname = 'XYZ'.
*
*TYPES : BEGIN OF it_vbak,
*          vbeln TYPE vbeln_va,
*          kvgr1 TYPE kvgr1,
*          kvgr2 TYPE kvgr2,
*        END OF it_vbak.
*
*DATA : lt_vbak TYPE STANDARD TABLE OF it_vbak,
*       ls_vbak TYPE it_vbak,
*       lv_bstkd TYPE bstkd.
*
*SELECT vbeln kvgr1 kvgr2
*  FROM vbak
*  INTO TABLE lt_vbak
* WHERE vbeln = vbak-vbeln.
**
*READ TABLE lt_vbak INTO ls_vbak WITH KEY vbeln = vbak-vbeln.
*  IF sy-subrc = 0.
*    IF vbak-kvgr1 NE ls_vbak-kvgr1 or vbak-kvgr2 NE ls_vbak-kvgr2.
*       VBKD-BSTDK+6(2) = VBKD-BSTDK+6(2) + 2.
*       lv_bstkd = VBKD-BSTDK.
*       EXPORT lv_bstkd TO MEMORY ID 'bstkd'.
*    ENDIF.
*  ENDIF.
*ENDIF.



*DATA : lv_zterm TYPE dzterm,
*       flag_zterm TYPE flag.
*IF sy-tcode = 'VA02'.
*  SELECT SINGLE zterm FROM vbkd
*    INTO lv_zterm
*    WHERE vbeln = vbak-vbeln.
*  IF vbkd-zterm <> lv_zterm.
*    flag_zterm = 'X'.
*    EXPORT flag_zterm FROM flag_zterm TO MEMORY ID 'SY-UCOMM'.
*  ENDIF.
*ENDIF.
*DATA :lt_container TYPE STANDARD TABLE OF swr_cont,
*      ls_container TYPE swr_cont.
*IF sy-tcode = 'VA02'.
*  SELECT SINGLE zterm FROM vbkd
*    INTO lv_zterm
*    WHERE vbeln = vbak-vbeln.
*  IF vbkd-zterm = lv_zterm.
*  ELSE.
**    PERFORM call_workflow.
*    flag_zterm = 'X'.
*    ls_container-element = 'DOC_NO'.
*    ls_container-value = vbak-vbeln.
*    APPEND ls_container TO lt_container.
*    CLEAR : ls_container.
*
*    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*      EXPORTING
*        task                      = 'WS99900499'
*        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                    =
*              .
*    IF sy-subrc = 0.
*      EXPORT flag_zterm FROM flag_zterm TO MEMORY ID 'SY-UCOMM'.
*    ENDIF.
*  ENDIF.
*ENDIF.
ENDENHANCEMENT.
ENHANCEMENT 2  ZSALES_CHANGE_MOVE_VBAK.    "active version

DATA : Lv_kvgr1 TYPE VBAK-kvgr1.
DATA : lv_kvgr2 TYPE vbak-kvgr2.
DATA : FAKSK TYPE vbak-faksk.
DATA : kvgr1 TYPE flag.     "FLG_KVGR1 TYPE FLAG.
DATA : kvgr2  TYPE flag.  "FLG_KVGR2 TYPE FLAG.

if sy-tcode = 'VA02' AND SY-uname = 'XYZ'.
      SELECT SINGLE kvgr1
    FROM vbak
    INTO LV_KVGR1
    WHERE vbeln = vbak-vbeln.

   SELECT SINGLE kvgr2
    FROM vbak
    INTO LV_KVGR2
    WHERE vbeln = vbak-vbeln.

   IF LV_KVGR1 <> xvbak-kvgr1.
     kvgr1 = 'X'.

     EXPORT kvgr1 FROM kvgr1 TO MEMORY ID 'KVGR1'.
   ENDIF.

  IF LV_KVGR2 <> xvbak-kvgr2.
    kvgr2 = 'X'.
   EXPORT kvgr2 FROM kvgr2 TO MEMORY ID 'KVGR2'.
  ENDIF.
ENDIF.

ENDENHANCEMENT.
ENHANCEMENT 1  ZSALES_CHANGE_MOVE_VBKD.    "active version

  DATA : gs_zterm TYPE VBKD-zterm.
  DATA : zterm  TYPE flag.

  IF SY-tcode = 'VA02' AND SY-uname = 'XYZ'.
    SELECT SINGLE zterm
      FROM vbkd
      INTO gs_zterm
      WHERE vbeln = vbak-vbeln.
    IF gs_zterm <> xvbkd-zterm.
      zterm  = 'X'.
      EXPORT zterm  FROM zterm TO MEMORY ID 'ZTERM'.
    ENDIF.
  ENDIF.


ENDENHANCEMENT.
ENHANCEMENT 1  ZSALES_CH_ZTERM_WRKF_MB.    "active version
*break-point.
  IF SY-tcode = 'VA02' AND SY-uname = 'XYZ'.
    SELECT SINGLE zterm
      FROM vbkd
      INTO gs_zterm
      WHERE vbeln = vbak-vbeln.
    IF gs_zterm <> xvbkd-zterm.
      zterm  = 'X'.
      EXPORT zterm  FROM zterm TO MEMORY ID 'ZTERM'.
    ENDIF.
  ENDIF.
ENDENHANCEMENT.
ENHANCEMENT 2  ZVBAK_WF_K.    "active version
*

*data : lv_zterm TYPE vbkd-zterm.
*if sy-tcode = 'VA01' or sy-tcode = 'VA02'.
*
*  CLEAR : sy-ucomm.
*  if vbkd-zterm ne 'ZXYZ' .
*    MESSAGE 'You Can enter Only One Payment term : ZXYZ' TYPE 'E' DISPLAY LIKE 'I'.
*   endif.
*  ENDIF.
******
******DATA: flag_zterm(1) type c,
******      gs_vbkd TYPE vbkd.

******IF sy-tcode = 'VA02' and sy-uname = 'XYZ'.
******  SELECT SINGLE *
******      FROM vbkd
******      INTO gs_vbkd
******      WHERE vbeln = vbak-vbeln.
******     IF gs_vbkd-zterm <> xvbkd-zterm.
******       flag_zterm = 'X'.
******     ENDIF.
******EXPORT flag_zterm FROM flag_zterm TO MEMORY ID 'ZTERM'.
******ENDIF.



ENDENHANCEMENT.
*$*$-End:   (5)---------------------------------------------------------------------------------$*$*

*  VBKD-zzfield = xxxx-zzfield2.

ENDFORM.
*eject

*---------------------------------------------------------------------*
*       FORM USEREXIT_NUMBER_RANGE                                    *

*---------------------------------------------------------------------*

*       This userexit can be used to determine the numberranges for   *

*       the internal document number.                                 *

*                                                                     *

*       US_RANGE_INTERN - internal number range                       *
*                                                                     *
*       This form is called from form BELEG_SICHERN                   *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_NUMBER_RANGE USING US_RANGE_INTERN.

* Example: Numer range from TVAK like in standard
* US_RANGE_INTERN = TVAK-NUMKI.

ENDFORM.
*eject

*---------------------------------------------------------------------*
*       FORM USEREXIT_PRICING_PREPARE_TKOMK                           *
*---------------------------------------------------------------------*
*       This userexit can be used to move additional fields into the  *
*       communication table which is used for pricing:                *
*                                                                     *
*       TKOMK for header fields                                       *
*                                                                     *
*       This form is called from form PREISFINDUNG_VORBEREITEN.       *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_PRICING_PREPARE_TKOMK.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(6) Form USEREXIT_PRICING_PREPARE_TKOMK, Start                                                                                                        A
*$*$-Start: (6)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZGR_ENH.    "active version

ENDENHANCEMENT.
*$*$-End:   (6)---------------------------------------------------------------------------------$*$*

*  TKOMK-zzfield = xxxx-zzfield2.

ENDFORM.
*eject

*---------------------------------------------------------------------*
*       FORM USEREXIT_PRICING_PREPARE_TKOMP                           *
*---------------------------------------------------------------------*
*       This userexit can be used to move additional fields into the  *
*       communication table which is used for pricing:                *
*                                                                     *
*       TKOMP for item fields                                         *
*                                                                     *
*       This form is called from form PREISFINDUNG_VORBEREITEN.       *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_PRICING_PREPARE_TKOMP.

*  TKOMP-zzfield = xxxx-zzfield2.
*{   INSERT         ID3K933021                                        1
* SL Ocean Carrier Demo Setup
data: lv_adrnr like vbpa-adrnr.
data: wa_xvbap like vbap.

if vbak-auart = 'ZZOR' or
   vbak-auart = 'ZZQT' or
   vbak-auart = 'ZZSC'.
  tkomp-kvgr2 = vbak-kvgr2.
  loop at xvbpa
    where parvw = 'ZV'.
    tkomp-zzporcit  = xvbpa-lifnr.
    tkomp-zzporland = xvbpa-land1.
  endloop.
  loop at xvbpa
    where parvw = 'ZW'.
    tkomp-zzpodcit  = xvbpa-lifnr.
    tkomp-zzpodland = xvbpa-land1.
  endloop.

* 29.12.2005 Achim Rink, D029766
* move city of partners YV (Load port) and YW (Discharge Port) into comm
* structure
loop at xvbpa
   where parvw = 'YV'.
   tkomp-zzloadport = xvbpa-lifnr.
 endloop.
loop at xvbpa
   where parvw = 'YW'.
   tkomp-zzdischport = xvbpa-lifnr.
 endloop.
* end of inser
* 29.12.2005 Achim Rink, D029766
endif.

* Material Freight Group for THC and CYD
if not vbap-uepos is initial and
   not vbap-stlkn is initial and
   vbap-pstyv eq 'ZSLC'.
   read table xvbap with key posnr = vbap-uepos
              into wa_xvbap.
   tkomp-mfrgr = wa_xvbap-mfrgr.
endif.

* Reference document for pricing agreements in Contract Process
if not vbak-vgbel is initial
   and vbap-pstyv eq 'ZLSC'.
   tkomp-vgbel = vbak-vgbel.
endif.

*}   INSERT

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(7) Form USEREXIT_PRICING_PREPARE_TKOMP, End                                                                                                          A
*$*$-Start: (7)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZENH_SD_PRICING.    "active version

ENDENHANCEMENT.
*$*$-End:   (7)---------------------------------------------------------------------------------$*$*
ENDFORM.
*eject

*---------------------------------------------------------------------*
*       FORM USEREXIT_READ_DOCUMENT                                   *
*---------------------------------------------------------------------*
*       This userexit can be used to read data in additional tables   *
*       when the program reads a sales document.                      *
*                                                                     *
*       This form is called at the end of form BELEG_LESEN.           *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_READ_DOCUMENT.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(8) Form USEREXIT_READ_DOCUMENT, Start                                                                                                                A
*$*$-Start: (8)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZENH_SD_READ_DOC.    "active version
*
ENDENHANCEMENT.
*$*$-End:   (8)---------------------------------------------------------------------------------$*$*

ENDFORM.
*eject

*---------------------------------------------------------------------*
*       FORM USEREXIT_SAVE_DOCUMENT                                   *
*---------------------------------------------------------------------*
*       This userexit can be used to save data in additional tables   *
*       when a document is saved.                                     *
*                                                                     *
*       If field T180-TRTYP contents 'H', the document will be        *
*       created, else it will be changed.                             *
*                                                                     *
*       This form is called at from form BELEG_SICHERN, before COMMIT *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_SAVE_DOCUMENT.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(9) Form USEREXIT_SAVE_DOCUMENT, Start                                                                                                                A
*$*$-Start: (9)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 2  ZCUST_WF_SO.    "active version



****if sy-tcode = 'VA01' or Sy-tcode = 'VA02'.
****  if vbkd-zterm ne 'ZXYZ'.
****    MESSAGE 'You Can take Only One Payment term : ZXYZ' TYPE 'S' DISPLAY LIKE 'E'.
****    PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).
****    FCODE = 'ENT1'.
****    SET SCREEN SYST-DYNNR.
****    LEAVE SCREEN.
****   endif.
****ENDIF.

*IF 1 = 2.

*  DATA : lv_bname TYPE bname_v.
*  CLEAR : lv_bname.
*  SELECT SINGLE bname
*    FROM vbak
*    INTO lv_bname
*    WHERE vbeln = vbak-vbeln.
*
*    IF lv_bname <> xvbak-bname.
*      xvbak-name_flg = 'X'.
*      yvbak-name_flg = 'X'.
*      vbak-name_flg = 'X'.
**      xvbak-augru = '000'.
**      vbak-augru = '000'.
*
*      DATA: LT_CONT TYPE STANDARD TABLE OF SWR_CONT,
*            LS_CONT TYPE SWR_CONT.
*
*      LS_CONT-ELEMENT = 'DOCNO'.
*      LS_CONT-VALUE = vbak-vbeln.
*      APPEND LS_CONT TO LT_CONT.
*      CLEAR LS_CONT.
*
*      CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*        EXPORTING
*          TASK            = 'WS99900502'
*          LANGUAGE        = SY-LANGU
*          DO_COMMIT       = 'X'
*          USER            = SY-UNAME
*        TABLES
*          INPUT_CONTAINER = LT_CONT.
*
*    ENDIF.
*
*ENDIF.
**IF sy-uname = 'XYZ'.
*
*
**ENDIF.
*
*  break XYZ.
*  DATA: LT_CONTAINER TYPE STANDARD TABLE OF SWR_CONT,
*        LS_CONTAINER TYPE SWR_CONT.
*
*
*  LS_CONTAINER-ELEMENT = 'SALES_ORDER'.
*  LS_CONTAINER-VALUE = vbak-vbeln.
*  APPEND LS_CONTAINER TO LT_CONTAINER.
*  CLEAR LS_CONTAINER.
*
*
*
*CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*  EXPORTING
*    TASK            = 'WS99900247'
*    LANGUAGE        = SY-LANGU
*    DO_COMMIT       = 'X'
*    USER            = SY-UNAME
*  TABLES
*    INPUT_CONTAINER = LT_CONTAINER.

*BREAK XYZ.
*DATA: LT_CONTAINER TYPE STANDARD TABLE OF SWR_CONT,
*      LS_CONTAINER TYPE SWR_CONT.
*
*LS_CONTAINER-ELEMENT = 'DOC_NO'.
*LS_CONTAINER-VALUE = vbak-vbeln.
*APPEND LS_CONTAINER TO LT_CONTAINER.
*CLEAR LS_CONTAINER.
*
*
*
*CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*  EXPORTING
*    TASK            = 'WS99900425'
*    LANGUAGE        = SY-LANGU
*    DO_COMMIT       = 'X'
*    USER            = SY-UNAME
*  TABLES
*    INPUT_CONTAINER = LT_CONTAINER.

*BREAK XYZ.
*DATA : lv_zterm TYPE dzterm,
*       flag_zterm TYPE flag.
*DATA : lv_kvgr2 TYPE kvgr2,
*       flag_kvgr2 TYPE flag.
*DATA :lt_container TYPE STANDARD TABLE OF swr_cont,
*      ls_container TYPE swr_cont.
*IF sy-tcode = 'VA02'.
*  SELECT SINGLE zterm FROM vbkd
*    INTO lv_zterm
*    WHERE vbeln = vbak-vbeln.
*  SELECT SINGLE kvgr2 FROM vbak
*    INTO lv_kvgr2
*    WHERE vbeln = vbak-vbeln.
*  IF vbak-kvgr2 <> lv_kvgr2.
*    flag_kvgr2 = 'X'.
*    EXPORT flag_zterm FROM flag_zterm TO MEMORY ID 'SY-UNAME'.
*  ENDIF.
*  IF vbkd-zterm <> lv_zterm.
*    flag_zterm = 'X'.
*    EXPORT flag_zterm FROM flag_zterm TO MEMORY ID 'SY-UCOMM'.
*  ENDIF.
***************************************************************************
*BREAK anju_d.
*IF sy-tcode = 'VA02'.
DATA : flag_kvgr2 TYPE flag.
*       flag_zterm TYPE flag.
*
DATA :lt_container TYPE STANDARD TABLE OF swr_cont,
      ls_container TYPE swr_cont.
*
*IMPORT flag_kvgr2 TO flag_kvgr2 FROM MEMORY ID 'SY-UNAME'.
*IMPORT flag_zterm TO flag_zterm FROM MEMORY ID 'SY-UCOMM'.
*wait UP TO 2 SECONDS.
*  IF flag_kvgr2 <> ''. "OR
*     "flag_zterm <> ''.
*

*    ls_container-element = 'DOC_NO'.
*    ls_container-value = vbak-vbeln.
*    APPEND ls_container TO lt_container.
*    CLEAR : ls_container.
*
*    ls_container-element = 'FLAG_KVGR2'."'flag_kvgr2'.
*    ls_container-value = flag_kvgr2.
*    APPEND ls_container TO lt_container.
*    CLEAR : ls_container.
*
**    ls_container-element = 'FLAG_ZTERM'."'flag_zterm'.
**    ls_container-value = flag_zterm.
**    APPEND ls_container TO lt_container.
**    CLEAR : ls_container.
*
*    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*      EXPORTING
*        task                      = 'WS99900499'
*        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                    =
*              .
*  ENDIF.
*
*  wait UP TO 2 SECONDS.
*  IF flag_zterm <> ''.
*    refresh lt_container.
*    ls_container-element = 'DOC_NO'.
*    ls_container-value = vbak-vbeln.
*    APPEND ls_container TO lt_container.
*    CLEAR : ls_container.
*
*    ls_container-element = 'FLAG_ZTERM'."'flag_zterm'.
*    ls_container-value = flag_zterm.
*    APPEND ls_container TO lt_container.
*    CLEAR : ls_container.
*
*    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*      EXPORTING
*        task                      = 'WS99900499'
*        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                    =
*              .
*
*  ENDIF.
*
*ENDIF.
*******************************************************************************
IF sy-tcode = 'VA02' and sy-UNAME = 'XYZ'.
DATA : flg_audat TYPE flag.
IMPORT flg_audat TO flg_audat FROM MEMORY ID 'FLG_AUDAT'.
  IF flg_audat <> ''.
*  DATA :lt_container TYPE STANDARD TABLE OF swr_cont,
*        ls_container TYPE swr_cont.

    ls_container-element = 'SONO'.
    ls_container-value = vbak-vbeln.
    APPEND ls_container TO lt_container.
    CLEAR : ls_container.

    ls_container-element = 'FLG_AUDAT'.
    ls_container-value = flg_audat.
    APPEND ls_container TO lt_container.
    CLEAR : ls_container.

    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
      EXPORTING
        task                      = 'WS99900504'
        language                  = sy-langu
        do_commit                 = 'X'
        user                      = sy-uname
      TABLES
        input_container           = lt_container.
  ENDIF.
ENDIF.
ENDENHANCEMENT.
ENHANCEMENT 2  ZDOC_DATE_VALIDATION.    "active version
*
ENDENHANCEMENT.
ENHANCEMENT 3  ZFM_VA02_DATE.    "active version
DATA : lv_bstkd TYPE bstkd.
IMPORT lv_bstkd FROM MEMORY ID 'bstkd'.

vbkd-bstkd = lv_bstkd.
ENDENHANCEMENT.
ENHANCEMENT 2  ZNK_DATEVALIDATION.    "active version
*BREAK NAVEENC.
*if sy-ucomm = 'SICH'.
**  FCODE = 'ENT1'.
*  IF VBAK-audat < SY-datum.
*    MESSAGE 'SO DATE should not be less than the current date' TYPE 'E'.
*  endif.

* PERFORM folge_gleichsetzen(saplv00f).
*         fcode = 'ENT1'.
*         SET SCREEN syst-dynnr.
*         LEAVE SCREEN.
*endif.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(10) Form USEREXIT_SAVE_DOCUMENT, Start, Enhancement ZNK_DATEVALIDATION, End                                                                          A
*$*$-Start: (10)--------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZSALES_CHANGE.    "active version


*DATA : lv_ZTERM TYPE vbkd-zterm.
*DATA : LV_KVGR1 TYPE VBAK-kvgr1.
*DATA : LV_KVGR2 TYPE vbak-kvgr2.

DATA : Lv_kvgr1 TYPE VBAK-kvgr1.
DATA : lv_kvgr2 TYPE vbak-kvgr2.
DATA : lv_zterm TYPE VBKD-zterm.
*DATA : FAKSK TYPE VBAK-faksk.
DATA : kvgr1 TYPE FLAG.
DATA : kvgr2 TYPE FLAG.
DATA : zterm  TYPE flag.

    DATA : gt_cont2_zterm TYPE STANDARD TABLE OF swr_cont,
           gs_cont2_zterm TYPE swr_cont.

    DATA : gt_con2_zkvgr1 TYPE STANDARD TABLE OF swr_cont,
           gs_con2_zkvgr1 TYPE swr_cont.

    DATA : gt_con2_zkvgr2 TYPE STANDARD TABLE OF swr_cont,
           gs_con2_zkvgr2 TYPE swr_cont.

**  IF sy-tcode = 'VA02' AND sy-uname = ‘XYZ'..
**
**     SELECT SINGLE zterm
**      FROM vbkd
**      INTO lv_ZTERM
**      WHERE vbeln = VBAK-vbeln.
**
**     SELECT SINGLE kvgr1
**    FROM vbak
**    INTO LV_KVGR1
**    WHERE vbeln = vbak-vbeln.
**
**   SELECT SINGLE kvgr2
**    FROM vbak
**    INTO LV_KVGR2
**    WHERE vbeln = vbak-vbeln.
**
**
**    if lv_ZTERM <> xvbkd-zterm.
**    clear : gt_cont2_zterm[].
**    IMPORT ZTERM TO ZTERM FROM MEMORY ID 'ZTERM'.
**    VBAK-zzterm = 'X'.
**
**     gs_cont2_zterm-element = 'SO_NO'.
**     gs_cont2_zterm-value = vbak-vbeln.
**     APPEND gs_cont2_zterm to gt_cont2_zterm.
**     CLEAR: gs_cont2_zterm.
**
**      gs_cont2_zterm-element = 'ZTERM'.
**     gs_cont2_zterm-value = zterm.
**     APPEND gs_cont2_zterm to gt_cont2_zterm.
**     CLEAR: gs_cont2_zterm.
**
**     CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
**       EXPORTING
**         task                     = 'WS99900543'
**        LANGUAGE                  = SY-LANGU
**        DO_COMMIT                 = 'X'
**        USER                      = SY-UNAME
**      TABLES
**        INPUT_CONTAINER           = gt_cont2_zterm.
**   ENDIF.
**
**  if LV_KVGR1 <> xvbak-kvgr1.
**    clear : gt_cont2_zterm[].
**    IMPORT KVGR1 TO KVGR1 FROM MEMORY ID 'KVGR1'.
**    VBAK-zzkvgr1 = 'X'.
**
**     gs_con2_zkvgr1-element = 'SO_NO'.
**     gs_con2_zkvgr1-value = VBAK-vbeln.
**     APPEND gs_con2_zkvgr1 to gt_con2_zkvgr1.
**     CLEAR : gs_con2_zkvgr1.
**
**     gs_con2_zkvgr1-element = 'KVGR1'.
**     gs_con2_zkvgr1-value = KVGR1.
**     APPEND gs_con2_zkvgr1 to gt_con2_zkvgr1.
**     CLEAR : gs_con2_zkvgr1.
**
**     CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
**       EXPORTING
**         task                     = 'WS99900543'
**        LANGUAGE                  = SY-LANGU
**        DO_COMMIT                 = 'X'
**        USER                      = SY-UNAME
**      TABLES
**        INPUT_CONTAINER           = gt_con2_zkvgr1.
**   ENDIF.
**
**   if Lv_kvgr2 <>  xvbak-kvgr2.
**     clear : gt_cont2_zterm[].
**     IMPORT KVGR2 TO KVGR2 FROM MEMORY ID 'KVGR2'.
**     vbak-zzkvgr2 = 'X'.
**
**     gs_con2_zkvgr2-element = 'SO_NO'.
**     gs_con2_zkvgr2-value = VBAK-vbeln.
**     APPEND gs_con2_zkvgr2 to gt_con2_zkvgr2.
**     CLEAR : gs_con2_zkvgr2.
**
**     gs_con2_zkvgr2-element = 'KVGR2'.
**     gs_con2_zkvgr2-value = KVGR2.
**     APPEND gs_con2_zkvgr2 to gt_con2_zkvgr2.
**     CLEAR : gs_con2_zkvgr2.
**
**      CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
**       EXPORTING
**         task                     = 'WS99900543'
**        LANGUAGE                  = SY-LANGU
**        DO_COMMIT                 = 'X'
**        USER                      = SY-UNAME
**      TABLES
**        INPUT_CONTAINER           = gt_con2_zkvgr2.
**   ENDIF.
**ENDIF.



**********Workflow For Multi Level****
DATA : lv_matkl TYPE vbap-MVGR1.
DATA : zmatkl TYPE flag.
DATA : GS_VBAP TYPE vbapvb.


DATA : gt_cont2_zmatkl TYPE STANDARD TABLE OF swr_cont,
       gs_cont2_zmatkl TYPE swr_cont.


if sy-tcode = 'VA02' AND sy-uname = 'XYZ'.
 read table xvbap into gs_vbap index 1.
 if sy-subrc = 0.
  SELECT SINGLE MVGR1
    FROM vbap
    INTO lv_matkl
    WHERE vbeln =  xvbap-vbeln
      and posnr = '000010'.
 endif.
 clear : gs_vbap.

 READ TABLE xvbap into gs_vbap with KEY posnr = '000010'.
  if lv_matkl <> gs_vbap-mvgr1.  "xvbap-mvgr1.
    CLEAR : gt_cont2_zmatkl[].
*    IMPORT zmatkl to zmatkl FROM MEMORY id 'ZMATKL'.
*    VBAp-zmatkl = 'X'.

     gs_cont2_zmatkl-element = 'VBELN'.
     gs_cont2_zmatkl-value = vbak-vbeln.
     APPEND gs_cont2_zmatkl to gt_cont2_zmatkl.
     CLEAR: gs_cont2_zmatkl.

    gs_cont2_zmatkl-element = 'ZMATKL'.
     gs_cont2_zmatkl-value = xvbap-zmatkl.
     APPEND gs_cont2_zmatkl to gt_cont2_zmatkl.
     CLEAR: gs_cont2_zmatkl.


     CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
       EXPORTING
         task                     = 'WS99900552'
        LANGUAGE                  = SY-LANGU
        DO_COMMIT                 = 'X'
        USER                      = SY-UNAME
      TABLES
        INPUT_CONTAINER           = gt_cont2_zmatkl.
   ENDIF.

*    READ TABLE yvbap into gs_vbap with KEY vbeln = xvbap-vbeln
*                                        posnr = '000010'.
*  if lv_matkl <> gs_vbap-mvgr1.  "xvbap-mvgr1.
*    CLEAR : gt_cont2_zmatkl[].
**    IMPORT zmatkl to zmatkl FROM MEMORY id 'ZMATKL'.
**    VBAp-zmatkl = 'X'.
*
*     gs_cont2_zmatkl-element = 'VBELN'.
*     gs_cont2_zmatkl-value = vbak-vbeln.
*     APPEND gs_cont2_zmatkl to gt_cont2_zmatkl.
*     CLEAR: gs_cont2_zmatkl.
*
*    gs_cont2_zmatkl-element = 'ZMATKL'.
*     gs_cont2_zmatkl-value = zmatkl.
*     APPEND gs_cont2_zmatkl to gt_cont2_zmatkl.
*     CLEAR: gs_cont2_zmatkl.
*
*
*     CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*       EXPORTING
*         task                     = 'WS99900552'
*        LANGUAGE                  = SY-LANGU
*        DO_COMMIT                 = 'X'
*        USER                      = SY-UNAME
*      TABLES
*        INPUT_CONTAINER           = gt_cont2_zmatkl.
*   ENDIF.

ENDIF.


ENDENHANCEMENT.
ENHANCEMENT 1  ZSALES_CH_WRKF.    "active version

DATA : wa_kvgr1 TYPE VBAK-kvgr1.
DATA : wa_kvgr2 TYPE vbak-kvgr2.
DATA : wa_zterm TYPE VBKD-zterm.
DATA : fkvgr1 TYPE FLAG.
DATA : fkvgr2 TYPE FLAG.
DATA : fzterm  TYPE flag.

    DATA : it_cont2_zterm TYPE STANDARD TABLE OF swr_cont,
           wa_cont2_zterm TYPE swr_cont.

    DATA : it_con2_zkvgr1 TYPE STANDARD TABLE OF swr_cont,
           wa_con2_zkvgr1 TYPE swr_cont.

    DATA : it_con2_zkvgr2 TYPE STANDARD TABLE OF swr_cont,
           wa_con2_zkvgr2 TYPE swr_cont.

  IF sy-tcode = 'VA02' AND sy-uname = 'XYZ'.

     SELECT SINGLE zterm
      FROM vbkd
      INTO wa_ZTERM
      WHERE vbeln = VBAK-vbeln.

     SELECT SINGLE kvgr1
    FROM vbak
    INTO wa_KVGR1
    WHERE vbeln = vbak-vbeln.

   SELECT SINGLE kvgr2
    FROM vbak
    INTO wa_KVGR2
    WHERE vbeln = vbak-vbeln.

break-point.
    if wa_ZTERM <> xvbkd-zterm.
    clear : gt_cont2_zterm[].
    IMPORT ZTERM TO fZTERM FROM MEMORY ID 'ZTERM'.
    VBAK-zzterm = 'X'.

     wa_cont2_zterm-element = 'VBELN'.
     wa_cont2_zterm-value = vbak-vbeln.
     APPEND wa_cont2_zterm to it_cont2_zterm.
     CLEAR: wa_cont2_zterm.

     wa_cont2_zterm-element = 'ZTERM'.
     wa_cont2_zterm-value = fzterm.
     APPEND wa_cont2_zterm to it_cont2_zterm.
     CLEAR: wa_cont2_zterm.

*     CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*       EXPORTING
*         task                     = 'WS99900554'
*        LANGUAGE                  = SY-LANGU
*        DO_COMMIT                 = 'X'
*        USER                      = SY-UNAME
*      TABLES
*        INPUT_CONTAINER           = it_cont2_zterm.
     CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
       EXPORTING
         task                     = 'WS99900562'
        LANGUAGE                  = SY-LANGU
        DO_COMMIT                 = 'X'
        USER                      = SY-UNAME
      TABLES
        INPUT_CONTAINER           = it_cont2_zterm.
   ENDIF.

*break-point.
*  if wa_KVGR1 <> xvbak-kvgr1.
*    clear : gt_cont2_zterm[].
*    IMPORT KVGR1 TO fKVGR1 FROM MEMORY ID 'KVGR1'.
*    VBAK-zzkvgr1 = 'X'.
*
*     wa_con2_zkvgr1-element = 'VBELN'.
*     wa_con2_zkvgr1-value = VBAK-vbeln.
*     APPEND wa_con2_zkvgr1 to it_con2_zkvgr1.
*     CLEAR : wa_con2_zkvgr1.
*
*     wa_con2_zkvgr1-element = 'KVGR1'.
*     wa_con2_zkvgr1-value = fKVGR1.
*     APPEND wa_con2_zkvgr1 to it_con2_zkvgr1.
*     CLEAR : wa_con2_zkvgr1.

*     CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*       EXPORTING
*         task                     = 'WS99900554'
*        LANGUAGE                  = SY-LANGU
*        DO_COMMIT                 = 'X'
*        USER                      = SY-UNAME
*      TABLES
*        INPUT_CONTAINER           = it_con2_zkvgr1.
*     CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*       EXPORTING
*         task                     = 'WS99900562'
*        LANGUAGE                  = SY-LANGU
*        DO_COMMIT                 = 'X'
*        USER                      = SY-UNAME
*      TABLES
*        INPUT_CONTAINER           = it_con2_zkvgr1.
*
*   ENDIF.

break-point.
   if wa_kvgr2 <>  xvbak-kvgr2.
     clear : it_con2_zkvgr1[].
     IMPORT KVGR2 TO fKVGR2 FROM MEMORY ID 'KVGR2'.
     vbak-zzkvgr2 = 'X'.

     wa_con2_zkvgr2-element = 'VBELN'.
     wa_con2_zkvgr2-value = VBAK-vbeln.
     APPEND wa_con2_zkvgr2 to it_con2_zkvgr2.
     CLEAR : wa_con2_zkvgr2.

     wa_con2_zkvgr2-element = 'KVGR2'.
     wa_con2_zkvgr2-value = fKVGR2.
     APPEND wa_con2_zkvgr2 to it_con2_zkvgr2.
     CLEAR : wa_con2_zkvgr2.

*      CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*       EXPORTING
*         task                     = 'WS99900554'
*        LANGUAGE                  = SY-LANGU
*        DO_COMMIT                 = 'X'
*        USER                      = SY-UNAME
*      TABLES
*        INPUT_CONTAINER           = it_con2_zkvgr2.
     CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
       EXPORTING
         task                     = 'WS99900562'
        LANGUAGE                  = SY-LANGU
        DO_COMMIT                 = 'X'
        USER                      = SY-UNAME
      TABLES
        INPUT_CONTAINER           = it_con2_zkvgr2.

   ENDIF.
ENDIF.

*----------------------------------------------------*
ENDENHANCEMENT.
*$*$-End:   (10)--------------------------------------------------------------------------------$*$*
ENDENHANCEMENT.
ENHANCEMENT 1  ZSALES_WF_K.    "active version
*
  DATA: gs_vbkd TYPE vbkd.
  DATA: gs_vbak TYPE vbak.
  IF sy-tcode = 'VA02' and sy-uname = ‘XYZ'.
    DATA:lt_cont_zterm TYPE STANDARD TABLE OF swr_cont,
         ls_cont_zterm TYPE swr_cont.
    DATA:lt_cont_kvgr2 TYPE STANDARD TABLE OF swr_cont,
         ls_cont_kvgr2 TYPE swr_cont.
    DATA:ls_txt(50) TYPE c.
    DATA:flag_zterm(1) TYPE c.
*         flag_kvgr2(1) TYPE c.

      SELECT SINGLE *
        FROM vbkd
        INTO gs_vbkd
        WHERE vbeln = vbak-vbeln.

      SELECT SINGLE *
        FROM vbak
        INTO gs_vbak
        WHERE vbeln = vbak-vbeln.

    IF gs_vbkd-zterm <> xvbkd-zterm.
      clear : flag_zterm.
      flag_zterm = 'X'.
*      IMPORT flag_zterm TO flag_zterm FROM MEMORY ID 'ZTERM'.
      VBAK-zzterm1 = flag_zterm.

      ls_cont_zterm-element = 'VBELN'.
      ls_cont_zterm-value = vbak-vbeln.
      APPEND ls_cont_zterm to lt_cont_zterm.
      CLEAR: ls_cont_zterm.

      ls_cont_zterm-element = 'ZTERM'.
      ls_cont_zterm-value = flag_zterm.
      APPEND ls_cont_zterm to lt_cont_zterm.
      CLEAR: ls_cont_zterm.

      ls_txt = 'Payment Terms'.
      ls_cont_zterm-element = 'LS_TEXT'.
      ls_cont_zterm-value = ls_txt.
      APPEND ls_cont_zterm to lt_cont_zterm.
      CLEAR: ls_cont_zterm.


      CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
        EXPORTING
          task                      = 'WS99900551'
         LANGUAGE                  = SY-LANGU
         DO_COMMIT                 = 'X'
         USER                      = SY-UNAME
       TABLES
         INPUT_CONTAINER           = lt_cont_zterm.
    ENDIF.

      IF gs_vbak-kvgr2 <> xvbak-kvgr2.
        CLEAR:flag_kvgr2.
      IMPORT flag_kvgr2 TO flag_kvgr2 FROM MEMORY ID 'KVGR2'.
      VBAK-zzkvgr2 = flag_kvgr2.

      ls_cont_kvgr2-element = 'VBELN'.
      ls_cont_kvgr2-value = vbak-vbeln.
      APPEND ls_cont_kvgr2 to lt_cont_kvgr2.
      CLEAR: ls_cont_kvgr2.

      ls_cont_kvgr2-element = 'KVGR2'.
      ls_cont_kvgr2-value = flag_kvgr2.
      APPEND ls_cont_kvgr2 to lt_cont_kvgr2.
      CLEAR:ls_cont_kvgr2.

      ls_txt = 'Customer Group2'.
      ls_cont_kvgr2-element = 'LS_TEXT'.
      ls_cont_kvgr2-value = ls_txt.
      APPEND ls_cont_kvgr2 to lt_cont_kvgr2.
      CLEAR: ls_cont_kvgr2.

     CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
       EXPORTING
        task                      = 'WS99900551'
       LANGUAGE                  = SY-LANGU
        DO_COMMIT                 = 'X'
        USER                      = SY-UNAME
     TABLES
       INPUT_CONTAINER           = lt_cont_kvgr2.
      ENDIF.
ENDIF.


*    DATA: lt_cont2 TYPE STANDARD TABLE OF swr_cont,
*          ls_cont2 TYPE swr_cont.
*
*    DATA: lt_cont_kvgr1 TYPE STANDARD TABLE OF swr_cont,
*          ls_cont_kvgr1 TYPE swr_cont.
*
*    DATA: lt_cont_kvgr2 TYPE STANDARD TABLE OF swr_cont,
*          ls_cont_kvgr2 TYPE swr_cont.
*    data : flag_zterm(1) type c,
*           flag_kvgr1(1) TYPE c,
*           flag_kvgr2(1) TYPE c.
*
*    SELECT SINGLE *
*      FROM vbkd
*      INTO gs_vbkd
*      WHERE vbeln = vbak-vbeln.
*
*    SELECT SINGLE *
*      FROM vbak
*      INTO gs_vbak
*      WHERE vbeln = vbak-vbeln.
*
*   IF gs_vbkd-zterm <> xvbkd-zterm.
*      clear : flag_zterm.
*      flag_zterm = 'X'.
**      IMPORT flag_zterm TO flag_zterm FROM MEMORY ID 'ZTERM'.
*      VBAK-zzterm1 = flag_zterm.
*
*      ls_cont2-element = 'VBELN'.
*      ls_cont2-value = vbak-vbeln.
*      APPEND ls_cont2 to lt_cont2.
*      CLEAR: ls_cont2.
*
*      ls_cont2-element = 'ZTERM'.
*      ls_cont2-value = flag_zterm.
*      APPEND ls_cont2 to lt_cont2.
*      CLEAR: ls_cont2.
*
*    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*      EXPORTING
*        task                      = 'WS99900540'
*       LANGUAGE                  = SY-LANGU
*       DO_COMMIT                 = 'X'
*       USER                      = SY-UNAME
*     TABLES
*       INPUT_CONTAINER           = lt_cont2.
*    ENDIF.
*
*    IF gs_vbak-kvgr1 <> xvbak-kvgr1.
**      flag_kvgr1 = 'X'.
*      IMPORT flag_kvgr1 TO flag_kvgr1 FROM MEMORY ID 'KVGR1'.
*      VBAK-zzkvgr1_1 = flag_kvgr1.
*
*      ls_cont_kvgr1-element = 'VBELN'.
*      ls_cont_kvgr1-value = vbak-vbeln.
*      APPEND ls_cont_kvgr1 to lt_cont_kvgr1.
*      CLEAR: ls_cont_kvgr1.
*
*      ls_cont_kvgr1-element = 'KVGR1'.
*      ls_cont_kvgr1-value = flag_kvgr1.
*      APPEND ls_cont_kvgr1 to lt_cont_kvgr1.
*      CLEAR:ls_cont_kvgr1.
*
*      CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*      EXPORTING
*        task                      = 'WS99900540'
*       LANGUAGE                  = SY-LANGU
*       DO_COMMIT                 = 'X'
*       USER                      = SY-UNAME
*     TABLES
*       INPUT_CONTAINER           = lt_cont_kvgr1.
*    ENDIF.
*   IF gs_vbak-kvgr2 <> xvbak-kvgr2.
**      flag_kvgr2 = 'X'.
*      IMPORT flag_kvgr2 TO flag_kvgr2 FROM MEMORY ID 'KVGR2'.
*      VBAK-zzkvgr2 = flag_kvgr2.
*
*      ls_cont_kvgr2-element = 'VBELN'.
*      ls_cont_kvgr2-value = vbak-vbeln.
*      APPEND ls_cont_kvgr2 to lt_cont_kvgr2.
*      CLEAR: ls_cont_kvgr2.
*
*      ls_cont_kvgr2-element = 'KVGR2'.
*      ls_cont_kvgr2-value = flag_kvgr2.
*      APPEND ls_cont_kvgr2 to lt_cont_kvgr2.
*      CLEAR:ls_cont_kvgr2.
*
*
*     CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*       EXPORTING
*        task                      = 'WS99900540'
*       LANGUAGE                  = SY-LANGU
*        DO_COMMIT                 = 'X'
*        USER                      = SY-UNAME
*     TABLES
*       INPUT_CONTAINER           = lt_cont_kvgr2.
*    ENDIF.
*  ENDIF.
*IF sy-tcode = 'VA02' and sy-uname = 'KRUTIS'.
*  DATA: LT_CONT2 TYPE STANDARD TABLE OF SWR_CONT,
*        LS_CONT2 TYPE SWR_CONT.
*
*     SELECT SINGLE *
*       FROM vbkd
*       INTO gs_vbkd
*       WHERE vbeln = vbak-vbeln.
*
*    IF gs_vbkd-zterm <> xvbkd-zterm.
*      ls_cont2-element = 'VBELN'.
*      ls_cont2-value = vbak-vbeln.
*      APPEND ls_cont2 to lt_cont2.
*      CLEAR: ls_cont2.
*
*      ls_cont2-element = 'KUNNR'.
*      ls_cont2-value = vbak-KUNNR.
*      APPEND ls_cont2 to lt_cont2.
*      CLEAR: ls_cont2.
**      ls_cont2-element = 'ZTERM'.
**      ls_cont2-value = xvbkd-zterm.
**      APPEND ls_cont2 to lt_cont2.
**      CLEAR  ls_cont2.
*
*    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*      EXPORTING
*        TASK                      = 'WS99900534'
*       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_cont2
**       MESSAGE_LINES             =
**       MESSAGE_STRUCT            =
**       AGENTS                    =              .
*
* ENDIF.
*
*ENDIF.

ENDENHANCEMENT.
ENHANCEMENT 1  ZWF_SO_CHANGE.    "active version
IF sy-uname = 'CHIRAGB'.
BREAK chiragb.
    IF xvbak-name_flg = 'X'." lv_name <> xvbak-bname.

      DATA: LT_CONT1 TYPE STANDARD TABLE OF SWR_CONT,
            LS_CONT1 TYPE SWR_CONT.

      LS_CONT1-ELEMENT = 'VBELN'.
      LS_CONT1-VALUE = vbak-vbeln.
      APPEND LS_CONT1 TO LT_CONT1.
      CLEAR LS_CONT1.

      CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
        EXPORTING
          TASK            = 'WS99900502'
          LANGUAGE        = SY-LANGU
          DO_COMMIT       = 'X'
          USER            = SY-UNAME
        TABLES
          INPUT_CONTAINER = LT_CONT1.

    ENDIF.

ENDIF.
ENDENHANCEMENT.
ENHANCEMENT 1  ZWF_TRIGGER.    "active version
**
*  BREAK SUNILM.

*
*  IF SY-TCODE = 'VA02' AND SY-UNAME = ‘XYZ’.
*    DATA LV_DATE TYPE MAHDT.
*
*  IF XVBAK-BNAME IS NOT INITIAL AND XVBAK-BNAME = ‘XYZ’.

*    DATA: GT_CONT TYPE STANDARD TABLE OF SWR_CONT,
*          GS_CONT TYPE SWR_CONT.
*    GS_CONT-ELEMENT = 'ORD NO'.
*    GS_CONT-VALUE =  VBAK-VBELN.
*    APPEND GS_CONT TO GT_CONT.
*    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*      EXPORTING
*        TASK                      = 'WS99900512'
*       LANGUAGE                  = SY-LANGU
*       DO_COMMIT                 = 'X'
*       USER                      = SY-UNAME
*      TABLES
*       INPUT_CONTAINER           = GT_CONT.
*  ENDIF.
*  ENDIF.

*IF sy-tcode = 'VA02' and sy-uname = ‘XYZ’.
*
*  data :lv_ord type vbeln_va,
**        lv_old type BNAME_V,
*        lv_new type BNAME_V.
*  lv_ord = xvbak-vbeln.
*  select single bname from vbak into lv_new where vbeln = lv_ord.
* IF lv_new NE vbak-bname.   "xvbak-bname.
*   TYPES:BEGIN OF TY_TYAU,
*  AUGRU TYPE TVAUT-AUGRU,
**  VAUNA TYPE TVAUT-VAUNA,
*  BEZEI TYPE TVAUT-BEZEI,
*  END OF TY_TYAU.
*
*  DATA :GT_TYAU TYPE STANDARD TABLE OF TY_TYAU,
*        GS_TYAU TYPE TY_TYAU.
*  SELECT SINGLE  AUGRU BEZEI FROM TVAUT INTO GS_TYAU WHERE AUGRU = 460 AND SPRAS = 'E' .
*
*   DATA: GT_CONT TYPE STANDARD TABLE OF SWR_CONT,
*          GS_CONT TYPE SWR_CONT.
*
*    GS_CONT-ELEMENT = 'ORD NO'.
*    GS_CONT-VALUE =  VBAK-VBELN.
*    APPEND GS_CONT TO GT_CONT.
*
**    types: begin of ty_xvbak,
**      vbeln type vbeln_va,
**      augru type augru,
**      end of ty_xvbak.
**
**      data : gt_xvbak type TABLE OF ty_xvbak,
**            gs_xvbak type ty_xvbak.
*
** gs_xvbak-vbeln = xvbak-vbeln.
**  gs_xvbak-augru = gs_tyau-augru.
**  append gs_xvbak to gt_xvbak.
**
**  xvbak-augru = gs_tyau-augru.
**  VBAK-AUGRU = GS_TYAU-AUGRU.
**  modify xvbak from xvbak.
**data wa_vbak type vbak.
**select single * from vbak into wa_vbak where vbeln = lv_ord.
**  if sy-subrc = 0.
**    wa_vbak-augru = 460.
**    modify vbak from wa_vbak.
**    UPDATE vbak set augru =  GS_TYAU-augru where vbeln = lv_ord.
**    endif.
**
*   CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*      EXPORTING
*        TASK                      = 'WS99900512'
*       LANGUAGE                  = SY-LANGU
*       DO_COMMIT                 = 'X'
*       USER                      = SY-UNAME
*      TABLES
*       INPUT_CONTAINER           = GT_CONT.
* ENDIF.
*  endif.

ENDENHANCEMENT.
*$*$-End:   (9)---------------------------------------------------------------------------------$*$*

* Example:
* CALL FUNCTION 'ZZ_EXAMPLE'
*      IN UPDATE TASK
*      EXPORTING
*           ZZTAB = ZZTAB.
*{   INSERT         IDTK919292                                        2
* Pharma DEA demo script
*TABLES:
*   zzdea_qty.          "quantity per license, material and period --> global in MV45ATZZ

DATA:
    v_zzdea_qty_in_dea_units TYPE i,
    v_zzdea_ship_to          LIKE vbpa-kunnr.


  LOOP AT xvbap
    WHERE updkz NE updkz_delete
    AND zzdea_license IS NOT INITIAL
    and ABGRU IS initial.

* Determine ship-to partner for this item
    READ TABLE xvbpa WITH KEY vbeln = xvbap-vbeln
                              posnr = xvbap-posnr
                              parvw = 'WE'.
    IF sy-subrc NE 0.
      READ TABLE xvbpa WITH KEY vbeln = xvbap-vbeln
                                posnr = '000000'
                                parvw = 'WE'.
      IF sy-subrc NE 0.
        MESSAGE e100(zzdea_msg).
      ENDIF.
    ENDIF.
    MOVE xvbpa-kunnr TO v_zzdea_ship_to.


    SELECT SINGLE FOR UPDATE *
      FROM zzdea_qty
      WHERE ship_to EQ v_zzdea_ship_to AND
            material EQ xvbap-matnr.
    IF sy-subrc = 0.

* Convert order quantity to the DEA quantity unit
        CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
          EXPORTING
            input                = xvbap-klmeng
            kzmeinh              = space
            matnr                = xvbap-matnr
            meinh                = zzdea_qty-qty_unit
          IMPORTING
            output               = v_zzdea_qty_in_dea_units
          EXCEPTIONS
            conversion_not_found = 1.

      zzdea_qty-cumulative_qty = zzdea_qty-cumulative_qty +
                                 v_zzdea_qty_in_dea_units.
      zzdea_qty-order_items    = zzdea_qty-order_items + 1.
      zzdea_qty-avg_qty        = zzdea_qty-cumulative_qty /
                                 zzdea_qty-order_items.
      UPDATE zzdea_qty FROM zzdea_qty.
    ENDIF.
  ENDLOOP.

*}   INSERT
*{   INSERT         DH3K911961                                        3
* D037609
* Insert Mobile Push Function
if T180-TRTYP eq 'H' or T180-TRTYP eq 'V' or T180-TRTYP eq 'L' .
if vbak-KUNNR eq '0000301185'
or vbak-KUNNR eq '0000301194'
or vbak-KUNNR eq '0000100239'
or vbak-KUNNR eq '0000301200'.

CALL FUNCTION 'Z_MOBILEIDES_ORDER_PUSH' IN UPDATE TASK
  EXPORTING
    vbeln          = vbak-VBELN
    customer       = vbak-KUNNR
    TASK       =  T180-TRTYP.


endif.
endif.

*--

*}   INSERT
*{   INSERT         IDTK932476                                        4
* include for IDES Exposure Mgmt Demo
* inserted by d047969 at 30.11.2009
include ztr_exposure_from_sales_order.
*}   INSERT

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(11) Form USEREXIT_SAVE_DOCUMENT, End                                                                                                                 A
*$*$-Start: (11)--------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZCUST_WF_SO.    "active version
*





ENDENHANCEMENT.
*$*$-End:   (11)--------------------------------------------------------------------------------$*$*
ENDFORM.
*eject
*---------------------------------------------------------------------*
*       FORM USEREXIT_SAVE_DOCUMENT_PREPARE                           *
*---------------------------------------------------------------------*
*       This userexit can be used for changes or checks, before a     *
*       document is saved.                                            *
*                                                                     *
*       If field T180-TRTYP contents 'H', the document will be        *
*       created, else it will be changed.                             *
*                                                                     *
*       This form is called at the beginning of form BELEG_SICHERN    *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_SAVE_DOCUMENT_PREPARE.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(12) Form USEREXIT_SAVE_DOCUMENT_PREPARE, Start                                                                                                       A
*$*$-Start: (12)--------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZCS_DATEVALIDATION.    "active version

*IF sy-tcode = 'VA01' or sy-tcode = 'VA02'.
*IF VBAK-AUDAT < SY-DATUM.
*   FCODE = 'ENT1'.
*  MESSAGE E040(ZCS_MSG).
*    ENDIF.
*endif.
ENDENHANCEMENT.
ENHANCEMENT 3  ZCUST_WF_SO.    "active version
*************

*BREAK ‘XYZ’.
.
*IF vbak-audat < sy-datum.
*  FCODE = 'ENT1'.
*  MESSAGE 'Sales order created date should be greather than system date' TYPE 'E'.
*ENDIF.
*BREAK anjaliv.
*IF vbak-audat < sy-datum.
*  PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).
*  FCODE = 'ENT1'.
*  MESSAGE 'Sales Order Date Should not be in past' TYPE 'E'.
*  SET SCREEN SYST-DYNNR.
*  LEAVE SCREEN.
*

*if vbak-bstdk is INITIAL.
*  MESSAGE 'Please Enter date' TYPE 'E'.
*
*  PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).
*  FCODE = 'ENT1'.
*  MESSAGE e000(38) WITH  'Please Enter date'.
*  SET SCREEN SYST-DYNNR.
*  LEAVE SCREEN.
*ENDIF.
***************
*BREAK anju_d.
*IF vbak-audat < sy-datum.
*  PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).
*  FCODE = 'ENT1'.
*  MESSAGE 'Sales Order Date Should not be in past' TYPE 'E'.
*  SET SCREEN SYST-DYNNR.
*  LEAVE SCREEN.
*
*ENDIF.

***************‘XYZ’.****** Date :16/12/2016
*if vbak-audat lt sy-datum.
*  PERFORM folge_gleichsetzen(SAPLV00F).
*  fcode = 'ENT1'.
*  MESSAGE 'Please Enter Current Date & Future Date' TYPE 'E'.
*  set SCREEN SYST-DYNNR.
*  LEAVE SCREEN.
*  ENDIF.
*DATA : lv_kvgr2 TYPE kvgr2,
*       flag_kvgr2 TYPE flag.
*IF sy-tcode = 'VA02'.
*  SELECT SINGLE kvgr2 FROM vbak
*    INTO lv_kvgr2
*    WHERE vbeln = vbak-vbeln.
*  IF vbak-kvgr2 <> lv_kvgr2.
*    flag_kvgr2 = 'X'.
*    EXPORT flag_kvgr2 FROM flag_kvgr2 TO MEMORY ID 'SY-UNAME'.
*  ENDIF.
*ENDIF.


*********************** END OF *******************************
ENDENHANCEMENT.
ENHANCEMENT 1  ZDOC_DATE_VALIDATION.    "active version
*if sy-uname = ‘XYZ’.
.
*IF  vbak-audat < sy-datum.
*  fcode = 'ENT1'.
*  MESSAGE 'SO Date Should Not be Less Than Current Date.' TYPE 'E'.
*  SET SCREEN SYST-DYNNR.
*  LEAVE SCREEN..
*ENDIF.
*ENDIF.
ENDENHANCEMENT.
ENHANCEMENT 1  ZENHANCEMENT.    "active version
** start change by ‘XYZ’.

*    IF sy-uname = ‘XYZ’.
*    IF VBAK-kunnr IS INITIAL.
*      DATA: lv_kunnr(10) TYPE C VALUE 'BNAYAK'.
*      VBAK-kunnr = LV_KUNNR.
*      ENDIF.
*    IF  VBAP-matnr IS INITIAL.
*     DATA : LV_MATNR(12) TYPE C VALUE 'BNAYAK'.
*    VBAP-matnr = LV_MATNR.
*    ENDIF.
*    IF VBAP-kwmeng IS INITIAL.
*      DATA: LV_KWMENG TYPE MENG15 VALUE '1.00'.
*         VBAP-kwmeng = LV_KWMENG.
*         ENDIF.
*    IF VBAP-werks IS INITIAL.
*          DATA: LV_WERKS(4) TYPE C VALUE 'B100'.
*    VBAP-werks = LV_WERKS.
*    ENDIF.
*    ENDIF.
*BREAK ‘XYZ’.
*if sy-uname = ‘XYZ’.
*IF  vbak-audat < sy-datum.
*  fcode = 'ENT1'.
*  MESSAGE 'SO Date Should Not be Less Than Current Date.' TYPE 'E'.
*  SET SCREEN SYST-DYNNR.
*  LEAVE SCREEN.
*ENDIF.
*ENDIF.
* end change by ‘XYZ’.
ENDENHANCEMENT.
ENHANCEMENT 1  ZENHT.    "active version
*****
*****if sy-tcode = 'VA01' or sy-tcode ='VA02'.
*****************‘XYZ’****************************
***** IF VBAK-audat < SY-datum.
*****    MESSAGE 'Document Date should not be less than the System Date' TYPE 'S' DISPLAY LIKE 'E'.
*****    PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).
*****    FCODE = 'ENT1'.
*****    SET SCREEN SYST-DYNNR.
*****    LEAVE SCREEN.
*****   endif.
*****ENDIF.
*************‘XYZ’****************************
*  if VBKD-BSTDK IS INITIAL.
*  PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).
*  FCODE = 'ENT1'.
*  SET SCREEN SYST-DYNNR.
*  LEAVE SCREEN.
*   MESSAGE s000(38) WITH 'Please Enter Purchase order date'.
*ENDIF.

*BREAK ‘XYZ’
*
*DATA: wa_vbak TYPE vbak.
*
*  IF vbak is NOT INITIAL.
*     wa_vbak = vbak.
*  ENDIF.






ENDENHANCEMENT.
ENHANCEMENT 1  ZENH_SO_DATE_VALIDATION.    "active version
*
            *IF sy-tcode = 'VA01' or sy-tcode = 'VA02'.
*  IF vbak-audat < sy-datum.
*    MESSAGE 'Document Date Cannot be before System Date' TYPE 'E'.
*  ENDIF.
*ENDIF.

ENDENHANCEMENT.
ENHANCEMENT 2  ZFM_VA02_DATE.    "active version
*DATA : lv_bstkd TYPE bstkd.
*IMPORT lv_bstkd FROM MEMORY ID 'bstkd'.
*vbkd-bstkd = lv_bstkd.
*IF sy-tcode = 'VA02' and sy-uname = ‘XYZ’.
*
*TYPES : BEGIN OF it_vbak,
*          vbeln TYPE vbeln_va,
*          kvgr1 TYPE kvgr1,
*          kvgr2 TYPE kvgr2,
*        END OF it_vbak.
*
*DATA : lt_vbak TYPE STANDARD TABLE OF it_vbak,
*       ls_vbak TYPE it_vbak,
*       lv_bstkd TYPE bstkd.
*
*SELECT vbeln kvgr1 kvgr2
*  FROM vbak
*  INTO TABLE lt_vbak
* WHERE vbeln = vbak-vbeln.
**
*READ TABLE lt_vbak INTO ls_vbak WITH KEY vbeln = vbak-vbeln.
*  IF sy-subrc = 0.
*    IF vbak-kvgr1 NE ls_vbak-kvgr1 or vbak-kvgr2 NE ls_vbak-kvgr2.
*       VBKD-BSTDK+6(2) = VBKD-BSTDK+6(2) + 2.
*       lv_bstkd = VBKD-BSTDK.
*       EXPORT lv_bstkd TO MEMORY ID 'bstkd'.
*    ENDIF.
*  ENDIF.
*ENDIF.
ENDENHANCEMENT.
ENHANCEMENT 1  ZKS_TEST.    "active version
*FCODE = 'ENT1'.
*  if sy-tcode = 'VA01' or sy-tcode ='VA02'.
*BREAK ‘XYZ’.
*data : it_tkomk TYPE STANDARD TABLE OF vbkd,
*     wa_vbak TYPE vbkd.
* IF   vbkd-ZTERM = '0012' or vbkd-ZTERM = '0006' or vbkd-ZTERM = '0007' or vbkd-ZTERM = '0008' or vbkd-ZTERM = '0009' or vbkd-ZTERM = '0010' or vbkd-ZTERM = '0011'.
*  MESSAGE 'Payment Term Not Valid' TYPE  'E'.
* ENDIF.
*ENDIF.
*if VBAK-AUDAT < sy-datum.
*  MESSAGE 'So Date should not be less than the Current Date' TYPE 'S' Display like 'E'.
*  ENDIF.


ENDENHANCEMENT.
ENHANCEMENT 1  ZNK_DATEVALIDATION.    "active version
*BREAK ‘XYZ’
*if sy-ucomm = 'SICH'.
**  FCODE = 'ENT1'.
*  IF VBAK-audat < SY-datum.
*    MESSAGE 'SO DATE should not be less than the current date' TYPE 'S' DISPLAY LIKE 'E'.
*  endif.
*
* PERFORM folge_gleichsetzen(saplv00f).
*         fcode = 'ENT1'.
*         SET SCREEN syst-dynnr.
*         LEAVE SCREEN.
*endif.
ENDENHANCEMENT.
ENHANCEMENT 1  ZPLANT_JEXP_CHK.    "active version
*  DATA : LS_J_1IWRKCUS TYPE J_1IWRKCUS.
*
* IF SY-TCODE = 'VA01' OR SY-TCODE = 'VA02'.
***   SELECT SINGLE * FROM J_1IWRKCUS INTO LS_J_1IWRKCUS WHERE J_1IWERKS = VBAP-WERKS.
***     IF LS_J_1IWRKCUS IS NOT INITIAL.
*
*       READ TABLE XKOMV WITH KEY KSCHL = 'ZA00' TRANSPORTING NO FIELDS.
*       IF SY-SUBRC = 0.
*         IF ( XKOMV-KBETR IS INITIAL OR XKOMV-KBETR EQ '0' ).
*             MESSAGE  'Amount Field  Should be not Blank OR 0' TYPE 'S' DISPLAY LIKE 'E'.
*
*             PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).
*             FCODE = 'ENT1'.
*             SET SCREEN SYST-DYNNR.
*             LEAVE SCREEN.
*         ENDIF.
*        ELSE.
*          MESSAGE  'Condation type ZA00 not exist' TYPE 'S' DISPLAY LIKE 'E'.
*
*          PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).
*             FCODE = 'ENT1'.
*             SET SCREEN SYST-DYNNR.
*             LEAVE SCREEN.
*       ENDIF.
*
*    ENDIF.
*  ENDIF.


ENDENHANCEMENT.
ENHANCEMENT 2  ZSALES_WF_K.    "active version
***  DATA:flag_zterm(1) TYPE c,
***       flag_kvgr1(1) TYPE c,
***       flag_kvgr2(1) TYPE c.
***  DATA:gs_vbak TYPE vbak,
***       gs_vbkd TYPE vbkd.
***IF sy-tcode = 'VA02' and sy-uname = ‘XYZ’ .
***    SELECT SINGLE *
***      FROM VBAK
***      INTO gs_vbak
***      WHERE vbeln = vbak-vbeln.
***    SELECT SINGLE *
***      FROM vbkd
***      INTO gs_vbkd
***      WHERE vbeln = vbak-vbeln.
***
***     IF gs_vbak-kvgr1 <> xvbak-kvgr1.
***       IMPORT flag_kvgr1 TO flag_kvgr1 FROM MEMORY ID 'KVGR1'.
***       VBAK-zzkvgr1_1 = flag_kvgr1.
***     ENDIF.
***     IF gs_vbak-kvgr2 <> xvbak-kvgr2.
***       IMPORT flag_kvgr2 TO flag_kvgr2 FROM MEMORY ID 'KVGR2'.
***       VBAK-zzkvgr2 = flag_kvgr2.
***     ENDIF.
***     IF gs_vbkd-zterm <> xvbkd-zterm.
***       IMPORT flag_zterm TO flag_zterm FROM MEMORY ID 'ZTERM'.
***       VBAK-zzterm1 = flag_zterm.
***     ENDIF.
***ENDIF.
***
****BREAK ‘XYZ’ .

***
***DATA : Lv_kvgr1 TYPE VBAK-kvgr1.
***DATA : lv_kvgr2 TYPE vbak-kvgr2.
***DATA : lv_zterm TYPE VBKD-zterm.
***
***IF sy-tcode = 'VA02' AND sy-uname = ‘XYZ’.
***       SELECT SINGLE zterm
***      FROM vbkd
***      INTO lv_ZTERM
***      WHERE vbeln = VBAK-vbeln.
***
***     SELECT SINGLE kvgr1
***    FROM vbak
***    INTO LV_KVGR1
***    WHERE vbeln = vbak-vbeln.
***
***   SELECT SINGLE kvgr2
***    FROM vbak
***    INTO LV_KVGR2
***    WHERE vbeln = vbak-vbeln.
***
***    if lv_ZTERM <> xvbkd-zterm.
***    VBAK-zzterm = 'X'.
***    ENDIF.
***
***    if LV_KVGR1 <> xvbak-kvgr1.
***       VBAK-zzkvgr1 = 'X'.
***  ENDIF.
***
***  if Lv_kvgr2 <>  xvbak-kvgr2.
***    vbak-zzkvgr2 = 'X'.
***  ENDIF.
***ENDIF.
***
***
***********Multilevel workflow **
****BREAK ‘XYZ’.
***DATA : gs_vbap TYPE vbapvb.
***DATA : zmatkl TYPE flag.
***DATA : lv_matkl TYPE vbap-mvgr1.
***
***
***IF sy-tcode = 'VA02' AND sy-uname = ‘XYZ’.

*** SELECT SINGLE MVGR1
***    FROM vbap
***    INTO lv_matkl
***    WHERE vbeln = yvbap-vbeln
***      and posnr = '000010'.
***
***
***loop at xvbap into gs_vbap where vbeln = yvbap-vbeln
***                             and posnr = '000010'.
***  if lv_matkl <> gs_vbap-mvgr1.
***    gs_vbap-zmatkl = 'X'.
***    modify xvbap from gs_vbap TRANSPORTING zmatkl.
***    clear : gs_vbap.
***  endif.
***endloop.
***
***loop at yvbap into gs_vbap where vbeln = xvbap-vbeln
***                             and posnr = '000010'.
***  if lv_matkl <> gs_vbap-mvgr1.
***    gs_vbap-zmatkl = 'X'.
***    modify yvbap from gs_vbap TRANSPORTING zmatkl.
***    clear : gs_vbap.
***  endif.
***endloop.
***ENDIF.
****break ‘XYZ’.
***
***
***
***
****
****BREAK-point.
****  DATA:flag_zterm(1) TYPE c,
****       flag_kvgr1(1) TYPE c,
****       flag_kvgr2(1) TYPE c.
***  DATA: wa_vbak TYPE vbak,
***        wa_vbkd TYPE vbkd.
***IF sy-tcode = 'VA02' and sy-uname = ‘XYZ’.

***    SELECT SINGLE *
***      FROM VBAK
***      INTO wa_vbak
***      WHERE vbeln = vbak-vbeln.
***    SELECT SINGLE *
***      FROM vbkd
***      INTO wa_vbkd
***      WHERE vbeln = vbak-vbeln.
***
***     IF wa_vbak-kvgr1 <> xvbak-kvgr1.
***       IMPORT kvgr1 TO flag_kvgr1 FROM MEMORY ID 'KVGR1'.
***       VBAK-zzkvgr1_1 = flag_kvgr1.
***     ENDIF.
***     IF wa_vbak-kvgr2 <> xvbak-kvgr2.
***       IMPORT kvgr2 TO flag_kvgr2 FROM MEMORY ID 'KVGR2'.
***       VBAK-zzkvgr2 = flag_kvgr2.
***     ENDIF.
***     IF wa_vbkd-zterm <> xvbkd-zterm.
***       IMPORT zterm TO flag_zterm FROM MEMORY ID 'ZTERM'.
***       VBAK-zzterm1 = flag_zterm.
***     ENDIF.
***ENDIF.
* ENDENHANCEMENT.
*$*$-End:   (12)--------------------------------------------------------------------------------$*$*
*{   INSERT         DE3K903284                                        1
DATA: lv_simulation TYPE c.
DATA: lv_func_pref_sd0a_r3
      LIKE rs38l-name VALUE '/SAPSLL/PREF_SD0A_R3'.

CALL FUNCTION 'FUNCTION_EXISTS'
  EXPORTING
    funcname           = lv_func_pref_sd0a_r3
  EXCEPTIONS
    function_not_exist = 1
    OTHERS             = 2.
IF sy-subrc <> 0.
  EXIT.
ENDIF.

lv_simulation = 'X'.

CALL FUNCTION '/SAPSLL/PREF_SD0A_R3'
  EXPORTING
    is_header             = vbak
    iv_business_object    = businessobjekt
    iv_simulation         = lv_simulation
    iv_deletion_indicator = yvbak_updkz
    is_document_type      = tvak
  TABLES
    it_partner_new        = xvbpa
    it_partner_old        = yvbpa
    ct_item_new           = xvbap
    it_item_old           = yvbap
    it_item_status_new    = xvbup
    it_sched_line_vb      = xvbep
    it_business_data      = xvbkd
    it_partner_address    = xvbadr
  EXCEPTIONS
    OTHERS                = 1.                            "#EC EXISTS

*}   INSERT
*{   INSERT         DH3K911961                                        2
*
*}   INSERT


ENDFORM.
*eject



Thursday, April 16, 2020

Calling Workflow When We Creating Sales order in SAP ABAP.


Trigger Workflow When We Creating Sales order in SAP ABAP.




Trigger Workflow Creating Sales order in SAP ABAP.

*DATA :lt_container TYPE STANDARD TABLE OF swr_cont,
*      ls_container TYPE swr_cont.
*IF sy-tcode = 'VA02'.
*  SELECT SINGLE kvgr2 FROM vbak
*    INTO lv_kvgr2
*    WHERE vbeln = vbak-vbeln.
*  IF vbak-kvgr2 = lv_kvgr2.
*  ELSE.
**    PERFORM call_workflow.
*    flag_kvgr2 = 'X'.
*    ls_container-element = 'DOC_NO'.
*    ls_container-value = vbak-vbeln.
*    APPEND ls_container TO lt_container.
*    CLEAR : ls_container.
*
*    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*      EXPORTING
*        task                      = 'WS999001233'
*        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                    =
*              .
*    IF sy-subrc = 0.
*      EXPORT flag_kvgr2 FROM flag_kvgr2 TO MEMORY ID 'SY-UNAME'.
*    ENDIF.
*  ENDIF.
*ENDIF.

Validation for Purchase requisition date before saving purchase requisition date.

                       
  • Validation for Purchase requisition date before saving purchase requisition date.

  • Purchase requisition date validation.

  • User exit MEREQ001.


Use this EXIT_SAPLMEREQ_005 function module for displaying error messages at the time of saving of  Purchase requisition.


DATA Fcode TYPE  Sy-UCOMM.
if im_data_new-badat < sy-datum.
    MESSAGE 'Purchase requisition Date not is less than the System Date' TYPE 'E'.
   endif.
   if im_data_new-FRGDT < sy-datum.
     MESSAGE 'PR Release Date not is less than the System Date' TYPE 'E.
   endif.