MV50AFZ1

<< Click to Display Table of Contents >>

Navigation:  All About ABAP Technique > Indonesia > ABAP Tutorial > ABAP Workbench Tools  > User Exits > Contoh User Exits >

MV50AFZ1

***INCLUDE MV50AFZ1 .
 
************************************************************************
*                                                                      *
* This include is reserved for user modifications                      *
*                                                                      *
* Forms for delivery processing                                        *
*                                                                      *
* The name of modification modules should begin with 'ZZ'.             *
*                                                                      *
************************************************************************
 
*---------------------------------------------------------------------*
*       FORM ZZEXAMPLE                                                *
*---------------------------------------------------------------------*
*       text......................................                    *
*---------------------------------------------------------------------*
*FORM ZZEXAMPLE.
 
*  ...
 
*ENDFORM.
 
*eject
*---------------------------------------------------------------------*
*       FORM USEREXIT_DELETE_DOCUMENT                                 *
*---------------------------------------------------------------------*
*       This userexit can be used to delete data in additional tables *
*       when a delivery is deleted.                                   *
*                                                                     *
*      This form is called in dialog at the end of form BELEG_LOESCHEN*
*      just before form BELEG_SICHERN is performed to delete the      *
*      datas on the database.                                         *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_DELETE_DOCUMENT.
*{   INSERT         WDVK900314                                        1
  Perform MV50AFZ1_ZWM03.
  PERFORM MV50AFZ1_ZWM02.
*}   INSERT
 
ENDFORM.
*eject
 
*---------------------------------------------------------------------*
*       FORM USEREXIT_MOVE_FIELD_TO_LIKP                              *
*---------------------------------------------------------------------*
*       This userexit can be used to move some fields into the        *
*       delivery header workaerea LIKP.                               *
*       This form is called, when a header is created                 *
*       This form is called at the end of form LIKP_FUELLEN.          *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_LIKP.
 
*  LIKP-zzfield = xxxx-zzfield2.
*{   INSERT         WDVK900915                                        1
  Perform MV50AFZ1_ZWM03.
*}   INSERT
 
ENDFORM.
*eject
 
*---------------------------------------------------------------------*
*       FORM USEREXIT_MOVE_FIELD_TO_LIPS                              *
*---------------------------------------------------------------------*
*       This userexit can be used to move some fields into the        *
*       delivery item workaerea LIPS                                  *
*       This form is called, when an item is created                  *
*                                                                     *
*                                                                     *
*       This form is called at the end of form LIPS_FUELLEN.          *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_LIPS.
 
*  LIPS-zzfield = xxxx-zzfield2.
*{   INSERT         WDVK900915                                        1
      Perform MV50AFZ1_ZWM03.
*}   INSERT
 
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 TVLK like in standard
* US_RANGE_INTERN = TVLK-NUMKI.
*{   INSERT         WDVK900241                                        1
  perform get_number_range in program zre_s9001_usrext
    using xlikp-vkorg
          xlikp-lfart
          xlikp-vstel
          ' '
          ' '
    changing us_range_intern.
*}   INSERT
 
ENDFORM.
*eject
 
*---------------------------------------------------------------------*
*       FORM USEREXIT_READ_DOCUMENT                                   *
*---------------------------------------------------------------------*
*       This userexit can be used to read data in additional tables   *
*       when the program reads a delivery.                            *
*                                                                     *
*       This form is called at the end of form BELEG_LESEN.           *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_READ_DOCUMENT.
*{   INSERT         WDVK900915                                        1
  Perform MV50AFZ1_ZWM03.
*}   INSERT
 
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.
 
* Example:
* CALL FUNCTION 'ZZ_EXAMPLE'
*      IN UPDATE TASK
*      EXPORTING
*           ZZTAB = ZZTAB.
 
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.
 
ENDFORM.
*eject
 
 
*---------------------------------------------------------------------*
*       FORM USEREXIT_REFRESH_DOCUMENT                                *
*---------------------------------------------------------------------*
*       It is always necessary to refresh user-specific data before   *
*       the next document will be processed.                          *
*       This can be done in this userexit.                            *
*       This userexit can be used to refresh user-specific data       *
*       when the processing of a delivery is finished                 *
*       - after the document is saved                                 *
*       - when you leave the document processing with F3 or F15       *
*       It may be necessary to refresh user-specific data before      *
*       the next document will be processed.                          *
*                                                                     *
*      This form is called in dialog at the end of form               *
*      BELEG_INITIALISIEREN                                           *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_REFRESH_DOCUMENT.
 
* clear: ZZ50A.
* refresh: zzitemtab.
*{   INSERT         WDVK900915                                        1
  Perform MV50AFZ1_ZWM03.
*}   INSERT
 
ENDFORM.
 
 
*---------------------------------------------------------------------*
*       FORM USEREXIT_SAVE_DOC_BEFORE_PREP (n_751000)                 *
*---------------------------------------------------------------------*
*       This userexit can be used for changes before a                *
*       document is saved.                                            *
*                                                                     *
*       This form is called at the beginning of form BELEG_SICHERN    *
*       before the requirement handling and before userexit           *
*       USEREXIT_SAVE_DOCUMENT_PREPARE.                               *
*                                                                     *
*---------------------------------------------------------------------*
FORM USEREXIT_SAVE_DOC_BEFORE_PREP.                         "v_n_751000
*{   INSERT         WDVK900314                                        1
 
DATA : li_old_xlips like line of xlips occurs 0 with header line.
DATA : li_xvbfa like line of xvbfa occurs 0 with header line.
 
Perform MV50AFZ1_ZWM03.
PERFORM MV50AFZ1_ZWM01.
 
 
 
*** Perlu dilakukan karena proses split.
IF T180-TRTYP = 'H' and CVBAK-VKORG = 'A201' and CVBAP-WERKS = '2012'
                  and CVBAK-VTWEG ne '07' and CVBAK-VBTYP = 'C'.
 
*** For Plant 2012 Re-arrange table xlips xvbup and xvbfa here ****
****>>> SY SYARIEN <<<<************
**** Attached free goods to main item into one delivery ********
DATA: GW_XLIPS like XLIPS occurs 0 with header line.
 
IF CVBAK-VKORG = 'A201' and CVBAP-WERKS = '2012' and CVBAK-VTWEG ne '07'.
    Free gw_xlips.
    GW_XLIPS[] = XLIPS[].
**** Jika bapak-e ono, anak-e ikut bapak-e.
    LOOP AT XLIPS.
      read table cvbap with key vbeln = xlips-vgbel
                                 posnr = xlips-vgpos.
      if cvbap-uepos is not initial.
          xlips-uepos = cvbap-uepos.
      endif.
 
      if xlips-uepos is not initial.
          read table gw_xlips with key posnr = xlips-uepos
                                        vgbel = xlips-vgbel.
          if sy-subrc = 0.
            if xlips-vbeln ne gw_xlips-vbeln.
                xlips-vbeln = gw_xlips-vbeln.
                modify xlips.
            endif.
          endif.
      endif.
    ENDLOOP.
 
**** Jika anak-e nggak ono, bapak-e ono, bapak-e ikut anak-e.
    GW_XLIPS[] = XLIPS[].
    LOOP AT GW_XLIPS where uepos is not initial
                      and  updkz = 'D'.
      LOOP AT XLIPS where posnr = gw_xlips-uepos
                      and vgbel = gw_xlips-vgbel.
           xlips-updkz = gw_xlips-updkz.
          modify xlips.
      ENDLOOP.
    ENDLOOP.
 
ENDIF.
 
**** Set table XVBFA and XVBUP according to xlips.
  sort xlips by vbeln posnr.
  loop at xlips.
****    Reorganize XVBFA
      loop at xvbfa where posnn = xlips-posnr
                    and   vbelv = xlips-vgbel
                    and   posnv = xlips-vgpos
                    and   VBTYP_N = 'J'.
            xvbfa-vbeln = xlips-vbeln.
            modify xvbfa.
            if xlips-updkz = 'D'.
              delete xvbfa.
            endif.
      endloop.
***     Reorganize XVBUP
      loop at xvbup where posnr = xlips-posnr
                    and   updkz = 'I'.
            if xvbup-vbeln ne xlips-vbeln.
              xvbup-vbeln = xlips-vbeln.
              modify xvbup.
            endif.
            if xlips-updkz = 'D'.
              delete xvbup.
            endif.
      endloop.
  endloop.
 
 
ENDIF.
****>>>> END OF ENHANCEMENT >>>>>****************
 
 
 
 
 
 
*  IF ( likp-lfart <> 'ZD10' ) and
*     ( likp-vkorg <> 'A103' ) and
*     ( vbuk-wbstk <> 'C' ) and
*     ( vbuk-kostk <> 'C' ) and
*     ( vbuk-lvstk <> 'C' ) and
*     ( sy-tcode np 'TVPO*' ).
DATA : lv_otflag.
perform fm_check_order_type(SAPLZFG_FREEGOODS) using likp-lfart changing lv_otflag.
if lv_otflag eq 'X' and
    likp-lfart ne 'ZS02'.
   li_old_xlips[] = xlips[].
  INCLUDE ZIN_S_CALC_FG_DLV.
endif.
*  ENDIF.
 
****>>>> Reset volume and weight for return delivery in shipment
IF T180-TRTYP = 'H'.
LOOP AT XLIKP.
    IF XLIKP-VBTYP = 'T'.
      XLIKP-VOLUM = 0.
      XLIKP-BTGEW = 0.
      XLIKP-NTGEW = 0.
    ELSE.
      CLEAR: XLIKP-BTGEW, XLIKP-NTGEW, XLIKP-VOLUM.
      LOOP AT XLIPS WHERE VBELN = XLIKP-VBELN and UPDKZ ne 'D'.
          PERFORM MENGE_ADDIEREN(SAPLV05I) USING XLIPS-BRGEW XLIPS-GEWEI
                                                 XLIKP-BTGEW XLIKP-GEWEI
                                                 XLIKP-BTGEW XLIKP-GEWEI.
          PERFORM MENGE_ADDIEREN(SAPLV05I) USING XLIPS-NTGEW XLIPS-GEWEI
                                                 XLIKP-NTGEW XLIKP-GEWEI
                                                 XLIKP-NTGEW XLIKP-GEWEI.
          PERFORM MENGE_ADDIEREN(SAPLV05I) USING XLIPS-VOLUM XLIPS-VOLEH
                                                 XLIKP-VOLUM LIKP-VOLEH
                                                 XLIKP-VOLUM LIKP-VOLEH.
      ENDLOOP.
    ENDIF.
    modify XLIKP.
ENDLOOP.
ENDIF.
 
*}   INSERT
 
 
ENDFORM.                                                   "^_n_751000
 
*eject
*{   INSERT         WDVK900894                                        1
* Free Goods Calculation in Delivery
INCLUDE ZIN_S_ATP_CHECK.
INCLUDE ZIN_S_CHG_QTY_LIPS.
*}   INSERT