on 04-14-2010 2:19 PM
Hi All,
The requirment I have is to automatically populate the Baseline date based on the GR posting date and Invoice posting date.
While creation of the Invoice in MIRO,
1) If the GR posting date is greater than the Invoice posting date then the Baseline date should be populated with the GR posting date.
2) If the Invoice posting date is greater than the GR posting date then the Baseline date date should be populated with the Invoice posting date.
This logic I have implemented in the BADI MRM_PAYMENT_TERMS which works as expected.
But the standard calculation of 'DUE ON' date, Payment terms, Cash discount days are not performing according to the standard functionality and these values do not get displayed.
Why is this getting affected?
Also, please suggest if there is any other way to achieve this requirement without any deviation from the standard functionality.
Below is the code that I have implemented in the BADI.
*----Defining the structure for work area for EKBE table data fetch
TYPES: BEGIN OF TY_EKBE,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
BELNR TYPE MBLNR,
BEWTP TYPE BEWTP,
BWART TYPE BWART,
BUDAT TYPE BUDAT,
END OF TY_EKBE.
*----Defining the work areas
DATA: WA_EKBE TYPE TY_EKBE, "Work area for History per Purchasing Document table
WA_DRSEG TYPE LINE OF MMCR_TDRSEG. "Work area for Invoice doc items
*----Checking if the Company code is IBTG
IF I_RBKPV-BUKRS = 'IBTG'.
*----Selecting data from EKBE table to fetch the latest GR posting date
SELECT EBELN
EBELP
BELNR
BEWTP
BWART
BUDAT
INTO WA_EKBE
FROM EKBE
FOR ALL ENTRIES IN TI_DRSEG
WHERE EBELN = TI_DRSEG-EBELN
AND BEWTP = 'E'
AND BWART = '101'.
ENDSELECT.
*----Looping at Invoice Doc. Items table into its work area
LOOP AT TI_DRSEG INTO WA_DRSEG.
IF WA_EKBE-BUDAT > WA_DRSEG-BUDAT. "If GR posting date is greater than invoice date
E_ZFBDT = WA_EKBE-BUDAT. "Assigning the GR date to Baseline date
ELSEIF WA_EKBE-BUDAT < WA_DRSEG-BUDAT. "If Invoice date is greater than GR date
E_ZFBDT = WA_DRSEG-BUDAT. "Assigning the Invoice date to Baseline date
ELSEIF WA_EKBE-BUDAT = WA_DRSEG-BUDAT. "If Invoice date is Equal to GR date
E_ZFBDT = WA_DRSEG-BUDAT. "Assigning the Invoice date to Baseline date
ENDIF.
ENDLOOP.
ENDIF.
Hi Darpana Ahire
Please share your inputs if this issue got rsolved .since we are facing same problem in due date calcualtion in MIRO .
Thanks & Regards,
Renuga.A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check the payment term that you are using. Try to change these values in tcode OBB8 and check if after do it, it works fine.
Regards
Eduardo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
if you go to se18 and display badi MRM_PAYMENT_TERMS,
in "Interface" tab if you double click on "Example implementation class" CL_EXM_IM_MRM_PAYMENT_TERMS
and then in class interface CL_EXM_IM_MRM_PAYMENT_TERMS, if you display the code of IF_EX_MRM_PAYMENT_TERMS~PAYMENT_TERMS_SET you will find three examples:
METHOD if_ex_mrm_payment_terms~payment_terms_set .
*--- fill all export-parameter ----------------------------------------*
e_zfbdt = i_rbkpv-zfbdt.
e_zbd1t = i_rbkpv-zbd1t.
e_zbd1p = i_rbkpv-zbd1p.
e_zbd2t = i_rbkpv-zbd2t.
e_zbd2p = i_rbkpv-zbd2p.
e_zbd3t = i_rbkpv-zbd3t.
e_zlspr = i_rbkpv-zlspr.
*
*-----------------------------------------------------------------------
*** Example 1: Setting ZFBDT depending on goods receive
*-----------------------------------------------------------------------
*
DATA: h_drseg TYPE mmcr_drseg,
h_budat TYPE mmcr_ekbe-budat.
TYPES: BEGIN OF x_datum ,
budat LIKE h_budat,
END OF x_datum.
TYPES: BEGIN OF x_ekbe_gelesen,
ebeln TYPE ekbe-ebeln,
ebelp TYPE mmcr_ekbe-ebelp,
END OF x_ekbe_gelesen.
DATA: h_ekbe_gelesen TYPE STANDARD TABLE OF x_ekbe_gelesen,
h1_ekbe_gelesen TYPE x_ekbe_gelesen.
DATA: h_datum TYPE STANDARD TABLE OF x_datum,
h1_datum TYPE x_datum,
h_ebeln LIKE h_drseg-ebeln,
h_ebelp LIKE h_drseg-ebelp.
LOOP AT ti_drseg INTO h_drseg WHERE selkz = 'X'.
SELECT budat FROM ekbe INTO h_budat WHERE
ebeln = h_drseg-ebeln AND
ebelp = h_drseg-ebelp AND
lfbnr = h_drseg-lfbnr AND
lfgja = h_drseg-lfgja AND
lfpos = h_drseg-lfpos AND
vgabe = '1'.
IF sy-subrc EQ 0.
MOVE h_budat TO h1_datum-budat.
APPEND h1_datum TO h_datum.
ENDIF.
ENDSELECT.
ENDLOOP.
SORT h_datum DESCENDING.
READ TABLE h_datum INDEX 1 INTO e_zfbdt.
*
*-----------------------------------------------------------------------
*** Example 2: calculate best payment terms based on manual settings
*-----------------------------------------------------------------------
*
DATA: h2_drseg TYPE mmcr_drseg,
h2_zbd1p TYPE mrm_rbkpv-zbd1p,
h2_zbd1t TYPE mrm_rbkpv-zbd1t,
h2_zbd2p TYPE mrm_rbkpv-zbd2p,
h2_zbd2t TYPE mrm_rbkpv-zbd2t,
h2_zbd3t TYPE mrm_rbkpv-zbd3t,
h21_zbd1p TYPE mrm_rbkpv-zbd1p,
h21_zbd1t TYPE mrm_rbkpv-zbd1t,
h21_zbd2p TYPE mrm_rbkpv-zbd2p,
h21_zbd2t TYPE mrm_rbkpv-zbd2t,
h21_zbd3t TYPE mrm_rbkpv-zbd3t.
LOOP AT ti_drseg INTO h2_drseg WHERE selkz = 'X'.
SELECT zbd1p zbd1t zbd2p zbd2t zbd3t
FROM ekko
INTO (h2_zbd1p, h2_zbd1t, h2_zbd2p, h2_zbd2t, h2_zbd3t)
WHERE ebeln = h2_drseg-ebeln.
IF sy-subrc EQ 0.
IF h2_zbd1p GT h21_zbd1p.
MOVE h2_zbd1p TO h21_zbd1p.
MOVE h2_zbd1t TO h21_zbd1t.
MOVE h2_zbd2p TO h21_zbd2p.
MOVE h2_zbd2t TO h21_zbd2t.
MOVE h2_zbd3t TO h21_zbd3t.
ENDIF.
ENDIF.
ENDSELECT.
ENDLOOP.
IF h21_zbd1p GT i_rbkpv-zbd1p.
MOVE h21_zbd1p TO e_zbd1p.
MOVE h21_zbd1t TO e_zbd1t.
MOVE h21_zbd2p TO e_zbd2p.
MOVE h21_zbd2t TO e_zbd2t.
MOVE h21_zbd3t TO e_zbd3t.
ENDIF.
*
*-----------------------------------------------------------------------
*** Example 3: Setting ZLSPR depending on currency
*-----------------------------------------------------------------------
*
CONSTANTS: c_zlspr_r VALUE 'R',
c_waers_itl TYPE waers VALUE 'ITL'.
IF i_rbkpv-waers = c_waers_itl.
MOVE c_zlspr_r TO e_zlspr.
ENDIF.
ENDMETHOD.
your case is similar to the first example.
Best regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pablo,
Thanks for the code of BADI MRM_PAYMENT_TERMS.
But my requirement is to use BADI MB_MIGO_ITEM_BADI and restrict the creation of GR of items which have delivery date > PO Delivery date.
exact requirement is:-
Invoke Badi MB_MIGO_ITEM_BADI
Only for GR
Check EKKO-BSART =PJ where EKKO-BELNR = MSEG-EBELN
Check if the Po Line item has single or multiple delivery
a) If single
Check if MKPF-CPUDT-3 > EKPO-EEIND
Yes u2013 Create GR
No --- Give error message
b) Multiple Delivery
Check if EKET WEMNG =0
Select EKET-EINDT where EKET-WEMNG < EKET MENGE
Check EKET-EINDT < MKPF-CPUDT-3
Yes u2013 Create GR
No --- Give error message
Error Message : u201CGR Cannot be posted as Delivery date is in future u201C
If u could give the code for that it would be very kind of u.
Thanks
Vivek
Hi
I have a requirement in it a validation needs to be built at GR level to restrict the creation of GR of items which have delivery date > PO Delivery date via BADI or user exists.
Thanks
Vivek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
U can try with Creation of Substitution Rules.
Tcode : GS01
Regrads
Arbind
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
7 | |
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.