Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

How to post clearing with direct input

$
0
0

Goal

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.

 

Solution for AC_DOCUMENT_DIRECT_INPUT

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:

  • function ‘FI_DOCUMENT_PROJECT’: saves clearing info from input parameters for further posting
  • function ‘FI_DOCUMENT_POST’: sends clearing info last saved to the real update module ‘POST_DOCUMENT’

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:

  • make implicit enhancement directly at the beginning of ‘FI_DOCUMENT_PROJECT’
  • or register you own RWIN handler for DOCUMENT/CLOSE event: t-code SM30, view TRWPR; take the rule 'SUBNO > 900' into account

In any case you might write unified ABAP logic (see attached example for RWIN) according to the following restrictions:

  • one item in document you create may clear only one item in other document
  • each item in your document has non-zero amounts
  • full clearing is possible if you explicilty mark it, partial clearing is performed by default

Short description of ABAP logic attached:

  • Take BUKRS, REBZG, REBZJ, REBZZ from T_ACCITP that should be set there by caller program
  • Read amounts T_AUSZ_CLRP‑WRBTR, -DMBTR from BSEG (or some non‑cleared index table) found by the reference and add new records to T_AUSZ_CLR[] with corresponding BSEG values.
  • Calculate reminder T_AUSZ_CLRP‑DIFFW, ‑DIFHW as difference between clearing and cleared amounts
  • Mark T_AUSZ_CLRP for partial clearing: CLRIN = ‘2’. But if DIFFW and DIFHW are both zero you might mark T_AUSZ_CLRP for the full clearing: CLRIN = ‘ ’ depending of T_ACCITP-AUGBL value: = ‘*’ (full clearing) or = ‘ ’ (partial).
  • For the whole document create single row in T_AUSZ2: fill BUKRS = T_ACCITP‑BUKRS. And when full clearing has marked you might fill T_AUSZ2‑AUGBL = ‘*’ also.

Solution for BAPI_ACC_DOCUMENT_POST

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:

  • At BAPI call point write your clearing reference(s) in you custom structure, or you may find and use some standard one, and serialize it to EXTENSION2 parameter of type BAPIPAREX_TAB. Don’t forget that POSNR field has to be present in the structure along with REBZG, REBZJ and REBZZ fields.
  • Implement BADI ACC_DOCUMENT, or – for new ERP versions – the enhancement spot BADI_ACC_DOCUMENT and create BADI implementation inside it with filter AWTYP = BKPFF
    • Use ABAP logic from sample CL_EXM_IM_ACC_DOCUMENT->CHANGE() to move you reference into corresponding T_ACCITP-REBZG, -REBZJ and –REBZZ
    • Ensure that document you clear is compatible with FUNCTION ‘FI_DOCUMENT_CHECK’ standard checks. Elsewhere you might set T_ACCIT‑REBZG_CHECK = ‘N’ and skip invoice reference checks

Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>