Skip to content
Top Menu
  • SAP Tables
  • SAP Tcodes
  • SAP BAPI
  • ABAP Snippets

SAP4TECH

SAP and ABAP Free Tutorials

  • SAP4TECH
    • About Us
    • Contact Us
    • Terms & Conditions
    • Privacy Policy
    • Cookie Policy
  • SAP Technical
    • ABAP Code Snippets
    • ABAP WebDynPro
    • SAP GW
    • SAP IDOC (ALE)
    • SAP PI (XI)
    • SAP Screen Personas
    • SAP Workflow
    • SAP BW
  • SAP Functional
    • SAP SRM
    • SAP CRM
    • SAP FI
    • SAP FSCM
    • SAP HR
    • SAP SD & SAP MM
    • SAP PM
    • SAP PP
    • SAP PS
    • SAP QM
    • SAP VIM
    • SAP WM
  • SAP Fiori
  • SAP S/4 HANA
  • SAP4TECH
Main Menu
ABAP Tutorials / SAP FI

Calculate Due Date in ABAP (BAPI DETERMINE_DUE_DATE)

November 27, 2015January 21, 2020
Calculate Due Date1 e1452811957210

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
    • Prepare Calculate Due Date Structure
  • Account Type in SAP FI
    • ABAP Sample for DETERMINE_DUE_DATE
  • Other BAPI for Payment Dates Calculation
    • SD_PRINT_TERMS_OF_PAYMENT_SPLI
    • SD_PRINT_TERMS_OF_PAYMENT

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 :

  • 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
*"----------------------------------------------------------------------
TaggedAccount TypeINVOICEPaymentSAP BAPIStructure

Related Posts

SAP Workflow Tables SAP Workflow Tcodes

SAP Workflow Tcodes and SAP Workflow Tables

July 12, 2018January 21, 2020

SAP OTR, Online Text Repository OTR Tcodes Tables Function and Translation

SAP OTR Tcodes, Tables, Function and Translation

December 21, 2017January 21, 2022

JSON and ABAP

List of The most important JSON ABAP Classes in SAP

December 19, 2017January 21, 2020

Post navigation

Previous Article Convert BAPI Message to PI Proxy Log
Next Article Manufacturing Plants of a SAP Material

Recent Posts

  • The Most Important SAP ISU Tables
  • SAP Fiori 3 UX and Design of SAP Fiori Apps for SAP S/4HANA, SAP TechEd Lecture
  • The Main SAP Dunning Transaction Codes
  • SAP Accounts Payable Tcodes & Accounts Receivable Tcodes ( SAP AP Tcodes & SAP AR Tcodes)
  • The Most Important SAP Payment Terms Tables (ZTERM, Text…)
  • The most Important SAP Work Center Tables in SAP PP

Quick Navigation

  • SAP Tables
  • SAP Tcodes
  • SAP BAPI
  • ABAP Snippets

Search …

SAP4TECH

  • Home
  • Privacy and Cookie Policy
  • Contact Us
  • About Me
  • Sitemaps
SAP and SAP logo are registered trademarks of SAP AG. sap4tech.net is not associated with SAP AG. We have made every effort to make sure provide relevant search results, use the content on this site at your own risk.
Powered by WordPress and HitMag.