Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Help for 'BAPI_ACC_DOCUMENT_REV_POST'' to reverse the accouting document

Former Member
0 Likes
1,888

Hi All,

I am trying to reverse the accounting document using BAPI "BAPI_ACC_DOCUMENT_REV_POST"

and finally using"BAPI_TRANSACTION_COMMIT " .

can any one provide me sample data to be passed to the two paramters:

REVERSAL

BUS_ACT

Please help me in reversing the accounting document number..

Any Suggestions of other BAPI to reverse the accounting document are also would be of great help to me..

Thanks in advance.

Prathima..

2 REPLIES 2
Read only

Former Member
0 Likes
871

ZBAPICONTAB

Ejemplo de contabilización con BAPIS

report zbapi_factura_acreedor2 .

*REPORT acc_bapi_test_document .

selection-screen begin of block bl01 .

parameters:

check_l radiobutton group rb1,

check_a default 'X' radiobutton group rb1,

post radiobutton group rb1.

selection-screen uline.

parameters:

rev_c radiobutton group rb1,

rev_p radiobutton group rb1.

selection-screen uline.

parameters:

ref_key like bapiache01-obj_key default 'TEST000001BAPICALL',

dest like bdi_logsys-logsys default ' '.

selection-screen end of block bl01 .

data:

gd_documentheader like bapiache09,

gd_customercpd like bapiacpa09,

gd_fica_hd like bapiaccahd,

it_accountreceivable like table of bapiacar09 with header line,

it_accountgl like table of bapiacgl09 with header line,

it_accounttax like table of bapiactx09 with header line,

it_criteria like table of bapiackec9 with header line,

it_valuefield like table of bapiackev9 with header line,

it_currencyamount like table of bapiaccr09 with header line,

it_return like table of bapiret2 with header line,

it_receivers like table of bdi_logsys with header line,

it_fica_it like table of bapiaccait with header line,

it_accountpayable like table of bapiacap09 with header line,

it_paymentcard like table of bapiacpc09 with header line,

it_ext like table of bapiacextc with header line.

  • it_re LIKE TABLE OF bapiacre09 WITH HEADER LINE,

  • it_ext2 LIKE TABLE OF bapiparex WITH HEADER LINE.

perform fill_internal_tables.

if check_l = 'X'.

call function 'BAPI_ACC_DOCUMENT_CHECK'

destination dest

exporting

documentheader = gd_documentheader

customercpd = gd_customercpd

contractheader = gd_fica_hd

tables

accountgl = it_accountgl

accountreceivable = it_accountreceivable

accountpayable = it_accountpayable

accounttax = it_accounttax

  • currencyamount = it_currencyamount

criteria = it_criteria

valuefield = it_valuefield

extension1 = it_ext

return = it_return

paymentcard = it_paymentcard

contractitem = it_fica_it.

  • extension2 = it_ext2

  • realestate = it_re.

.

write: / 'Result of check lines:'. "#EC NOTEXT

perform show_messages.

endif.

if check_a = 'X'.

call function 'BAPI_ACC_DOCUMENT_CHECK'

destination dest

exporting

documentheader = gd_documentheader

customercpd = gd_customercpd

contractheader = gd_fica_hd

tables

accountgl = it_accountgl

accountreceivable = it_accountreceivable

accountpayable = it_accountpayable

accounttax = it_accounttax

currencyamount = it_currencyamount

criteria = it_criteria

valuefield = it_valuefield

extension1 = it_ext

return = it_return

paymentcard = it_paymentcard

contractitem = it_fica_it.

  • extension2 = it_ext2

  • realestate = it_re.

write: / 'Result of check all:'. "#EC NOTEXT

perform show_messages.

endif.

if post = 'X'.

data: l_type like gd_documentheader-obj_type,

l_key like gd_documentheader-obj_key,

l_sys like gd_documentheader-obj_sys.

if dest = space or

dest = gd_documentheader-obj_sys.

  • post synchron

call function 'BAPI_ACC_DOCUMENT_POST'

exporting

documentheader = gd_documentheader

customercpd = gd_customercpd

contractheader = gd_fica_hd

importing

obj_type = l_type

obj_key = l_key

obj_sys = l_sys

tables

accountgl = it_accountgl

accountreceivable = it_accountreceivable

accountpayable = it_accountpayable

accounttax = it_accounttax

currencyamount = it_currencyamount

criteria = it_criteria

valuefield = it_valuefield

extension1 = it_ext

return = it_return

paymentcard = it_paymentcard

contractitem = it_fica_it.

  • extension2 = it_ext2

  • realestate = it_re.

write: / 'Result of post:'. "#EC NOTEXT

perform show_messages.

else.

  • create Idoc

it_receivers-logsys = dest.

append it_receivers.

call function 'ALE_ACC_DOCUMENT_POST'

exporting

documentheader = gd_documentheader

customercpd = gd_customercpd

contractheader = gd_fica_hd

tables

accountgl = it_accountgl

accountreceivable = it_accountreceivable

accountpayable = it_accountpayable

accounttax = it_accounttax

currencyamount = it_currencyamount

criteria = it_criteria

valuefield = it_valuefield

extension1 = it_ext

paymentcard = it_paymentcard

contractitem = it_fica_it

  • extension2 = it_ext2

  • realestate = it_re

receivers = it_receivers

  • COMMUNICATION_DOCUMENTS =

  • APPLICATION_OBJECTS =

exceptions

error_creating_idocs = 1

others = 2 .

if sy-subrc = 0.

write: / 'IDoc created'. "#EC NOTEXT

else.

write: sy-msgid.

endif.

endif.

endif.

if rev_p = 'X' or rev_c = 'X'.

data: rev like bapiacrev,

rev_key like ref_key.

rev_key = ref_key.

rev_key(1) = 'R'.

rev-obj_type = gd_documentheader-obj_type.

rev-obj_key = rev_key.

rev-obj_sys = gd_documentheader-obj_sys.

rev-obj_key_r = ref_key.

if rev_c is initial.

if dest = space or

dest = gd_documentheader-obj_sys.

call function 'BAPI_ACC_DOCUMENT_REV_POST'

exporting

reversal = rev

bus_act = gd_documentheader-bus_act

tables

return = it_return.

else.

it_receivers-logsys = dest.

append it_receivers.

call function 'ALE_ACC_DOCUMENT_REV_POST'

exporting

reversal = rev

busact = gd_documentheader-bus_act

  • OBJ_TYPE = 'BUS6035'

  • SERIAL_ID = '0'

tables

receivers = it_receivers

  • COMMUNICATION_DOCUMENTS =

  • APPLICATION_OBJECTS =

exceptions

error_creating_idocs = 1

others = 2

.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

write: / 'IDoc created'. "#EC NOTEXT

endif.

endif.

else.

call function 'BAPI_ACC_DOCUMENT_REV_CHECK'

exporting

reversal = rev

bus_act = gd_documentheader-bus_act

tables

return = it_return.

endif.

write: / 'Result of Reversal Posting:'. "#EC NOTEXT

perform show_messages.

endif.

commit work.

Try this code

give points if helpful