12-18-2013 11:05 AM
Hi,
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.
Thanks.
12-18-2013 11:53 AM
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.
else.
new_wa-amount = I_BSIS-amount * -1.
endif.
collect new_wa to new_table.
endloop.
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!
Regards,
Naveen
12-18-2013 11:54 AM
Hello,
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.
Endloop.
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.
Endloop.
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.
12-18-2013 12:15 PM
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.
Regards,
G.Sethuraman