Wednesday, December 1, 2010

Parking a Document in FI using BAPI

In FI Module, Sometimes we need to park a document instead of Posting. Through BDC, direct input method we can do this. But in this post, I am explaining the Parking using BAPI.

There is no Direct BAPI for parking the FI Document. So using the Document posting BAPI, ‘BAPI_ACC_GL_POSTING_POST’ we can achieve this easily.

Header-username = sy-uname.
Header-comp code = '1000'.
Header-fisc_year = sy-datum+0(4).
Header-doc_date = sy-datum.
Header-pstng_date = sy-datum.
Header-fis_period = sy-datum+4(2).
Header-doc_type = 'SA'.

accountgl-itemno_acc = '1'.
accountgl-gl_account = '0000115510' .
accountgl-comp_code = '1000'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'SA'.
accountgl-fisc_year = sy-datum+0(4).
accountgl-fis_period = sy-datum+4(2).
APPEND accountgl.
CLEAR accountgl.

loc_cnt = 1.
loc_cnt = loc_cnt + 1.
accountgl-itemno_acc = loc_cnt.
accountgl-gl_account = '0000601900' .
accountgl-comp_code = '1000'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'SA'.
accountgl-fisc_year = sy-datum+0(4).
accountgl-fis_period = sy-datum+4(2).
accountgl-costcenter = ‘13100’.
APPEND accountgl.
CLEAR accountgl.

currencyamount-itemno_acc = ‘1’.
currencyamount-currency = 'USD'.
currencyamount-amt_doccur = loc_amt. ( For Debit / ‘S’)
APPEND currencyamount.

CLEAR currencyamount.

currencyamount-itemno_acc = ‘2’.
currencyamount-currency = 'USD'.
currencyamount-amt_doccur = ( -1 ) * ( loc_amt ). ( For credit /‘H’)
APPEND currencyamount.

CLEAR currencyamount.

extension1-field1 = 'BAPI-PARK'.
extension1-field2 = '1'.
APPEND extension1.

CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING
documentheader = header
IMPORTING
obj_key = obj_key
TABLES
accountgl = accountgl
currencyamount = currencyamount
return = return
extension1 = extension1

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.

Implement Customer Exit (CMOD) ACBAPI01, with Include Program ZXACCU15 of Component EXIT_SAPLACC4_001.

READ TABLE extension INDEX 1.

IF sy-subrc = 0 AND extension-field1 = 'BAPI-PARK'. ( to confirm for our parking, because it should not work for all the BAPI posting by the standards.)

MOVE 2 TO t_acchd-status_new. " Park Document

Endif.

To check the parked Document, go to table BKPF and we can check the Document status as ‘V’.

We can check the parked document in FBV0.

One more important thing after implementing all the above steps, if you are trying to post a parked document which is created by the above process, you may be getting some error. We have to follow steps of the OSS notes (Note 1020574) to avoid that error.

No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive

goodsites