ZXATPU01

<< Click to Display Table of Contents >>

Navigation:  All About ABAP Technique > Indonesia > ABAP Tutorial > ABAP Workbench Tools  > Enhancement > Customer Exits > Contoh Customer Exits > Project ZSDWS001 > Funtions Exits > EXIT_SAPLATPC_002 >

ZXATPU01

*&---------------------------------------------------------------------*
*&  Include           ZXATPU02                                         *
*&---------------------------------------------------------------------*
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  TABLES
*"      T_ATPCSX STRUCTURE  ATPCS
*"      T_MDVEX STRUCTURE  MDVE
*"  CHANGING
*"     REFERENCE(P_ATPCC) TYPE  ATPCC OPTIONAL
*"----------------------------------------------------------------------
 
 
DATA: lv_qtyunit1 LIKE t_mdvex-mng01,
     lv_qtyunit2 LIKE t_mdvex-mng02,
     lv_umren LIKE  t_atpcsx-umren,
     lv_umrez LIKE  t_atpcsx-umrez,
     lv_omeng like VBBE-OMENG.
 
*********************************************************************
*** Availability Check for Return to Vendor Delivery ****************
*** For Return to Vendor and plant < 2019, Check Blocked Stock Only
TABLES: MARD,VBBE.
 
if t_atpcsx-chmod = 'ZRT'
                and t_atpcsx-atpm1 > 0
                and t_atpcsx-werks < '2019'.
*** get blocked stock qty
select single * from MARD where MATNR = t_atpcsx-matnr
                          and   WERKS = t_atpcsx-werks
                          and   LGORT = t_atpcsx-lgort.
if sy-subrc = 0.
  clear lv_omeng.
  select * from VBBE where MATNR = t_atpcsx-matnr
                        and WERKS = t_atpcsx-werks
                        and LGORT = t_atpcsx-lgort
                        and BDART = 'ZR'.
     lv_omeng = lv_omeng + VBBE-OMENG.
  endselect.
   t_atpcsx-atpm1 =  MARD-SPEME - lv_omeng.
else.
   t_atpcsx-atpm1 = 0.
endif.
if t_mdvex-mng02 > t_atpcsx-atpm1.
   t_mdvex-mng02 = t_atpcsx-atpm1.
endif.
modify t_atpcsx index 1.
 
endif.
**********************************************************************
 
 
 
read table t_atpcsx with key delkz = 'VJ'.
 
IF sy-subrc = 0.
MOVE  t_atpcsx-umren TO lv_umren.
MOVE  t_atpcsx-umrez TO lv_umrez.
IF t_mdvex-mng02 NE 0. "Jika bukan dalam base unit
   lv_qtyunit1 = t_mdvex-mng01 * lv_umren / lv_umrez.
   lv_qtyunit1 = FLOOR( lv_qtyunit1 ).             "bulatkan ke bawah
   lv_qtyunit1 = lv_qtyunit1 * lv_umrez / lv_umren.
   t_mdvex-mng01  = lv_qtyunit1.
 
   lv_qtyunit2 = t_mdvex-mng02 * lv_umren / lv_umrez.
   lv_qtyunit2 = FLOOR( lv_qtyunit2 ).             "bulatkan ke bawah
   lv_qtyunit2 = lv_qtyunit2 * lv_umrez / lv_umren.
   t_mdvex-mng02  = lv_qtyunit2.
 
  MODIFY t_mdvex index 1.
ENDIF.
 
CLEAR lv_umrez.
CLEAR lv_umren.
CLEAR lv_qtyunit1.
CLEAR lv_qtyunit2.
ENDIF.
******** END OF ENHANCEMENT ******************