‎2009 Aug 24 6:58 PM
Hi,
I have an ALV grid which contains some amount that I have to post. When I post a first time with function BAPI_ACC_GL_POSTING_POST, the posting and the reversal do correctly. After that I do a refresh of the ALV. But when I try a second time to post another document, I receive the internal message "Document XXXXXX already exist". I think my problem comes from the OBJ_KEY because It takes the old reference.
My posting is in a loop and I think maybe that I would have to increment my OBJ_KEY. Is it possible to do that?
Anybody would have an idea?
Regards,
Mohamed.
Edited by: rahhaoui mohamed on Aug 24, 2009 7:59 PM
‎2009 Aug 24 7:05 PM
try clearing the Object key and re assign in the loop. Or if the doc already exists you might have to use a doc change bapi
You should not increment just like that... there would be a number range assigned to Object key.. which will give you the next number to use.
‎2009 Aug 24 7:08 PM
Thks for your quick answer but how to clearing the OBJect key and re assign it. What BAPI are you talking?
DO you have an example maybe?
Thank you .
‎2009 Aug 24 7:35 PM
I receive the internal message "Document XXXXXX already exist". I think my problem comes from the OBJ_KEY because It takes the old reference.
already exists means the document already posted so with that OBject key you cannot force the system to create again....
loop at itab...
call bapi and send obj_key..
clear obj_key.
endloop.
‎2009 Aug 24 7:38 PM
Hi,
Thats an exporting parameter for the BAPI that you are using i think you should clear that variable before you call the BAPI second time in the loop.
Regards,
Himanshu
‎2009 Aug 25 9:26 AM
Hi Thanks a lot for your response but I always meet the same problem. I refresh the tables and I do before a commit.
LOOP AT l_seltab INTO wa_seltab.
* Call BAPI to post the document
CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING
documentheader = i_docheader
IMPORTING
obj_type = i_docheader-obj_type
obj_key = i_docheader-obj_key
obj_sys = i_docheader-obj_sys
TABLES
accountgl = i_accountgl
currencyamount = i_curramunt
return = i_return
* EXTENSION1 = .
CLEAR i_return.
REFRESH i_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = i_return.
commit WORK AND WAIT.
CLEAR i_return.
REFRESH i_return.
i_reversal-obj_type = 'BKPFF'.
i_reversal-obj_key = i_docheader-obj_key.
i_reversal-obj_key_r = i_docheader-obj_key.
i_reversal-reason_rev = '06'.
i_reversal-pstng_date = p_budt3.
i_reversal-fis_period = p_budt3+4(2).
i_reversal-comp_code = s_bukrs-low.
APPEND i_reversal.
* Reversal posting
CALL FUNCTION 'BAPI_ACC_GL_POSTING_REV_POST'
EXPORTING
reversal = i_reversal
IMPORTING
obj_type = i_reversal-obj_type
obj_key = i_reversal-obj_key
obj_sys = i_reversal-obj_sys
TABLES
return = i_return.
CLEAR i_return.
REFRESH i_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = i_return.
commit WORK AND WAIT.
refresh: i_docheader, i_accountgl, i_curramunt, i_reversal.
ENDLOOP.I don't see where is the problem.
Regards,
Mohamed.
‎2009 Aug 25 9:35 AM
Hi,
* Reversal posting
CALL FUNCTION 'BAPI_ACC_GL_POSTING_REV_POST'
EXPORTING
reversal = i_reversal
IMPORTING
obj_type = i_reversal-obj_type <<<< This is an importinging parameter
obj_key = i_reversal-obj_key <<<< This is an importinging parameter
obj_sys = i_reversal-obj_sys <<<< This is an importinging parameter
TABLES
return = i_return.
CLEAR i_return.
REFRESH i_return.
do not use the same values as returnurned above you can declare new variables like obj_type,obj_key and obj_sys here and then every time you call the FM for postings clear these variables these variables would ahve values returned by the FM and we dont need to pass any values to them we can also comment the importing lines and that should work.
Regards,
HImanshu
‎2009 Aug 25 4:00 PM
Hi HImanshu,
I did what you told me but always the same issue:
* Reversal posting
CALL FUNCTION 'BAPI_ACC_GL_POSTING_REV_POST'
EXPORTING
reversal = i_reversal
IMPORTING
obj_type = lw_obj_type
obj_key = lw_obj_key
obj_sys = lw_obj_sys
TABLES
return = i_return.
IF i_return-type = 'E'. "If error Document not posted
EXIT.
ENDIF.
CLEAR i_return.
REFRESH i_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = i_return.
IF i_return-type = 'E'. "If error Document not posted
MESSAGE s040(zst1).
EXIT.
ENDIF.
COMMIT WORK AND WAIT.
CLEAR: lw_obj_key, lw_obj_type, lw_obj_sys.
REFRESH: i_docheader, i_accountgl, i_curramunt, i_reversal.
ENDLOOP.
‎2009 Aug 25 5:05 PM
What should I have to pass in i_reversal-obj_key and i_reversal-obj_key_r fields?
Thank you.
‎2009 Aug 26 10:29 AM