Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

BADI MRM_PAYMENT_TERMS - Baseline date

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.

Former Member
Not what you were looking for? View more on this topic or Ask a question