Calculate Due Date in ABAP is main requirement when dealing with invoices and payment of this invoice.
It helps you also to handle dunning by calculating the Due date and current date and set the dunning level.
First let’s define the different Account Type, then we will detail the SAP BAPI to use when retrieving Due Date.
Table of Contents
Calculate Due Date
In order to determine the Due Date for an invoice, you can use the standard bapi ‘DETERMINE_DUE_DATE’. As input, it will take i_faede.
The output is e_faede and the duedate field is FAEDE-NETDT.
You way want to check also Step by Step Guide To Create Sap Down Payment with VIM
Prepare Calculate Due Date Structure
Before calculating the DueDate in SAP FI, the following Structure types as FAEDE should be filled.
The structure for Due Date input (FAEDE) is:
Fields | Description |
---|---|
SHKZG | Debit/Credit Indicator |
KOART | Account Type |
ZFBDT | Baseline Date for Due Date Calculation |
ZBD1T | Cash discount days 1 |
ZBD2T | Cash discount days 2 |
ZBD3T | Net Payment Terms Period |
REBZG | Number of the Invoice the Transaction Belongs to |
REBZT | Follow-On Document Type |
BLDAT | Document Date in Document |
NETDT | DueDate for Net Payment |
SK1DT | DueDate for Cash Discount 1 |
SK2DT | DueDate for Cash Discount 2 |
For more information about Finance module in SAP, check :
- SAP FI Tcodes & SAP CO Transaction Codes (Finance and Controlling Tcodes in SAP)
- List of Important SAP FI Tables (SAP Finance Tables)
The second step is to set the Account Type. Check the first section for different type of Account in SAP Invoice.
To go deep into ABAP development for SAP FI, check the following book ABAP Development for Financial Accounting: Custom Enhancements.
Account Type in SAP FI
The Account Type in SAP FI defines the type of SAP Account
The field in SAP Table is BSIS-KOART for Acct type in SAP.
In SAP FI, Account Type can have the following possible Values:
- A : Assets
- D : Customers
- K :Vendors
- M :Material
- S :G/L accounts
Check also SAP Invoice IDoc INVOIC2
ABAP Sample for DETERMINE_DUE_DATE
Let’s give a sample ABAP Code with DETERMINE_DUE_DATE function call.
You can set FAEDE input from an entrie from BSIS. The result for the Due Date can found in FAEDE-NETDT.
Move-corresponding bsis to faede. " Call of DETERMINE_DUE_DATE CALL FUNCTION 'DETERMINE_DUE_DATE' EXPORTING i_faede = faede IMPORTING e_faede = faede EXCEPTIONS OTHERS = 1. " Calculated Due Date WRITE: 'Due Date' , faede-netdt ." due date
Other BAPI for Payment Dates Calculation
The following SAP BAPI can help retrieve more data for Payment information of a SAP Account in SAP FI
- SD_PRINT_TERMS_OF_PAYMENT used to retrieve single payment term
- SD_PRINT_TERMS_OF_PAYMENT_SPLI can be used to retrieve multiple payment terms at once
SD_PRINT_TERMS_OF_PAYMENT_SPLI
This function SD_PRINT_TERMS_OF_PAYMENT_SPLI (Preparation of Terms of Payment According to Table 052) is in the function group VPRI SD Print Functions.
The signature of SD_PRINT_TERMS_OF_PAYMENT_SPLI is :
FUNCTION SD_PRINT_TERMS_OF_PAYMENT_SPLI. *"---------------------------------------------------------------------- *"*"Lokale Schnittstelle: *" IMPORTING *" VALUE(BLDAT) LIKE VBRK-ERDAT DEFAULT 00000000 *" VALUE(BUDAT) LIKE VBRK-FKDAT DEFAULT 00000000 *" VALUE(CPUDT) LIKE VBRK-ERDAT DEFAULT 00000000 *" VALUE(LANGUAGE) LIKE NAST-SPRAS DEFAULT ' ' *" VALUE(TERMS_OF_PAYMENT) LIKE T052-ZTERM *" VALUE(WERT) LIKE ACCCR-WRBTR DEFAULT 00000000 *" VALUE(WAERK) LIKE VBRK-WAERK DEFAULT ' ' *" VALUE(FKDAT) LIKE VBRK-FKDAT DEFAULT 00000000 *" VALUE(SKFBT) LIKE ACCCR-SKFBT DEFAULT 00000000 *" VALUE(I_COMPANY_CODE) LIKE VBRK-BUKRS OPTIONAL *" VALUE(I_COUNTRY) LIKE VBRK-LAND1 OPTIONAL *" EXPORTING *" VALUE(BASELINE_DATE) LIKE VBRK-FKDAT *" TABLES *" TOP_TEXT_SPLIT STRUCTURE VTOPIS *" EXCEPTIONS *" TERMS_OF_PAYMENT_NOT_IN_T052 *" TERMS_OF_PAYMENT_NOT_IN_T052S *"----------------------------------------------------------------------
SD_PRINT_TERMS_OF_PAYMENT
The standard Function module SD_PRINT_TERMS_OF_PAYMENT is for “Format Terms of Payment According to Table 052”.
Here the signature of this function:
FUNCTION SD_PRINT_TERMS_OF_PAYMENT. *"---------------------------------------------------------------------- *"*"Lokale Schnittstelle: *" IMPORTING *" VALUE(BLDAT) LIKE VBRK-ERDAT DEFAULT 00000000 *" VALUE(BUDAT) LIKE VBRK-FKDAT DEFAULT 00000000 *" VALUE(CPUDT) LIKE VBRK-ERDAT DEFAULT 00000000 *" VALUE(LANGUAGE) LIKE NAST-SPRAS DEFAULT ' ' *" VALUE(TERMS_OF_PAYMENT) LIKE T052-ZTERM *" VALUE(COUNTRY) LIKE KNA1-LAND1 DEFAULT ' ' *" VALUE(HOLDBACK) LIKE VBDKR-P_SPLIT DEFAULT ' ' *" VALUE(TOP_HOLDBACK_INFO) LIKE FPLTVB STRUCTURE FPLTVB *" OPTIONAL *" VALUE(DOCUMENT_CURRENCY) LIKE VBRK-WAERK DEFAULT ' ' *" EXPORTING *" VALUE(BASELINE_DATE) LIKE VBRK-FKDAT *" VALUE(PAYMENT_SPLIT) LIKE VBDKR-P_SPLIT *" VALUE(ZFBDT) LIKE VBDKR-ZFBDT *" TABLES *" TOP_TEXT STRUCTURE VTOPIS *" EXCEPTIONS *" TERMS_OF_PAYMENT_NOT_IN_T052 *"----------------------------------------------------------------------