Tuesday, 23 May 2017

Enhancement Implementation for VA21,VA22 ,VA41,VA42 ,DP91 and VA01.,VA01







1. Include  MV45AFZZ


FORM USEREXIT_READ_DOCUMENT.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Form USEREXIT_READ_DOCUMENT, Start                                                                                                                A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZSD_QUOT_CHANGERESTRICT.    "active version
*
  "added for restricting the change mode of quotation after final level of approval.
  "if quotation is already approved then you cannot change it in va22 but can view in va23.

  if sy-tcode = 'VA22'.

DATA : GT_QUOTATION TYPE ZSD_QUOTATION,
       LV_FLAG(1),
       gs_vbak TYPE vbak.

"FOR CHECKING THE LEVELS OF APPROVALS NEEDED BASED ON PROFIT MARGIN
CALL METHOD zcl_sd_quot_mail=>get_details
  EXPORTING
    vbeln    =  VBAK-VBELN
  IMPORTING
    lv_flag  = LV_FLAG.




     select single * from vbak into gs_vbak where vbeln = VBAK-VBELN.

"TO GET THE DETAILS OF APPROVED LEVELS FROM ZTABLE & RESTRICTING VA22 MODE FOR APPROVED QUOTATION.
    SELECT SINGLE * FROM ZSD_QUOTATION INTO GT_QUOTATION WHERE VBELN = VBAK-VBELN.
    IF SY-SUBRC = 0.
             IF LV_FLAG = '1'.
                if gs_vbak-spart <> '30'.
                 IF  GT_QUOTATION-status2 = 'A'.
                    MESSAGE 'Approved Quotation cannot be changed,Goto VA23' TYPE 'E'.
                 ENDIF.
                endif.
             ELSEIF lv_flag = '2'.
                IF  GT_QUOTATION-status3 = 'A'.
                    MESSAGE 'Approved Quotation cannot be changed,Goto VA23' TYPE 'E'.
                 ENDIF.
             elseif lv_flag = ' '.
                if gs_vbak-FAKSK = '99'.
                  MESSAGE 'Approved Quotation cannot be changed,Goto VA23' TYPE 'E'.
                endif.
             ENDIF.
    ENDIF.


    "for locking user if it is alreadty open for approval.

**data : it_enq type TABLE OF seqg3.
**
**CALL FUNCTION 'ENQUEUE_READ'
** EXPORTING
**   GCLIENT                     = SY-MANDT
***   GNAME                       = ' '
***   GARG                        = ' '
***   GUNAME                      = SY-UNAME
***   LOCAL                       = ' '
***   FAST                        = ' '
***   GARGNOWC                    = ' '
**** IMPORTING
***   NUMBER                      =
***   SUBRC                       =
**  TABLES
**    enq                         = it_enq
*** EXCEPTIONS
***   COMMUNICATION_FAILURE       = 1
***   SYSTEM_FAILURE              = 2
***   OTHERS                      = 3
**          .
**IF sy-subrc <> 0.
*** Implement suitable error handling here
**ENDIF.
**
**delete it_enq where gtcode <> 'SBWP'.
**
**IF it_enq[] IS NOT INITIAL.
**   CALL FUNCTION 'DEQUEUE_EVVBAKE'
** EXPORTING
**   MODE_VBAK       = 'E'
**   MANDT           = SY-MANDT
**   VBELN           = gs_vbak-vbeln
***   X_VBELN         = ' '
***   _SCOPE          = '3'
***   _SYNCHRON       = ' '
***   _COLLECT        = ' '
**          .
**
**   message 'QUOTATION ALREADY LOCKED BY OTHER USER' TYPE 'E'.
**
**  ENDIF.
endif.


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


ENDFORM.




*********************************************************************************



2. Include   MV45AFZZ


FORM USEREXIT_SAVE_DOCUMENT.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(2) Form USEREXIT_SAVE_DOCUMENT, Start                                                                                                                A
*$*$-Start: (2)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZVA41_SAVE_WBS_PARTNER.    "active version
************* added by chellam - 12.08.2015 ****************
IF sy-tcode = 'VA41' OR sy-tcode = 'VA42' OR sy-tcode = 'VA43' or sy-tcode = 'VA01' OR  sy-tcode = 'VA02'  OR sy-tcode = 'VA03' or sy-tcode = 'MASS'.
  TYPES: BEGIN OF ty_ihpa,
           objnr   TYPE ihpa-objnr,
           parvw   TYPE ihpa-parvw,
           counter TYPE ihpa-counter,
           obtyp   TYPE ihpa-obtyp,
           parnr   TYPE ihpa-parnr,
           erdat   TYPE ihpa-erdat,
           erzeit  TYPE ihpa-erzeit,
           ernam   TYPE ihpa-ernam,
           aedat   TYPE ihpa-aedat,
           aezeit  TYPE ihpa-aezeit,
           aenam   TYPE ihpa-aenam,
         END OF ty_ihpa.
  DATA : gt_ihpa TYPE TABLE OF ty_ihpa,
         gs_ihpa TYPE ihpa.
  DATA : lv_lines TYPE i.

  DATA : wa_xvbap   TYPE vbap,
         wa_prps    TYPE prps,
         lv_objnr   TYPE proj-objnr,
         lv_counter TYPE ihpa-counter,
         lv_check_objnr type proj-objnr.
  IF xvbak-auart = 'ZSCT' OR xvbak-auart = 'ZSCV' .
      LOOP AT xvbap INTO wa_xvbap.
        IF wa_xvbap-ps_psp_pnr IS NOT INITIAL.
          CLEAR : wa_prps.
          CALL FUNCTION 'CJDW_PRPS_SELECT_SINGLE'
            EXPORTING
              posnr             = wa_xvbap-ps_psp_pnr
            IMPORTING
              e_prps            = wa_prps
            EXCEPTIONS
              missing_parameter = 1
              not_found         = 2
              OTHERS            = 3.

          CLEAR : lv_objnr.
          SELECT SINGLE objnr FROM proj INTO lv_objnr WHERE pspnr = wa_prps-psphi.
          SELECT COUNT(*) FROM ihpa WHERE objnr = lv_objnr AND parvw = 'AG' AND obtyp = 'PDN'.
          IF SY-SUBRC = 0.
          ELSE.
          CLEAR : lv_counter,lv_check_objnr.
            select single objnr from ihpa INTO lv_check_objnr where objnr = lv_objnr.
            if lv_check_objnr is NOT INITIAL.
              SELECT MAX( counter ) FROM ihpa INTO lv_counter WHERE objnr = lv_objnr .
              lv_counter = lv_counter + 1.
            else.
              lv_counter = 0.
            endif.
            gs_ihpa-objnr = lv_objnr.
            gs_ihpa-parvw = 'AG'.
            gs_ihpa-counter = lv_counter.
            gs_ihpa-obtyp = 'PDN'.
            gs_ihpa-parnr = xvbak-kunnr.
            gs_ihpa-erdat = sy-datum.
            gs_ihpa-erzeit = sy-uzeit.
            gs_ihpa-ernam = sy-uname.
            gs_ihpa-aedat = sy-datum.
            gs_ihpa-aezeit = sy-uzeit.
            gs_ihpa-aenam = sy-uname.
            INSERT INTO ihpa VALUES gs_ihpa.
            IF sy-subrc = 0.
              CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
                EXPORTING
                  wait = 'X'.
            ENDIF.
          ENDIF.
        ENDIF.
        CLEAR : WA_XVBAP,GS_IHPA.
      ENDLOOP.
  ENDIF.
ENDIF.
************* end of added by chellam - 12.08.2015
ENDENHANCEMENT.
*$*$-End:   (2)---------------------------------------------------------------------------------$*$*

* Example:
* CALL FUNCTION 'ZZ_EXAMPLE'
*      IN UPDATE TASK
*      EXPORTING
*           ZZTAB = ZZTAB.

ENDFORM.

*eject
********************************************************************************

3. Include  MV45AF0T_TAXI_INITIALIZE_CARRI

FORM taxi_initialize_carrierscreen.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Form TAXI_INITIALIZE_CARRIERSCREEN, Start                                                                                                         A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZVBAP_WERKS_UPDATE_DP91.    "active version
******** added by chellam
  DATA : lv_werks TYPE ekpo-werks,
         lv_item  TYPE vbap-posnr.

  DATA : lv_auart TYPE vbak-auart.

  IF sy-tcode = 'DP91' .
    IF sy-dynnr = 4001 .
      LOOP AT xvbap.
        CLEAR : lv_werks.
        SELECT SINGLE werks FROM vbap INTO lv_werks
                      WHERE vbeln = xvbap-vgbel.
        IF lv_werks IS NOT INITIAL.
          CLEAR : lv_auart.
          SELECT SINGLE auart FROM vbak INTO lv_auart WHERE vbeln = xvbap-vgbel.
          IF lv_auart = 'ZSCV' OR lv_auart = 'ZSCT'.
            xvbap-werks = lv_werks.
            MODIFY xvbap INDEX sy-tabix TRANSPORTING werks.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDIF.
  ELSEIF sy-tcode = 'VA01' or sy-tcode = 'VA02' OR sy-tcode = 'VA03' OR sy-tcode = 'VA41' or sy-tcode = 'VA42' or sy-tcode = 'VA43'.
    IF sy-dynnr = 4001 .
      LOOP AT xvbap.
        CLEAR : lv_werks.
        SELECT SINGLE werks FROM vbap INTO lv_werks
                      WHERE vbeln = xvbap-vgbel.
        IF lv_werks IS NOT INITIAL.
          CLEAR : lv_auart.
          SELECT SINGLE auart FROM vbak INTO lv_auart WHERE vbeln = xvbap-vgbel.
          IF lv_auart = 'ZSCV' OR lv_auart = 'ZSCT'.
            xvbap-werks = lv_werks.
            MODIFY xvbap INDEX sy-tabix TRANSPORTING werks.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDIF.
ENDENHANCEMENT.
*$*$-End:   (1)---------------------------------------------------------------------------------$*$*

No comments:

Post a Comment