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
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.
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.
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.
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.
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.
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.
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.
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.
In the Process Open Items screen, the customer code, company code, and Document Number are picked from the FTCLEAR table.
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.
I hope this is some interesting stuff for you!!! If you have any questions, please feel free to drop a comment or mail at firstname.lastname@example.org. If you have read the whole tutorial, you can use POSTING_INTERFACE_CLEARING in your custom developments with ease. Until next time, Take Care!!!