https://sapficoblog.
com/
posting_interface_clearing_bapi-to-post-
clearing-in-sap/
POSTING_INTERFACE_CLEARING –
BAPI to Post Clearing in SAP
Hi All, today I have come up with a different topic that can help you in
clearing the transactions in custom developments. I’m sure you might
have searched about BAPIs while working on the implementation projects.
There are numerous BAPIs available in SAP that allows you to post
different kinds of accounting entries. Today, I will show you how you can
use the BAPI POSTING_INTERFACE_CLEARING to post the clearing
transactions in SAP.
When we are working on an implementation project, most of the time, the
standard transactions or reports do not suffice the client’s requirements.
In such scenarios, we end up developing the custom program and reports.
In some scenarios, we also develop a custom solution to post journal
entries. Now, this can be a normal accounting entry or a clearing entry.
To post a normal accounting document without clearing, you can use
the BAPI_ACC_DOCUMENT_POST. But, to post a clearing transaction, you need
to use the POSTING_INTERFACE_CLEARING BAPI. In standard
SAP, FB05 transaction is used to post the clearing transactions. This BAPI
is used in the background to post the FB05 transaction.
Table of Contents
POSTING_INTERFACE_CLEARING: Execute BAPI in SE37
Input Values in the T_FTCLEAR Table
Input Values in the T_FTPOST Table
Execute the POSTING_INTERFACE_CLEARING BAPI
Post and Display the Clearing Document in FB03
POSTING_INTERFACE_CLEARING: Execute BAPI in
SE37
To execute any BAPI, you can use the transaction code SE37. Enter the
BAPI name on the selection screen and click on the Execute button.
Ent
er the BAPI Name
After Executing the BAPI, you will see two sections namely Import
Parameters and Tables on the next screen. In the import parameters, you
need to maintain the value for the following 3 fields:
I_AUGLV = EINGZAHL (Incoming Payment) or AUSGZAHL (Outgoing Payment) or
UMBUCHNG (Transfer Posting with Clearing)
I_TCODE = FB05
I_SGFUNCT = C
If you remember, when we execute FB05, we have 4 processing types on
the selection screen: Credit Memo, Incoming Payment, Outgoing Payment,
& Transfer Posting with Clearing. Similarly, in the BAPI, we need to use the
I_AUGLV field to determine the processing type.
BAPI Initial Screen
Input Values in the T_FTCLEAR Table
I have posted 1 invoice of $3000 to a customer 3100000007. Now, I want
to transfer this $3000 from a customer to a vendor code using the
Transfer Posting with Clearing option. In this case, I need to clear the
document posted in the customer code and simultaneously transfer it to
the vendor code as an open item.
In a nutshell, you specify all the document numbers that need to be
cleared in the FTCLEAR table. For example, I will specify the debit note of
$3000 with the document number 1800000054. Please enter the following
details:
AGKOA = D (Customer) or K (Vendor) or S (GL Account)
AGKON = Account Code
AGBUK = Company Code
XNOPS = X (If you want to clear only the normal items). Leave it blank if you
also want to consider Special GL Documents for clearing
SELFD = BELNR (Criteria on which you want to identify the document to be
cleared)
SELVON = From Document Number
SELBIS = To Document Number
Since I need to clear the customer document, I have specified AGKOA = D
(customer) and entered the customer code in the AGKON field. In case
you want to clear a vendor document, then you need to specify AGKOA =
K (Vendor) and enter the vendor code in the AGKON field.
Since I know the document number that I want to clear, I have given the
clearing criteria as BELNR in the SELFD field and entered the range of
document numbers to be cleared. You can also use the other clearing
criteria like Reference, Amount, Posting Date, etc.
Fill the FTCLEAR Table
Input Values in the T_FTPOST Table
It’s our turn to enter the details of the vendor code. We have already
specified the document number that we want to clear in the FTCLEAR
table. Now, we need to transfer the same amount of $3000 from the
customer to a vendor code. Please note that the FTPOST table is used to
post the open line items.
In this table, there are only 4 fields:
STYPE = K (Header) or P (Line Item)
COUNT = Number of Line Item
FNAM = Technical Field Name
FVAL = Value for FNAM
Firstly, we need to specify the Header details like Posting Date, Document
Date, Company Code, Currency, etc. For all these fields, we need to create
individual records and the value in STYPE is K. For example, in the
screenshot below, I have added the header field for Currency and given
the value for currency as TWD. Similarly, you need to enter the details of
the other header fields.
Secondly, we need to specify the line item details like Account, Posting
Key, Amount, Text, etc. For the line item records, the value in the STYPE
field should be P.
Fill the FTPOST Table
In the screenshot below, you can see that I have created a total of 7
records for the header fields and only 1 line item. There are 3 fields in a
single line item: Posting Key, Account, and Amount. You need to use the
technical names RF05A-NEWBS and RF05A-NEWKO for Posting Key and
Account fields.
Enter
the Header & Line Item Details
For each header and line item field, you can see the details in the
screenshot below. I’m debiting the vendor code with posting key 21, given
the vendor code as 0A10000002, and the Amount of 3000 TWD.
Enter the Header & Line Item Details
Execute the POSTING_INTERFACE_CLEARING BAPI
After entering all the details, you can click on the ‘ Execute‘ button to
process the clearing transaction. As soon as you execute it, you will notice
that the system is using the FB05 transaction to clear the document.
Execute
the BAPI
In the foreground mode, you will see the system populating all the values
that were given in the FTPOST table. The values for Document Date,
Posting Date, Document Type, Company Code, Currency, Reference, and
Header Text are picked from the FTPOST table where STYPE = K.
Similarly, the values like Posting Key, Vendor Code, and Amount are again
picked from the FTPOST table where STYPE = P.
FB05 Processing Screen
Line Item Details
In the Process Open Items screen, the customer code, company code, and
Document Number are picked from the FTCLEAR table.
Process Open Items
Document Number for Clearing
Post and Display the Clearing Document in FB03
The system will automatically post the clearing document after processing
all the details. This is a clearing document that will clear the customer’s
open item and post a new open item in the vendor code.
As can be seen in the screenshot below, the customer line item is cleared
and the vendor line item is open. This is one example, you can use the
same BAPI POSTING_INTERFACE_CLEARING to post other clearing
transactions as well.
Display the Clearing Document
I hope this is some interesting stuff for you!!! If you have any questions,
please feel free to drop a comment or mail at admin@sapficoblog.com. If
you have read the whole tutorial, you can use
POSTING_INTERFACE_CLEARING in your custom developments with ease.
BAPI To Show Accounting Entry Simulation: FAGL_SPL_SIM_GL_VIEW
F-28 Tcode in SAP: Post an Incoming Payment
6 July 2020
POSTING_INTERFACE_CLEARING – BAPI to Post
Clearing in SAP”
Permalink
That a wonderful document. I have a requirement to post a Journal Entry
Clearing document with partial amount. I am doing it with F-28 tcode, so
could you please let me now if we can use this BAPI for the same and if so
how can I use this.
o abhishek6259
21 February 2022 at 10:25 am
Permalink
Ok so after making the partial payment, are you adjusting the rest of
the amount somewhere and clearing the original invoice? If yes, then
you specify the original invoice number in the FTCLEAR section and the
partial payment and the adjustment details in the FTPOST section.
Andrew Smith
11 February 2022 at 3:28 pm
Permalink
Gday
I have been using the function POSTING_INTERFACE_CLEARING
successfully , except when in ‘B’ batch run, I cannot get the NEW
document number returned from the function module. I have been
cribbing lots of SAP code to read BDC log etc but it always seems to get
the previous log! Any ideas?
BAPI To Show Accounting Entry
Simulation: FAGL_SPL_SIM_GL_VIEW
18 August 2021abhishek6259
In my previous post, I explained the BAPI that can be used to
post clearing transactions. Today, I will discuss the BAPI to show
accounting entry simulation before the actual posting. In this scenario,
you can use the BAPI FAGL_SPL_SIM_GL_VIEW.
SAP provides the functionality of simulating an accounting entry before
posting it to the GL accounts. This allows a user to display the accounting
entry that the system is going to post. Then, the user can validate the
accounting entry and post it in the system.
When you execute transactions like F-02, FB60, etc., there is an option to
simulate the accounting entry after entering all the details on the main
screen. As soon as you click on the Simulate button, SAP displays the
accounting entry. In the background, SAP uses the BAPI
FAGL_SPL_SIM_GL_VIEW to simulate and display the accounting entry.
But the question is why do you need it? If you have worked on an implementation project,
then you must be aware of the custom developments that the client demands from the
consultants. In some of the developments, they usually have a requirement to post accounting
entries via BAPI_ACC_DOCUMENT_POST. But, before posting the accounting entry directly,
sometimes the client asks to display the accounting entry that is going to post in the system.
That is where this BAPI can be used.
Table of Contents
Step 1: Execute the BAPI FAGL_SPL_SIM_GL_VIEW in SE37
Step 2: Fill the I_T_BKPF Header Table
Step 3: Fill the I_T_BSEG Line Items Table
Step 4: Execute the BAPI to Show Accounting Entry Simulation
Step 1: Execute the BAPI FAGL_SPL_SIM_GL_VIEW in
SE37
You can execute the BAPI in transaction code SE37. Enter the BAPI name
and click on the ‘Execute‘ button.
Enter BAPI Name in SE37
After executing the BAPI, you will notice the import parameters I_T_BKPF
and I_T_BSEG. As you already know, BKPF is the header table that stores
the accounting document header details such as Document Date, Posting
Date, Currency, Header Text, Reference, etc.
Similarly, BSEG is a line item table that stores all the line items of an
accounting document. The details like GL account, Amount, Cost Center,
Profit Center, etc. are stored in the BSEG table.
Enter the Import Parameters
Step 2: Fill the I_T_BKPF Header Table
The first thing you need to do is fill in both tables. Starting with the header
table BKPF, you need to fill in all the required details like Company Code,
Document Type, Document Date, Posting Date, etc.
In the screenshot below, I have given the Company Code 1234, Document
Type SA, Document and Posting Dates 30th June 2021, Username TEST,
Currency USD, and Transaction Code FB01. All these header values will be
shown in the simulation BAPI after I execute it.
Fill the BKPF Table
BKPF Table Details
Step 3: Fill the I_T_BSEG Line Items Table
After filling the header table, you need to enter the data in the line item
table BSEG. To complete any accounting entry, you need at least 1 debit
and 1 credit line item. In this example, I’m using the GL account posting in
both the line items. For line item 1, I have entered the company code,
fiscal year, line item number (BUZEI), Account Type S, Debit/Credit
Indicator H, Amount $10.
If you want to simulate customers and vendors, you need to use the
account types D & K respectively. For the SHKZG field, the debit amount
indicator is S, and the Credit amount indicator is H.
Fill the BSEG Table
I have also entered the expense GL account 6411400121. As you are
aware that for any expense account, we need to use a cost object. So, I
have also entered the cost center 12345678.
For Line item 2, I have given similar details except for BUZEI, SHKZG,
HKONT, and KOSTL. In line item 1, I used an expense account and debited
it with $10. In line item 2, I will use a balance sheet account and keep the
cost center field blank.
Since this is our second line item, I have given BUZEI as 002 and the
Debit/Credit Indicator as Debit (S).
Line Item 2
I have entered the balance sheet GL Account 9999999993.
Step 4: Execute the BAPI to Show Accounting Entry
Simulation
After entering all the details, you can see that the import parameters’
tables are filled with data. The BKPF table has 1 entry and the BSEG table
has 2 entries (1 entry for each debit/credit line item).
You can click on the ‘Execute‘ button to display the simulation results.
Execute the BAPI
After executing the BAPI, you can display all the details that were entered
in the import parameters. There are some fields like Posting Period,
Ledger, GL account name, etc. that will be automatically picked based on
the data entered.
For example, the system will derive the posting period from the posting
date field, and GL Account Name from the GL account code.
Display the Simulation
I hope you have liked this tutorial on the BAPI to show accounting entry
simulation. If you have any questions, please feel free to drop a comment
or mail at admin@sapficoblog.com. If you have read the whole tutorial, now
you can use FAGL_SPL_SIM_GL_VIEW in your custom developments with
ease.
BAPI_ACC_DOCUMENT_POST: BAPI to
Post Accounting Document in SAP
10 September 2021abhishek6259
In the previous two posts, I discussed the BAPI concept for
posting clearing postings and simulating the accounting entries. Today, I will
give you a brief tutorial on how to use the BAPI to post an accounting
entry in SAP. BAPI_ACC_DOCUMENT_POST allows you to post any kind of
accounting entry, i.e., GL postings, Customer or Vendor postings, etc.
The only drawback of this BAPI is that it does not post clearing
transactions. So, if you want to post an accounting entry and
simultaneously do the clearing as well, then you should check out my
tutorial on POSTING_INTERFACE_CLEARING BAPI.
Today, I will show you a scenario where I will post an accounting
document with a total of 3 line items. 2 GL line items, One balance sheet,
and one expense, and 1 customer line item. In this BAPI, there are
separate tables for each type of posting. For example, if you want to post
only to a GL Account, then there is one table that you need to populate.
Similarly, to post customer or vendor postings, there are separate tables.
Unlike POSTING_INTERFACE_CLEARING that is used for the FB05 transaction code,
please note that the BAPI_ACC_DOCUMENT_POST is the same as transaction code FB01
or F-02. As you already know that FB01 allows you to post accounting documents without
clearing.
Table of Contents
Step 1: Execute the BAPI_ACC_DOCUMENT_POST in SE37
Step 2: Fill the Header Details in the DOCUMENTHEADER section
Step 3: Fill the GL Account Details in the ACCOUNTGL Table
Step 4: Fill the Customer Code Details in the ACCOUNTRECEIVABLE Table
Step 5: Enter the Amounts for all the Line Items in the CURRENCYAMOUNT
Table
Step 6: Execute the BAPI & Post the Accounting Document
Step 1: Execute the BAPI_ACC_DOCUMENT_POST in
SE37
To display the BAPI structure & tables, you need to execute it in t-
code SE37. Enter the BAPI name BAPI_ACC_DOCUMENT_POST in the
function module field and click on the ‘ Execute‘ button given at the top in
the navigation section.
BAPI Name in SE37
After you execute the BAPI, you will notice two sections namely Import
Parameters & Tables. Under Import Parameters, you need to specify the
accounting document header details like Document Date, Posting Date,
Company Code, Reference, Header Text, etc. Since these header details
remain the same for the whole accounting document, hence it is to be
filled at the header level.
For all the line items, this BAPI has multiple tables. For
example, ACCOUNTGL, ACCOUNTRECEIVABLE, & ACCOUNTPAYABLE tables
are used for entering the GL accounts, Customer Codes, & Vendor Codes
respectively.
There are other tables like ACCOUNTTAX & CRITERIA that can be used to
enter tax & COPA-related details respectively.
BAPI Initial Screen
Step 2: Fill the Header Details in the
DOCUMENTHEADER section
As a first step, you need to enter the accounting document header details.
In the screenshot below, I have entered all the required fields like Header
Text, Username, Document & Posting Date, Company Code, Document
Type, & Reference.
Enter the Document Header Details
Step 3: Fill the GL Account Details in the ACCOUNTGL
Table
As I mentioned earlier, I’m showing a scenario where I am going to post 3
line items (2 for GL Accounts & 1 for Customer). Basically, I’m going to
post the following accounting entry:
Account Debit/Credit Indicator Amount
Balance Sheet GL a/c Cr. 100-
Expense GL a/c Dr. 40
Customer Code Dr. 60
Since I have 2 GL line items, I need to enter both the GL account details in
the ACCOUNTGL table. Starting with the Balance Sheet GL Account, I have
given ITEMNO_ACC as 1, GL Account, Item Text, and Company Code.
Enter the GL Line Items
Similarly, I will enter the second line item for the expense GL account. In
this case, ITEMNO_ACC is 2 and since it’s an expense account, I have also
entered a cost center.
Enter the GL Line Items
Enter the Cost Center
Step 4: Fill the Customer Code Details in the
ACCOUNTRECEIVABLE Table
Now it’s time to enter the details for the third line item for customer. If
you are posting to a customer code, then you need to use this table. The
ITEMNO_ACC is 3 now, enter the customer code along with other details
like payment terms, item text, etc. You can also make use of other
optional fields like payment method, reference key, etc.
Enter the Customer Details
Step 5: Enter the Amounts for all the Line Items in the
CURRENCYAMOUNT Table
You might have noticed that so far we have only entered the GL account
and customer code. We haven’t specified the amounts for each line item
and also the debit/credit indicators. In the BAPI, you need to enter the
amounts along with currency & debit/credit indicators in the
CURRENCYAMOUNT table.
In the screenshot below, for all the line items, the document currency is
USD. Also, for line item 1, amount is -$100. The negative sign next to the
amount identifies it as a credit amount. Similarly, for the rest of the 2 line
items, I have provided a debit amount. As you can see, the credit amount
is equal to the debit amount. So, while posting this document, we
shouldn’t face any ‘Balances in Transaction Currency’ error.
Enter the Amounts for all line items
Step 6: Execute the BAPI & Post the Accounting
Document
After entering the details of all the line items, when you go back to the
main screen of the BAPI, you would notice that there are entries under
each table. For example, there are 2 entries in ACCOUNTGL table. It
means this table has 2 GL line items. A 1 entry in ACCOUNTRECEIVABLE
table means there is 1 customer line item.
Similarly, 3 entries in CURRENCYAMOUNT table means that the amounts
have been entered for all the 3 line items. Click on the ‘ Execute‘ button to
post the accounting document.
Execute the BAPI
After executing the BAPI, you can see the posted accounting document
number in the Export Parameters section. For example, the accounting
document posted is 0100000025 in company code 1234, and fiscal year
2021.
Display the Results
I hope you have liked this tutorial on the BAPI_ACC_DOCUMENT_POST to
post an accounting document. If you have any questions, please feel free
to drop a comment or mail at admin@sapficoblog.com. Until next time,
Take Care!!!