2016 Apr 25 6:37 PM
Sometimes you may need create FI documents in your customer ABAP‑programs. Several techniques are useful for this, e.g. batch-input execution, direct accounting document input and so on and also BAPI.
And sometimes you may need to post FI-document with clearing including partial one. In this case it is not so obvious to use standard programming interface without batch‑input simulation of t-code ‘FB05’, such as function ‘AC_DOCUMENT_DIRECT_INPUT’ or BAPI function ‘BAPI_ACC_DOCUMENT_POST’. The text below explains as to make it for both cases.
The first obstacle for clearing with direct document input is a lack of input parameters with clearing‑info: AUSZ2_TAB and AUSZ_CLR_TAB types. In other words you want to tell FI‑interface that some item should be cleared by your document, but you can’t. You may ask why standard programs as ‘SAPMF05A’ processes a clearing with no problem, well answer is ‘BELEG’ RWIN-process used in that case, not ‘DOCUMENT’.
Key points to receive and handle clearing information with a non‑dialog posting procedure are:
The first function triggered at DOCUMENT/SPLIT RWIN‑event. So the only you need is to fill clearing info before the one has called. You might use one of 2 techniques to do this, depending on development rules for you project team:
In any case you might use unified ABAP logic (see attached example for RWIN) according to the following restrictions:
Short description of ABAP logic attached:
Well first the most of solution told above is applicable to BAPI also. Because the same function AC_DOCUMENT_CREATE called from AC_DOCUMENT_DIRECT_INPUT as well as from BAPI function.
The specific obstacle for BAPI is a lack of fields where you can pass clearing item reference: REBZG, REBZJ, REBZZ, and also helpful fields REBZG_CHECK and AUGBL. The solution contains 2 steps:
2016 May 09 6:03 PM
Hi Alexander,
thank you for the excellent post.
I'm very eager to substitute clearing transaction F-32 by BAPI_ACC_DOCUMENT_POST.
In F-32, the clearing information is provided by passing T_AUSZ3 to function FI_DOCUMENT_PROCESS with I_EVENT = 'PROJECT'.
Even in the 'POST' event I have only one line in T_BKPF and for the RW interface just onle line T_ACCIT is created.
Now I have no idea how the clearing items T_AUSZ3 may be supplied in BADI_ACC_DOCUMENT. Will I create additional
C_ACCIT
C_ACCCR
C_ACCWT
C_ACCTX
lines from my extension data here?
Can you give me a hint?
The code in z_rwin_clearing_sample does not really explain it or I do not fully understand
Thank You.
Best regards Clemens
2016 May 10 2:51 PM
Hi Clemens.
I think you should create as much items as required for zero-balancing your document.
But I wouldn't recommend you to add items within BADI implementation only to simulate 'F-32' visual behavior in your program internals. It will be much better if you construct all items of your clearing document before you call BAPI_ACC_DOCUMENT_POST. How they looks you might see in clearings that are really made by F-32.
2016 May 12 12:10 PM
Hi Alexander,
I'll try to do that:
Because the document created by clearing with F-32 has no items at all but will fill in the clearing data into the cleared items as AUGBL AUGT etc. I'm still in doubt how to convince the BAPI to behave like this.
Where will I supply the document and/or reference number of the items to be cleared?
I'm still in doubt as I do not want to create any new items but clear existing items.
My idea was to fill the T_AUSZ3 for further processing, but how?
Can you give any hints?
Best regards
Clemens
2016 May 13 9:56 AM
Hi, Clemens.
If you just about full clearing by itemless document then ... to use BAPI_ACC_DOCUMENT_POST whould be excessive I think. And besides, sample code above whouldn't work, it has to be improved for the case of itemless clearing.
To cover your goal you may try:
2016 May 25 9:34 AM
Hi, Clemens.
I've achieved a kind of clearing you told with BAPI_ACC_DOCUMENT_POST purely just for fun.
It was to create enough the document with mirror items to cleared. And use improved RW-handler, see post below.
2016 May 18 5:48 PM
Some corrections to the sample ...
1. Now ACCIT-REBZG_CHECK='A' used as a full-clearing indicator, instead of ACCIT-AUGBL='*'. AUGBL only used internally since RWIN-handler has finished.
2. Account types D, K, S are supported
3. Itemless clearing is supported
2016 May 31 5:29 PM
Hi Alexander.
I was trying to clear open items using bapi BAPI_ACC_DOCUMENT_POST ( and badi BADI_ACC_DOCUMENT enhancement ) but is not working.
In badi implementation i was passing:
REBZG -> invoice reference
REBZJ -> pos invoice
REBZZ -> I tried with A, Z ...
In this point, i should check tx OB74 ? I'm trying to posting a payment entry for an open invoice.
Now i´m thinking use FM CLEAR_DOCUMENTS.
Any suggest or hint ?
Thanks.
Regards,
Manuel H.
2016 Jun 01 9:04 AM
Hint is that REBZZ has to be filled with item position number, not a follow-on document type indicator as you do. And REBZJ to be filled with year, not a position number. Please look attentively the sample before usage. Also fill REBZG_CHECK with: 'A' if you want to perform a full clearing, or 'N' if you don't.
Unfortunately, data from OB74 is not allowed to consider yet. To improve this you might:
Correction 1. Replace:
IF t_accit-rebzg_check = 'A'.
<fs_ausz2>-augbl = '*'.
<fs_ausz2>-aktio = 'A'.
ENDIF.
...
with
IF t_accit-rebzg_check CO 'AX'.
<fs_ausz2>-augbl = '*'.
<fs_ausz2>-aktio = t_accit-rebzg_check.
ENDIF.
...
Correction 2. Replace:
MODIFY t_accit TRANSPORTING rebzg_check WHERE bukrs = <fs_ausz2>-bukrs AND rebzg_check = 'A'.
with
MODIFY t_accit TRANSPORTING rebzg_check WHERE bukrs = <fs_ausz2>-bukrs AND rebzg_check CO 'AX'.
Correction 3. Replace:
IF lines( t_ausz_clr[] ) = lines( t_accit[] ).
t_accit-bstat = 'A'.
MODIFY t_accit TRANSPORTING bstat WHERE bukrs = <fs_ausz2>-bukrs.
ENDIF.
with
IF lines( t_ausz_clr[] ) = lines( t_accit[] ) AND <fs_ausz2>-aktio = 'A'.
t_accit-bstat = 'A'.
MODIFY t_accit TRANSPORTING bstat WHERE bukrs = <fs_ausz2>-bukrs.
ELSE.
<fs_ausz2>-aktio = 'A'.
ENDIF.
Good luck.
2024 Nov 10 4:20 PM
Hi sir,
It need create posting vendor partial clearing document. Please tell me, I must config how to fill REBZG_CHECK and value for it?
With my knowlegde i config REBZG, REBZJ, REBZZ and AUGBL in extension 2(item) but i don't know config REBZG_CHECK how?
Please help me,
Thank you,