Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 

Need to clear FI documents

Former Member
0 Kudos


I have fetched some data from BSIS to the internal table. Internal table has fields HKONT, ZUONR, BELNR, BUZEI, BLDAT, SHKZG, DMBTR, PRCTR. Only one GL will be selected at a time in internal table. Here I have to sort internal table in ascending order by PRCTR, ZUONR and BLDAT. Now I have to clear documents whose debit credit entries are of the same amount. Please can you let me know with sample code, how I should pick up documents for clearing from internal table. I have done till sorting.



Active Contributor
0 Kudos

This cannot be done with statements like delete adj. duplicates. You will have to loop your internal table data to find same Debit and Credit values and then delete them.

Some thing like, create one more internal table with just two fields i.e. Document Number and Amount.

Loop at I_BSIS.

new_wa-Doc = I_BSIS-Doc.

  if SHKZG = Debit.

   new_wa-amount =  I_BSIS-amount.


   new_wa-amount =  I_BSIS-amount * -1.


  collect new_wa to new_table.


delete new_table where amount <> 0.

Now, this new_table will be having all Document number that have to be deleted from your Internal table. You can same logic in different ways!



Active Contributor
0 Kudos


a sujjestion from my side to achieve your goal.

Create two work area, both of the type of your internal table.

Create another internal table  ( say  itab1) and copy all data from first table.(say itab)

Loop your internal table (itab) .

Read table itab1 when SHKZG = 'H'.

****ADD the value of DMBTR here and assign it in first work area you have created.


Loop your internal table (itab) .

Read table itab1 when SHKZG = 'S'.

****ADD the value of DMBTR here and assign it in second work area you have created.


now write your code logic as below.

if work-area1-dmbtr = work-area2-dmbtr.

Delete your itab based on this condition.

It will surely help you, if you are not getting my points , then plesae revert me.

Former Member
0 Kudos

Hi ABAP Guy,

You can do automatic clearing in F.13 t code.

Before that you should config the node SPRO--->Financial accounting--->General ledger accounting--->Business transactions--->Open item clearing--->Prepare automatic clearing and give your criterias(PRCTR, ZUONR and BLDAT) in the node.

Sample screenshot attached.