Skip to Content

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 = SYUNAME.
WA_HEADER
COMP_CODE = ‘Z001’.
WA_HEADER
DOC_DATE = ‘20160720’. “SY-DATUM.
WA_HEADER
PSTNG_DATE = ‘20160720’.
WA_HEADER
DOC_TYPE = ‘KR’.

WA_ACCOUNTPAYABLEITEMNO_ACC = ‘1’.
WA_ACCOUNTPAYABLE
VENDOR_NO = ‘0000800005’.
WA_ACCOUNTPAYABLE
COMP_CODE = ‘Z001’.
APPEND WA_ACCOUNTPAYABLE TO IT_ACCOUNTPAYABLE.
CLEAR WA_ACCOUNTPAYABLE.

WA_CURRENCYAMOUNTITEMNO_ACC = ‘1’.
WA_CURRENCYAMOUNT
CURRENCY  = ‘INR’.
WA_CURRENCYAMOUNT
AMT_DOCCUR = 1000.
APPEND WA_CURRENCYAMOUNT TO IT_CURRENCYAMOUNT.
CLEAR WA_CURRENCYAMOUNT.

WA_EXTENSION2VALUEPART1 = ‘PARK’.
APPEND WA_EXTENSION2 TO IT_EXTENSION2.
CLEAR : WA_EXTENSION2.

CALL FUNCTION ‘BAPI_ACC_DOCUMENT_POST’
EXPORTING
DOCUMENTHEADER
= WA_HEADER
TABLES
ACCOUNTPAYABLE
= IT_ACCOUNTPAYABLE
CURRENCYAMOUNT
= IT_CURRENCYAMOUNT
EXTENSION2    
= IT_EXTENSION2
RETURN         = IT_RETURN.

READ TABLE IT_RETURN INTO WA_RETURN WITH KEY TYPE = ‘E’.
IF SYSUBRC <> 0.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
WAIT = ‘X’.
ENDIF.


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).

BAdI.jpg

Maintain Filters in BAdI as given in screenshot:

BAdI2.jpg

BAdI that we implemented has two methods (Refer Screenshot):

BadI3.jpg

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:

 

  METHOD IF_EX_ACC_DOCUMENT~CHANGE.

DATA : WA_EXT LIKE LINE OF C_EXTENSION2.

READ TABLE C_EXTENSION2 INTO WA_EXT INDEX 1.

IF WA_EXTVALUEPART1 = ‘PARK’.

C_ACCHDSTATUS_NEW = 2. “ Status will be set as PARKED.

ENDIF.

ENDMETHOD.                    “IF_EX_ACC_DOCUMENT~CHANGE

Parked document can be then posted using Tcode FBV0.

FBV0.jpg

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply