In FI Module, I faced one customer requirement as to park FI Document with just vendor data, without
G/L line items using BAPI.
We have knowledge material available related to parking whole document using BAPI.
But, it is not enough to park just vendor line without G/L.
Also, we don’t have direct BAPI to park document.
We can achieve it as follows:
DATA : IT_HEADER TYPE STANDARD TABLE OF BAPIACHE09.
DATA : WA_HEADER TYPE BAPIACHE09.
DATA : IT_CURRENCYAMOUNT TYPE STANDARD TABLE OF BAPIACCR09.
DATA : WA_CURRENCYAMOUNT TYPE BAPIACCR09.
DATA : IT_ACCOUNTPAYABLE TYPE STANDARD TABLE OF BAPIACAP09.
DATA : WA_ACCOUNTPAYABLE TYPE BAPIACAP09.
DATA : IT_RETURN TYPE STANDARD TABLE OF BAPIRET2.
DATA : WA_RETURN TYPE BAPIRET2.
DATA : IT_EXTENSION2 TYPE STANDARD TABLE OF BAPIPAREX.
DATA : WA_EXTENSION2 TYPE BAPIPAREX.
CLEAR : WA_HEADER.
WA_HEADER–USERNAME = SY–UNAME.
WA_HEADER–COMP_CODE = ‘Z001’.
WA_HEADER–DOC_DATE = ‘20160720’. “SY-DATUM.
WA_HEADER–PSTNG_DATE = ‘20160720’.
WA_HEADER–DOC_TYPE = ‘KR’.
WA_ACCOUNTPAYABLE–ITEMNO_ACC = ‘1’.
WA_ACCOUNTPAYABLE–VENDOR_NO = ‘0000800005’.
WA_ACCOUNTPAYABLE–COMP_CODE = ‘Z001’.
APPEND WA_ACCOUNTPAYABLE TO IT_ACCOUNTPAYABLE.
WA_CURRENCYAMOUNT–ITEMNO_ACC = ‘1’.
WA_CURRENCYAMOUNT–CURRENCY = ‘INR’.
WA_CURRENCYAMOUNT–AMT_DOCCUR = 1000.
APPEND WA_CURRENCYAMOUNT TO IT_CURRENCYAMOUNT.
WA_EXTENSION2–VALUEPART1 = ‘PARK’.
APPEND WA_EXTENSION2 TO IT_EXTENSION2.
CLEAR : WA_EXTENSION2.
CALL FUNCTION ‘BAPI_ACC_DOCUMENT_POST’
DOCUMENTHEADER = WA_HEADER
ACCOUNTPAYABLE = IT_ACCOUNTPAYABLE
CURRENCYAMOUNT = IT_CURRENCYAMOUNT
EXTENSION2 = IT_EXTENSION2
RETURN = IT_RETURN.
READ TABLE IT_RETURN INTO WA_RETURN WITH KEY TYPE = ‘E’.
IF SY–SUBRC <> 0.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
WAIT = ‘X’.
Above program fills Document Header, Vendor Details and Currency details and extension.
NO G/L table is filled.
Step 2: Implement BADI to make use of extension data that we passed to BAPI and park document.
Go To SE19 and Create implementation for BAdI “ACC_DOCUMENT” as “ZACC_DOCUMENT” (Refer screenshot).
Maintain Filters in BAdI as given in screenshot:
BAdI that we implemented has two methods (Refer Screenshot):
Go in Method CHANGE:
This method has runtime structures that hold FI Document data as importing parameter.
Like C_ACCHD(Document Header), C_ACCIT(Document Line Item), C_EXTENSION2(Extension) etc.
C_EXTENSION2 holds same data that we passed to BAPI in Table IT_EXTENSION2.
This can be used to validate for our parking, because it should not work for all the BAPI postings.
Use following code in method CHANGE:
DATA : WA_EXT LIKE LINE OF C_EXTENSION2.
READ TABLE C_EXTENSION2 INTO WA_EXT INDEX 1.
IF WA_EXT–VALUEPART1 = ‘PARK’.
C_ACCHD–STATUS_NEW = 2. “ Status will be set as PARKED.
Parked document can be then posted using Tcode FBV0.