Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor
Hello Experts,

Posting the documents with Clearing open items and doing the transfer postings is a very common requirements in most of the SAP implementation FICO based projects.

Clearing can done in multiple ways

  • G/L posting with clearing

  • Customer - Customer  Posting with clearing

  • Vendor- vendor Posting with Clearing

Till today for the custom based requirements we are using either BDC on the transactions F-30 or FB05 with Transfer posting with clearing options or using the below three function modules which is detailed out in the below blog .




However with the ABAP cloud and Fiori apps are coming into picture there was an alternative approach required to perform the transfer postings.

New Approach for the Transfer postings :

During the analysis to find a new class or function module to avoid the BDC coding and perform the above activity the below applications Upload Journal Entry app  F2548'F2548')/S24OPand the SOAP based Interface which is posting the Journal Entries is evaluated and realized the class CL_FDC_ACCDOC_POST=> ACCDOC_POST is used in the same.

Before Moving into the technical solution let us understand what is the Transfer posting with Clearing :

Lets say customer 1  has total open items of 2000 Eur and out of that he wants to transfer 1500 to another customer and clear the original posting we can use any of the transaction FB05 or F-30 to do the same using the options

  • Open Transaction F-30 provide the customer1 details to be cleared and posted

F-30 Transaction

Enter the amount to be transferred from Customer 1

Transfer Amount

Now click on the Process Open Items buttons and check the list of open items

Now click on the Charge Off Difference to charge the remaining amounts to Customer 2 for Clearing as shown below enter amount as *

On Click of back button the posting will be seen as below with the customer line items and the amounts to be transferred,

Thus you can do the postings and clear the Customer 1. When you open the Open items again for the Customer 1 1500 will be cleared.


Find the below reference code for the reference for Customer - Customer Transfer posting scenario .

  • Fill the Header structure

  • Fill the Item Table with the line items for the Customer 1 to be transferred

  • Fill the Item table to be cleared structure with the Customer 2 number

  • Simulate using the class method cl_fdc_accdoc_post=>accdoc_simulate  to check for any errors

  • In case of no errors use the class cl_fdc_accdoc_post=>accdoc_post  or wrap the class inside a RFC Function module for RAP based scenarios and call the function module with Destination 'NONE' to avoid the commit dumps .

NOTE : The below code will help to start with the postings with clearing but it might non work 1-1 in practical scenarios .
*& Report Z_POST_CLEAR
REPORT z_post_clear.
DATA: fdc_accdoc_tax TYPE fdc_t_accdoc_tax,
fdc_accdoc_whtax TYPE fdc_t_accdoc_whtax,
fdc_accdoc_itm_to_be_clrd TYPE fdc_t_accdoc_itm_to_be_clrd,
fdc_accdoc_pay_diff TYPE fdc_t_accdoc_pay_diff,
accdoc_itm_copa TYPE fdc_t_accdoc_itm_copa,
fdc_accdoc_itm TYPE fdc_t_accdoc_itm,
accdoc_dispute TYPE fdc_t_accdoc_dispute,
accdoc_one_time_account TYPE fdc_t_accdoc_one_time_account,
itm_payment_only TYPE fdc_s_accdoc_with_item,
fdc_accdoc_warning_messages TYPE fdc_t_accdoc_warning_messages,
warning TYPE fdc_t_accdoc_warning_messages.
** Fill header info
DATA(headerinfo) = VALUE fdc_s_accdoc_hdr( bukrs = '0001'
blart = cl_abap_context_info=>get_system_date( )
budat = cl_abap_context_info=>get_system_date( )
waers = 'EUR'
hwaer = 'EUR' " Get the currencies from CDS View p_ldcmpcurr
hwae2 = 'EUR' " Get the currencies from CDS View p_ldcmpcurr
xblnr = 'Test13'
gjahr = '2023'
tcode = cl_fdc_posting_impl=>co_fdc_s_accdoc_hdr_tcode-ar_clearing "FBDC_C022'
auglv = 'UMBUCHNG'
curt1 = '10' " Get the currencies from CDS View p_ldcmpcurr
curt2 = '10' " Get the currencies from CDS View p_ldcmpcurr
awtyp = 'BKPFF'
augtx = 'cleared header text' ).
"Get the Open Items from the CDS view I_OperationalAcctgDocItem and loop at it and fill the item informations
DATA(iteminfo) = VALUE fdc_t_accdoc_itm(
( shkzg = 'S'
bschl = '17' " Other Clearing
bukrs = '0001'
gjahr = '2023'
wrbtr = 1500
dmbtr = 1500
dmbe2 = 1500
zuonr = 'zuonr'
kunnr = Customer 1 " for the GL clearing fill HKONT instead of KUNNR
posnr = '0000000001'
koart = 'D'

DATA(clearinfo) = VALUE fdc_t_accdoc_itm_to_be_clrd(
( belnr = '0100000000'"Get the Open Documents from the CDS view I_OperationalAcctgDocItem
bukrs = '0001'
gjahr = '2023'
awitem = '000002'
wrbtr = 100
dmbtr = 100
dmbe2 = 100
shkzg = 'H'
xaktp = abap_true
koart = 'D'
konko = Customer2
hkont = '1331100010'

** Simulate the posting to check the errors
et_ausz2 = DATA(ausz2)
et_ausz3 = DATA(ausz3)
et_message = DATA(return)
et_simulated_gl_view = DATA(simulated_gl_view)
et_fdc_accdoc_hdr_sim = DATA(fdc_accdoc_hdr_sim)
es_fdc_accdoc_disc_doc = DATA(fdc_accdoc_disc_doc)
cs_fdc_accdoc_hdr = headerinfo
ct_fdc_accdoc_tax = fdc_accdoc_tax
ct_fdc_accdoc_whtax = fdc_accdoc_whtax
ct_fdc_accdoc_itm_to_be_clrd = clearinfo
ct_fdc_accdoc_pay_diff = fdc_accdoc_pay_diff
ct_accdoc_itm_copa = accdoc_itm_copa
ct_fdc_accdoc_itm = iteminfo
ct_accdoc_dispute = accdoc_dispute
ct_accdoc_one_time_account = accdoc_one_time_account
cs_with_itm_payment_only = itm_payment_only
ct_fdc_accdoc_warning_messages = fdc_accdoc_warning_messages " Warning Messages


** For RAP based apps use thie function module with destination None to avoid commit dumps
CALL METHOD cl_fdc_accdoc_post=>accdoc_post
is_fdc_accdoc_hdr = headerinfo
it_fdc_accdoc_itm = iteminfo
iv_ignore_warnings = abap_true
et_message = DATA(message)
ev_awref = DATA(awref)
es_posted_document = DATA(posted_document)
ct_fdc_accdoc_itm_to_be_clrd = clearinfo
ct_fdc_accdoc_warning_messages = warning
rv_save_rejected = DATA(rejected).
IF posted_document IS NOT INITIAL.

Thus you can avoid the BDC programming going forward for the F-30 and FB05 transactions

Labels in this area