Skip to Content
0
Former Member
May 05, 2009 at 07:38 AM

User Exit for saving Invoice

5993 Views

Hi Experts,

My req, is I have to check billing date with order date/ delivery date while creating the invoice in VF01.

For that I have done codig in user exit RV60AFZZ, so it gives error ,but the billing date field get disable.

& this invoice no. alsp get created.

So can anybody plz tell me in which user exit i have to put my code ???

I have tried with RV60AFZC.But it is not working.

My code is

FORM userexit_pricing_prepare_tkomp.

*  TKOMP-zzfield = xxxx-zzfield2.



* structure for vbak
TYPES:BEGIN OF ty_vbak,
      vbeln TYPE vbak-vbeln,
      audat TYPE vbak-audat,
      END OF ty_vbak.

*likp structure
TYPES:BEGIN OF ty_likp,
      vbeln TYPE likp-vbeln,
      lfdat TYPE likp-lfdat,
      END OF ty_likp.

*vbrp structure
TYPES:BEGIN OF ty_vbrp,
      vgbel TYPE vbrp-vgbel,
      vgpos TYPE vbrp-vgpos,
      aubel TYPE vbrp-aubel,
      aupos TYPE vbrp-aupos,
      END OF ty_vbrp.

DATA:it_vbak TYPE STANDARD TABLE OF ty_vbak,
     it_likp TYPE STANDARD TABLE OF ty_likp,
     it_vbrp TYPE STANDARD TABLE OF ty_vbrp.

DATA:wa_vbak TYPE ty_vbak,
     wa_likp TYPE ty_likp,
     wa_vbrp TYPE ty_vbrp.


***** take reference document no & delivery no. *****
LOOP AT xvbrp.
  wa_vbrp-vgbel = xvbrp-vgbel.
  wa_vbrp-vgpos = xvbrp-vgpos.
  wa_vbrp-aubel = xvbrp-aubel.
  wa_vbrp-aupos = xvbrp-aupos.

  APPEND wa_vbrp TO it_vbrp.

ENDLOOP.

IF it_vbrp IS NOT INITIAL.
SELECT vbeln audat FROM vbak
      INTO TABLE it_vbak
      FOR ALL ENTRIES IN it_vbrp
      WHERE vbeln = it_vbrp-aubel.

SELECT vbeln lfdat from likp
       INTO TABLE it_likp
       FOR ALL ENTRIES IN it_vbrp
       WHERE vbeln = it_vbrp-vgbel.

ENDIF.
**** check for invoice date with order date *****
LOOP AT it_vbak INTO wa_vbak.

  IF xvbrk-fkdat IS NOT INITIAL AND xvbrk-fkdat < wa_vbak-audat.
    MESSAGE 'Invoice Date is less than Order Date' TYPE 'E'.
  ENDIF.
ENDLOOP.

**** check for invoice date with delievery date *****
LOOP AT it_likp INTO wa_likp.

  IF xvbrk-fkdat IS NOT INITIAL AND xvbrk-fkdat < wa_likp-lfdat.
    MESSAGE 'Invoice Date is less than Delivery Date' TYPE 'E'.
  ENDIF.
ENDLOOP.


ENDFORM.                    "USEREXIT_PRICING_PREPARE_TKOMP

Thanks & Regards,

Anagha Deshmukh