cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI for automatic clearing (similar to F.13)

Former Member
0 Kudos

Hi ABAP Gurus,

I need to create a new program that should be able to clear by comparing the ASSIGNMENT filed of the payment document (DZ) against the REFERENCE field of the installment invoice (II).

With this, do you know a BAPI that I can use for this? I assume this BAPI will be similar as to how F.13 works.

Thanks for your inputs.

Regards.

Brando

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

You may have to write your own... the F.13 / SAPF124 process will follow the clearing rules defined in SPRO under in "Prepare Automatic Clearing" which allows grouping by up to 5 separate grouping fields, but not cross-field matching .. so ZUONR vs XBLNR isn't a typically supported combination.

My general approach when asked to do similar processing has been to write my own function module (or class method) that will accept an array document line items to clear and feed these into a BDC / Call Transaction for FB05... and then you have to write a program to read in the open items (BSID for customer items), identify the matched items, and feed these into the FM / method to do the SAP clearing work (the reason for the FM / method is re-usability / modularity... it always seems that once you've built this once, the client finds another process that needs similar clearing logic).

Any chance you could get clearing reference key value recorded into the Assignment field on both the payment document and installment invoice instead?.. then SAPF124 could be scheduled to do the clearing in the background once a day / hour.

Jonathan

Former Member
0 Kudos

Hi Jonathan,

Thank you very much for your inputs.

I think we can transfer the value of the XBLNR to ZOUNR via substitution exit. But, the problem here is that there are multiple line items with same XBLNR. As such, as per my understanding, F.13 will still not be able to clear line items since the ratio is 1:many.

Does it mean that FB05 clears the same way as that of F.13 for customers? In FB05, we just have to determine the credit and debit entries that should be cleared. Is this correct?

Again, thanks for your help.

Best regards.

Brando

brad_bohn
Active Contributor
0 Kudos

You can also use FB1D in A/R. Both FB05 and FB1D will clear based on the selections you make, not the criteria specified in the IMG. My suggestion would have been the substitution (or an alternate user exit/enhancement in SD for the SD side) as you mentioned. As long as the debits and credits match, then the items will clear; it does not matter how many items are in the group. Prior to A/R archiving, I often set the criteria to customer and clear by year for our accounts that don't get regularly cleared. It's a much easier process to use the standard clearing program in a batch job. You can also further restrict the clearing to certain docs by submitting the clearing program from a shell program and specifying certain docs for a 'grouping'.

Former Member
0 Kudos

As Brad confirm, the F.13 processing will pick up 1:N or even N:N open items and clear them based on your criteria... one site I work up sometimes builds up a mix of several hundred debits and credits within individual customer accounts over a couple of months before these clear off.

One thing to be aware of with FB05 is where you might have several open line items on the same document as the transaction's default logic will bring in all of these into the list of items to be cleared so your code would need to be able to deselect the ones you don't want - it may not be a situation that affects your scenario, but it needed some careful programming (plus I set up an additional sort option for the line item matching dynpro).

Another approach that I haven't tried is that used within F.13 itself - if you drill down into the code far enough you will see the SAP code does Call Transactions itself - but prior to the call it exports a list of items to a memory id, so I assume you could also try this technique - just never tried myself.

But, like Brad, I'd try to get the ZUONR set correctly on all the line items via substitution or whatever ... we also built a simple utility for one site that allowed the A/R end users to change just that field in bulk (list entries, select items, popup screen to collect new Assignment value, then BDC / call trans to FB02 to zap it) just so the automatic clearing could do the hard(er) multi-line clearing work for you.

Jonathan

Former Member
0 Kudos

Thanks for your inputs on this. I'm currently trying to use POSTING_INTERFACE_CLEARING in my custom program. Is it possible to clear two documents using their document numbers and the said FM? Thanks in advance for all your help.

Former Member
0 Kudos

It looks quite possible - that function module builds up a BDC / Call Transaction to FB05 (or a couple of other Tcodes)... I did a "where used" and it has several references in SAP - the RFFMPOSA report looks like a model you could follow (form clear_account). Our custom function module does a bit more than this as we sometimes need to clear differences to another account, but for simply clearing a list of documents together it looks fine.

Jonathan

Former Member
0 Kudos

Thanks again, I was able to post and clear already using the said FM. I'll try to look at the program you mentioned and check if it can only clear documents. Thanks again.