ZXMCVU06

<< Click to Display Table of Contents >>

Navigation:  All About ABAP Technique > English > ABAP Tutorial > ABAP Workbench Tools > Enhancement > Customer Exits > Customer Exits Examples > Project ZSDWS001  > Funtions Exits  > EXIT_SAPLMCS6_002 >

ZXMCVU06

*&---------------------------------------------------------------------*
*&  Include           ZXMCVU06                                         *
*&---------------------------------------------------------------------*
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"       IMPORTING
*"             VALUE(I_XMCVBRK) LIKE  MCVBRKB STRUCTURE  MCVBRKB
*"             VALUE(I_XMCVBUK) LIKE  MCVBUKB STRUCTURE  MCVBUKB
*"             VALUE(I_XMCVBRP) LIKE  MCVBRPB STRUCTURE  MCVBRPB
*"             VALUE(I_XMCVBUP) LIKE  MCVBUPB STRUCTURE  MCVBUPB
*"             VALUE(I_CONTROL) LIKE  MCCONTROL STRUCTURE  MCCONTROL
*"       EXPORTING
*"             VALUE(E_XMCVBRPUSR) LIKE  MCVBRPUSR
*"                             STRUCTURE  MCVBRPUSR
*"----------------------------------------------------------------------
 
** Purpose: to fill the following fields based on CO derivation rules:
***** ZZRKEG_WW002   ASM
***** ZZRKEG_WW001   RSM
** CO derivation rule tables:
****  K9RWDV1000006 : derivation rule SalesGroup to ASM
****  K9RWDV1000005 : derivation rule ASM to RSM
 
**>> Determine ASM
select single * from K9RWDV1000006
    where SOUR1_FROM le I_XMCVBRP-VKGRP
      and SOUR1_TO   ge I_XMCVBRP-VKGRP
      and SOUR2_FROM le I_XMCVBRP-VKBUR
      and SOUR2_TO   ge I_XMCVBRP-VKBUR
      and SOUR3_FROM le I_XMCVBRP-SPART
      and SOUR3_TO   ge I_XMCVBRP-SPART
      and DELETE_FLG = space.
if sy-subrc = 0.
 E_XMCVBRPUSR-ZZWW001 = K9RWDV1000006-TARGET1.
endif.
 
**>> Determine RSM
select single * from K9RWDV1000005
    where SOUR1_FROM le E_XMCVBRPUSR-ZZWW001
      and SOUR1_TO   ge E_XMCVBRPUSR-ZZWW001
      and DELETE_FLG = space.
if sy-subrc = 0.
 E_XMCVBRPUSR-ZZWW002 = K9RWDV1000005-TARGET1.
endif.
 
**>> Determine Sales Order Date
if I_XMCVBRP-AUTYP = 'C'.
select single * from vbak
          where vbeln = I_XMCVBRP-AUBEL.
if sy-subrc = 0.
   E_XMCVBRPUSR-ZZAUDAT = VBAK-AUDAT.
else.
   E_XMCVBRPUSR-ZZAUDAT = I_XMCVBRK-FKDAT.
endif.
endif.
 
**>> Determine Customer Hierarchy
select single * from knvp
        where kunnr = I_XMCVBRK-KUNAG
        and   parvw = '1A'.
if sy-subrc = 0.
 E_XMCVBRPUSR-ZZHIENR01 = KNVP-KUNN2.
endif.
 
 
**>> Determine Customer Class and Industry Code
select single * from kna1 where kunnr = I_XMCVBRK-KUNAG.
if sy-subrc = 0.
 E_XMCVBRPUSR-ZZKUKLA = KNA1-KUKLA.
 E_XMCVBRPUSR-ZZBRAN1 = KNA1-BRAN1.
endif.
 
**>> determine cash/credit group
IF I_XMCVBRK-ZTERM = 'Z00'.
 E_XMCVBRPUSR-ZZKVGR1 = 'CAS'.
ELSE.
 E_XMCVBRPUSR-ZZKVGR1 = 'CRE'.
ENDIF.
 
*** Get Pre-Shipment Invoice number.
tables: vbfa.
data: lv_fksto like vbrk-fksto.
data: lv_vbeln like vbrk-vbeln.
 
free lv_fksto.
free lv_vbeln.
IF I_XMCVBRK-VTWEG ge '06' and I_XMCVBRK-VTWEG le '07'.
  select * from vbfa where vbelv = I_XMCVBRP-VGBEL
                            and   posnv = I_XMCVBRP-VGPOS
                            and   vbtyp_n = 'U'.
    select single fksto into lv_fksto from vbrk
                        WHERE vbeln = vbfa-vbeln.
    if lv_fksto is initial.
        lv_vbeln = vbfa-vbeln.
    endif.
  endselect.
  if sy-subrc = 0.
     E_XMCVBRPUSR-ZZVBELN = lv_vbeln.
  endif.
ENDIF.