‎2008 May 06 5:09 AM
All,
Can I use BAPI_ACC_DOCUMENT_POST for posting in FBS1 with reversal reason & reversal date? I can't find such option in the BAPI. If not, can you suggest other BAPI that I can use to perform posting with reversal reason & reversal date? Thanks in advance.
‎2008 May 06 5:39 AM
Hi Nivla,
You do one thing what ever the document you want to post for
FBS1. you try to post the same from standard process or you see the already posted document in the document list.
Find out the parameters what system is passing through standard process. and try the same with your code by passing those parameters in your BAPI_ACC_DOCU_POST.
You have to try.
Regards,
madan.
‎2008 May 06 6:29 AM
I can only find reversal reason in the header parameter of BAPI_ACC_DOCUMENT_POST, but not reversal date. Has anyone ever used BAPI_ACC_DOCUMENT_POST to post with reversal date? All I need to know is whether this can be done or not.
‎2008 May 06 7:05 AM
Anyone? Do I need to use the extention structure? Is yes, how can it be done? I came across articles saying that we can add our own posting key through the use of the extention structure. Can we do that to the reversal date as well? All helps are greatly appreciated.
‎2008 May 07 2:08 AM
I wonder is has there anyone came across the same scenario as mine? Please, I need the help urgently..
‎2008 May 07 2:16 AM
Check the below sample code.
Parameters p_belnr like bkpf-belnr default '0100000236'.
*Get last SA type document posted to build document key
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR = '01'
OBJECT = 'RF_BELEG'
QUANTITY = '1'
SUBOBJECT = '4000' "company code
TOYEAR = '2005'
IGNORE_BUFFER = '2005'
IMPORTING
NUMBER = docnum
QUANTITY =
RETURNCODE =
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
BUFFER_OVERFLOW = 7
OTHERS = 8
.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
"Begin to populate docnument header.
*obj_key contains new document no.
CONCATENATE docnum '4000' sy-datlo(4) INTO doc_header-obj_key.
doc_header-obj_type = 'BKPFF'.
*obj_key_r contains document no. needed to reverse
CONCATENATE p_belnr '4000' sy-datlo(4) INTO doc_header-obj_key_r.
doc_header-obj_sys = 'A1DMD011'.
*doc_header-OBJ_KEY_R = 'AWREF_REV'.
*doc_header-AC_DOC_NO = '8'.
*doc_header-header_txt = 'TEST BOC BAPI POSTING'.
doc_header-comp_code = '4000'.
doc_header-REASON_REV = '02'.
doc_header-pstng_date = '20050517'.
doc_header-FIS_PERIOD = '05'.
"All tables filled - now call BAPI.
CALL FUNCTION 'BAPI_ACC_GL_POSTING_REV_POST'
EXPORTING
REVERSAL = doc_header
IMPORTING
OBJ_TYPE = doc_header-obj_type
OBJ_KEY = doc_header-obj_key
OBJ_SYS = doc_header-obj_sys
TABLES
RETURN = return
.
LOOP AT return WHERE type = 'E'.
EXIT.
ENDLOOP.
IF sy-subrc EQ 0.
WRITE: / 'BAPI call failed - debug and fix!'.
LOOP AT return.
WRITE: / .
WRITE:
return-TYPE,
'|',
return-ID,
'|',
return-NUMBER,
'|',
return-MESSAGE.
ENDLOOP.
ELSE.
LOOP AT return.
WRITE: / .
WRITE:
return-TYPE,
'|',
return-ID,
'|',
return-NUMBER,
'|',
return-MESSAGE.
ENDLOOP.
CLEAR return.
REFRESH return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
return = return.
WRITE: / 'BAPI call worked!!'.
WRITE: / doc_header-obj_key, ' posted'.
Hope this works.
Reward points if it helped you.
Rgds,
Abhishek
‎2008 May 07 4:26 AM
But this BAPI 'BAPI_ACC_GL_POSTING_REV_POST' is used to perform the reversal, am I right? What I need is to POST an accounting document (together with reversal reason & reversal date; like how to do it in FBS1), not reversing an accounting document. You dun do reversal in FBS1, don't you? Correct me if I'm wrong.
‎2008 May 07 10:09 AM
‎2008 May 17 12:59 PM
Hi Mil,
I have the same requirement. Did you get any standard solution for this.
Cheers,
Bala
‎2016 Jul 22 12:57 PM
Dear All,
Very old threat but I dont like when there is no solution.
It's possible using the extension2 parameter.
there you can pass your date for reversal (stodt) and reason (stgrd).
As documented you have then to implement the BADI ACC_DOCUMENT.
It will look like something like this.
Bapi Call:
DATA:
lt_extension2 TYPE STANDARD TABLE OF bapiparex,
ls_extension2 TYPE bapiparex.
ls_extension2-structure = 'ACCIT'.
ls_extension2-valuepart1 = YOUR DATE
ls_extension2-valuepart2 = YOUR REASON
APPEND ls_extension2 TO lt_extension2.
then you bapi call passing the lt_extension2 as parameter
Badi:
METHOD if_ex_acc_document~change.
* Feldsymbole
FIELD-SYMBOLS <ls_accit> TYPE accit.
* Arbeitsbereiche
DATA: ls_extension TYPE bapiparex.
LOOP AT c_accit ASSIGNING <ls_accit>.
READ TABLE c_extension2 INTO ls_extension
WITH KEY structure = 'ACCIT'.
IF sy-subrc = 0.
<ls_accit>-stodt = ls_extension-valuepart1.
<ls_accit>-stgrd = ls_extension-valuepart2.
ENDIF.
ENDLOOP.
ENDMETHOD.
Hope this will help you.
Best regards
Yannick