Categories: ABAP TutorialsSAP FI

Calculate Due Date in ABAP (BAPI DETERMINE_DUE_DATE)

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.

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:

FieldsDescription
SHKZGDebit/Credit Indicator
KOARTAccount Type
ZFBDTBaseline Date for Due Date Calculation
ZBD1TCash discount days 1
ZBD2TCash discount days 2
ZBD3TNet Payment Terms Period
REBZGNumber of the Invoice the Transaction Belongs to
REBZTFollow-On Document Type
BLDATDocument Date in Document
NETDTDueDate for Net Payment
SK1DTDueDate for Cash Discount 1
SK2DTDueDate for Cash Discount 2

For more information about Finance module in SAP, check :

The second step is to set the Account Type. Check the first section for different type of Account in SAP Invoice.

Related Post

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
*"----------------------------------------------------------------------
Share
Published by
John

Recent Posts

The Most Important SAP ISU Tables

SAP ISU Tables for Technical master data, for Billing Master Data, Billing and invoicing Tables?…

December 22, 2020

SAP Fiori 3 UX and Design of SAP Fiori Apps for SAP S/4HANA, SAP TechEd Lecture

SAP Fiori 3 UX and Design of SAP Fiori Apps for SAP S/4HANA, SAP TechEd…

November 18, 2020

The Main SAP Dunning Transaction Codes

Dunning is the business practice of informing a customer of past due payment. Dunning letters…

November 28, 2019

SAP Accounts Payable Tcodes & Accounts Receivable Tcodes ( SAP AP Tcodes & SAP AR Tcodes)

SAP AP Tcodes & SAP AR Tcodes: House Banks Tcodes, Advance Payments or Down Payments,…

August 1, 2019

The Most Important SAP Payment Terms Tables (ZTERM, Text…)

What are the main SAP Payment Terms Tables ? What are the related Tables in…

October 21, 2018

The most Important SAP Work Center Tables in SAP PP

Work center consists of master data related to routing of products. It contains data related…

October 21, 2018