03-27-2006 2:19 PM
Hi ,
I want to post an amount thru a Fm bapi_acc_document_post to a g/l account .
It's getting posted while using account payable but first line is credit i.e; posting key 31 instead of debit i.e; posting key 40 and second line is debit instead of credit ( posting key 40 instead of 50 ) . Using account receivable returns an error 'F5 702 balance in transaction currency' .
Secondly when testing the FM thru se37 , using account receivable it says 'g/l accountno is not a reconcilliation account' .
Any help !!! I would like to thank you all in advance ,whoever takes the pain to solve this .
Sun
03-28-2006 9:25 AM
hi max ,
Thank you for reply . But total of items is zero .
I want to post it with posting key 40 in first line & 50 in second line . Instead this is 31 in first line and 40 in second line . It's getting posted using account payable with posting key 31 & 40 . I think posting key problem will be solved by using account receivable but then error F5 702 is coming .I am supplying vendor and customer parameters. Using the same account no. with tcode fb65 I can post the amount .
I can post the amount using FM bapi_acc_gl_posting_post
with proper posting keys but in first line also I am getting g/l account no instead of customer no related with the particular vendor into place of account in transaction code fb03 .
my code:
WA_DOCUMENTHEADER-HEADER_TXT = 'Vendor- Credit Note'(001).
WA_DOCUMENTHEADER-BUS_ACT = 'RFBU' .
WA_DOCUMENTHEADER-USERNAME = SY-UNAME.
WA_DOCUMENTHEADER-COMP_CODE = COMPCODE.
WA_DOCUMENTHEADER-DOC_DATE = SY-DATUM.
WA_DOCUMENTHEADER-PSTNG_DATE = SY-DATUM.
WA_DOCUMENTHEADER-DOC_TYPE = 'SA'.
*-- Set Account Payable details
REFRESH I_ACCOUNTPAYABLE.
CLEAR I_ACCOUNTPAYABLE.
I_ACCOUNTPAYABLE-ITEMNO_ACC = 1.
I_ACCOUNTPAYABLE-VENDOR_NO = P_VENDOR.
I_ACCOUNTPAYABLE-COMP_CODE = COMPCODE.
I_ACCOUNTPAYABLE-BUSINESSPLACE = '0607' .
I_ACCOUNTPAYABLE-SECTIONCODE = '0101' .
I_ACCOUNTPAYABLE-BLINE_DATE = SY-DATUM.
I_ACCOUNTPAYABLE-ITEM_TEXT = LFA1-NAME1. "#EC NOTEXT
APPEND I_ACCOUNTPAYABLE.
REFRESH I_ACCOUNTGL.
CLEAR I_ACCOUNTGL.
I_ACCOUNTGL-ITEMNO_ACC = 2.
I_ACCOUNTGL-GL_ACCOUNT = '51000081' .
i_accountgl-item_text = lfa1-name1.
I_ACCOUNTGL-PROFIT_CTR = P_PROFITCTR .
i_accountgl-pstng_date = sy-datum.
I_ACCOUNTGL-plant = P_site .
APPEND I_ACCOUNTGL.
*-- Account receivable
I_ACCOUNTRECEIVABLE-ITEMNO_ACC = 1 .
I_ACCOUNTRECEIVABLE-CUSTOMER = P_CUSTOMER.
I_ACCOUNTRECEIVABLE-BUSINESSPLACE = '0607' .
I_ACCOUNTRECEIVABLE-gl_account = P_GL_VALUE .
I_ACCOUNTRECEIVABLE-comp_code = COMPCODE .
*-- Set currency details
V_AC_PAY = V_GL_AMT * -1 .
REFRESH I_CURRENCYAMOUNT.
CLEAR I_CURRENCYAMOUNT.
I_CURRENCYAMOUNT-ITEMNO_ACC = 1.
I_CURRENCYAMOUNT-CURRENCY = 'INR'.
I_CURRENCYAMOUNT-AMT_DOCCUR = V_AC_PAY.
APPEND I_CURRENCYAMOUNT.
CLEAR I_CURRENCYAMOUNT.
I_CURRENCYAMOUNT-ITEMNO_ACC = 2.
I_CURRENCYAMOUNT-CURRENCY = 'INR'.
I_CURRENCYAMOUNT-AMT_DOCCUR = V_GL_AMT.
APPEND I_CURRENCYAMOUNT.
REFRESH: RETURN .
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = WA_DOCUMENTHEADER
IMPORTING
OBJ_TYPE = WA_DOCUMENTHEADER-OBJ_TYPE
OBJ_KEY = WA_DOCUMENTHEADER-OBJ_KEY
OBJ_SYS = WA_DOCUMENTHEADER-OBJ_SYS
TABLES
ACCOUNTGL = I_ACCOUNTGL
accountreceivable = i_accountreceivable
ACCOUNTPAYABLE = I_ACCOUNTPAYABLE
CURRENCYAMOUNT = I_CURRENCYAMOUNT
RETURN = RETURN
.
Can u please help me ?
regards ,
03-27-2006 2:29 PM
Hi
I think the total of all items is not zero.
When you move an item, you have to indicate the sign too, because the BAPIs doesn't allow to indicate the posting key.
Max
03-28-2006 9:31 AM
Hi Max and Sun,
I am looking for the same code and as well my post was open on the same issue.
Could you provide me some some code regarding the INPUT parameters of this FM in-order to post the accounting doc's for GL accnt.
deepak333@yahoo.com
Thanks.
Message was edited by: KDeepak
03-28-2006 10:19 AM
Hi ,
I am supplying the code for you . this is working with account payable but not with account receivable .but my problem is about opposite posting key . Please see if any thing you can suggest me .
DATA : WA_DOCUMENTHEADER LIKE BAPIACHE09,
WA_DOCUMENTHEADER LIKE BAPIACHE08,
WA_CUSTOMERCPD LIKE BAPIACPA09,
WA_FICA_HD LIKE BAPIACCAHD, I_ACCOUNTRECEIVABLE LIKE TABLE OF BAPIACAR09 WITH HEADER LINE,
I_ACCOUNTGL LIKE TABLE OF BAPIACGL09 WITH HEADER LINE,
I_ACCOUNTTAX LIKE TABLE OF BAPIACTX09 WITH HEADER LINE,
I_CRITERIA LIKE TABLE OF BAPIACKECR WITH HEADER LINE,
I_VALUEFIELD LIKE TABLE OF BAPIACKEVA WITH HEADER LINE,
I_CURRENCYAMOUNT LIKE TABLE OF BAPIACCR09 WITH HEADER LINE,
I_FICA_IT LIKE TABLE OF BAPIACCAIT WITH HEADER LINE,
I_ACCOUNTPAYABLE LIKE TABLE OF BAPIACAP09 WITH HEADER LINE,
I_PAYMENTCARD LIKE TABLE OF BAPIACPC09 WITH HEADER LINE,
I_EXT LIKE TABLE OF BAPIEXTC WITH HEADER LINE,
I_RE LIKE TABLE OF BAPIACRE09 WITH HEADER LINE,
I_EXT2 LIKE TABLE OF BAPIPAREX WITH HEADER LINE.
WA_DOCUMENTHEADER-OBJ_TYPE = 'BKPFF'.
WA_DOCUMENTHEADER-OBJ_KEY = '$' .
CONCATENATE SY-SYSID 'CLNT' SY-MANDT INTO WA_DOCUMENTHEADER-OBJ_SYS.
WA_DOCUMENTHEADER-HEADER_TXT = 'Vendor- fixedfee Credit Note'(001).
WA_DOCUMENTHEADER-BUS_ACT = 'RFBU' .
WA_DOCUMENTHEADER-USERNAME = SY-UNAME.
WA_DOCUMENTHEADER-COMP_CODE = COMPanyCODE.
WA_DOCUMENTHEADER-DOC_DATE = SY-DATUM.
WA_DOCUMENTHEADER-PSTNG_DATE = SY-DATUM.
WA_DOCUMENTHEADER-DOC_TYPE = 'SA'.
REFRESH I_ACCOUNTPAYABLE.
CLEAR I_ACCOUNTPAYABLE.
I_ACCOUNTPAYABLE-ITEMNO_ACC = 1.
I_ACCOUNTPAYABLE-VENDOR_NO = P_VENDOR.
I_ACCOUNTPAYABLE-COMP_CODE = COMPCODE.
I_ACCOUNTPAYABLE-BUSINESSPLACE = '0607' .
I_ACCOUNTPAYABLE-SECTIONCODE = '0101' .
I_ACCOUNTPAYABLE-BLINE_DATE = SY-DATUM.
I_ACCOUNTPAYABLE-ITEM_TEXT = LFA1-name1
APPEND I_ACCOUNTPAYABLE.
*-- Set GL Details
REFRESH I_ACCOUNTGL.
CLEAR I_ACCOUNTGL.
I_ACCOUNTGL-ITEMNO_ACC = 2.
I_ACCOUNTGL-GL_ACCOUNT = your g/l a/c here .
I_ACCOUNTGL-PROFIT_CTR = P_PROFITCTR .
i_accountgl-pstng_date = sy-datum.
APPEND I_ACCOUNTGL.
*-- Account receivable
I_ACCOUNTRECEIVABLE-ITEMNO_ACC = 1 .
I_ACCOUNTRECEIVABLE-CUSTOMER = P_CUSTOMER.
I_ACCOUNTRECEIVABLE-BUSINESSPLACE = '0607' .
I_ACCOUNTRECEIVABLE-gl_account = your g/l a/c here .
I_ACCOUNTRECEIVABLE-comp_code = COMPanyCODE .
" suppose v_ac_pay = 100 inr .
*-- Set currency details
V_AC_PAY = V_GL_AMT * -1 .
REFRESH I_CURRENCYAMOUNT.
CLEAR I_CURRENCYAMOUNT.
I_CURRENCYAMOUNT-ITEMNO_ACC = 1.
I_CURRENCYAMOUNT-CURRENCY = 'INR'.
I_CURRENCYAMOUNT-AMT_DOCCUR = V_AC_PAY.
APPEND I_CURRENCYAMOUNT.
CLEAR I_CURRENCYAMOUNT.
I_CURRENCYAMOUNT-ITEMNO_ACC = 2.
I_CURRENCYAMOUNT-CURRENCY = 'INR'.
I_CURRENCYAMOUNT-AMT_DOCCUR = V_GL_AMT.
APPEND I_CURRENCYAMOUNT.
here balance is zero as suggested by max .
REFRESH: RETURN .
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = WA_DOCUMENTHEADER
IMPORTING
OBJ_TYPE = WA_DOCUMENTHEADER-OBJ_TYPE
OBJ_KEY = WA_DOCUMENTHEADER-OBJ_KEY
OBJ_SYS = WA_DOCUMENTHEADER-OBJ_SYS
TABLES
ACCOUNTGL = I_ACCOUNTGL
accountreceivable = i_accountreceivable
ACCOUNTPAYABLE = I_ACCOUNTPAYABLE
CURRENCYAMOUNT = I_CURRENCYAMOUNT
RETURN = RETURN
.
if sy-subrc <> 0 .
message E999(RE) WITH 'Error .
rollback work .
else.
l_BELNR = return-MESSAGE_V2+0(10) .
commit work .
endif .
loop at return .
endloop.
regards and thanks to all in advance .
03-28-2006 9:25 AM
hi max ,
Thank you for reply . But total of items is zero .
I want to post it with posting key 40 in first line & 50 in second line . Instead this is 31 in first line and 40 in second line . It's getting posted using account payable with posting key 31 & 40 . I think posting key problem will be solved by using account receivable but then error F5 702 is coming .I am supplying vendor and customer parameters. Using the same account no. with tcode fb65 I can post the amount .
I can post the amount using FM bapi_acc_gl_posting_post
with proper posting keys but in first line also I am getting g/l account no instead of customer no related with the particular vendor into place of account in transaction code fb03 .
my code:
WA_DOCUMENTHEADER-HEADER_TXT = 'Vendor- Credit Note'(001).
WA_DOCUMENTHEADER-BUS_ACT = 'RFBU' .
WA_DOCUMENTHEADER-USERNAME = SY-UNAME.
WA_DOCUMENTHEADER-COMP_CODE = COMPCODE.
WA_DOCUMENTHEADER-DOC_DATE = SY-DATUM.
WA_DOCUMENTHEADER-PSTNG_DATE = SY-DATUM.
WA_DOCUMENTHEADER-DOC_TYPE = 'SA'.
*-- Set Account Payable details
REFRESH I_ACCOUNTPAYABLE.
CLEAR I_ACCOUNTPAYABLE.
I_ACCOUNTPAYABLE-ITEMNO_ACC = 1.
I_ACCOUNTPAYABLE-VENDOR_NO = P_VENDOR.
I_ACCOUNTPAYABLE-COMP_CODE = COMPCODE.
I_ACCOUNTPAYABLE-BUSINESSPLACE = '0607' .
I_ACCOUNTPAYABLE-SECTIONCODE = '0101' .
I_ACCOUNTPAYABLE-BLINE_DATE = SY-DATUM.
I_ACCOUNTPAYABLE-ITEM_TEXT = LFA1-NAME1. "#EC NOTEXT
APPEND I_ACCOUNTPAYABLE.
REFRESH I_ACCOUNTGL.
CLEAR I_ACCOUNTGL.
I_ACCOUNTGL-ITEMNO_ACC = 2.
I_ACCOUNTGL-GL_ACCOUNT = '51000081' .
i_accountgl-item_text = lfa1-name1.
I_ACCOUNTGL-PROFIT_CTR = P_PROFITCTR .
i_accountgl-pstng_date = sy-datum.
I_ACCOUNTGL-plant = P_site .
APPEND I_ACCOUNTGL.
*-- Account receivable
I_ACCOUNTRECEIVABLE-ITEMNO_ACC = 1 .
I_ACCOUNTRECEIVABLE-CUSTOMER = P_CUSTOMER.
I_ACCOUNTRECEIVABLE-BUSINESSPLACE = '0607' .
I_ACCOUNTRECEIVABLE-gl_account = P_GL_VALUE .
I_ACCOUNTRECEIVABLE-comp_code = COMPCODE .
*-- Set currency details
V_AC_PAY = V_GL_AMT * -1 .
REFRESH I_CURRENCYAMOUNT.
CLEAR I_CURRENCYAMOUNT.
I_CURRENCYAMOUNT-ITEMNO_ACC = 1.
I_CURRENCYAMOUNT-CURRENCY = 'INR'.
I_CURRENCYAMOUNT-AMT_DOCCUR = V_AC_PAY.
APPEND I_CURRENCYAMOUNT.
CLEAR I_CURRENCYAMOUNT.
I_CURRENCYAMOUNT-ITEMNO_ACC = 2.
I_CURRENCYAMOUNT-CURRENCY = 'INR'.
I_CURRENCYAMOUNT-AMT_DOCCUR = V_GL_AMT.
APPEND I_CURRENCYAMOUNT.
REFRESH: RETURN .
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = WA_DOCUMENTHEADER
IMPORTING
OBJ_TYPE = WA_DOCUMENTHEADER-OBJ_TYPE
OBJ_KEY = WA_DOCUMENTHEADER-OBJ_KEY
OBJ_SYS = WA_DOCUMENTHEADER-OBJ_SYS
TABLES
ACCOUNTGL = I_ACCOUNTGL
accountreceivable = i_accountreceivable
ACCOUNTPAYABLE = I_ACCOUNTPAYABLE
CURRENCYAMOUNT = I_CURRENCYAMOUNT
RETURN = RETURN
.
Can u please help me ?
regards ,
03-28-2006 10:56 AM
Hi
I can't understand your posting: you can use posting key 40 and 50 for only G/L account not payable and recivable.
So I think the behavior of BAPI is correct.
Why do you want to post a payable item using the key 40 or 50?
If your document has to have only G/L account items, you can do it (and you did it by BAPI bapi_acc_gl_posting_post).
The BAPI get the posting key in the form fill_acct_key, this is the code:
data: ld_bschh like accit-bschl,
ld_bschs like accit-bschl,
ld_umskz like accit-umskz.
if not gs_accit-ktosl is initial and
gs_accit-kstat is initial.
call function 'FI_GET_POSTING_KEY'
exporting
i_ktosl = gs_accit-ktosl
importing
e_bschs = ld_bschs
e_bschh = ld_bschh
e_umskz = ld_umskz
exceptions
error_message = 1.
if sy-subrc is initial.
if gs_accit-shkzg = 'S'.
gs_accit-bschl = ld_bschs.
else.
gs_accit-bschl = ld_bschh.
endif.
SHB-Vorgänge HR-Travel mit Ktosl 'HRV'
IF NOT ld_umskz IS INITIAL.
gs_accit-umskz = ld_umskz.
keine Ableitung Zahlungsbedingung für SHB-Vorgänge
CLEAR gs_accit-zterm.
ENDIF.
else.
perform error_from_system
using gs_bapi_accit-parameter
gs_bapi_accit-tabix
'ACCT_KEY'.
endif.
endif.
if gs_accit-bschl is initial.
case gs_accit-koart.
when 'D' or 'V'.
if gs_accit-shkzg = 'S'.
gs_accit-bschl = '01'.
else.
gs_accit-bschl = '11'.
endif.
when 'K'.
if gs_accit-shkzg = 'S'.
gs_accit-bschl = '21'.
else.
gs_accit-bschl = '31'.
endif.
when 'S'.
if gs_accit-shkzg = 'S'.
gs_accit-bschl = '40'.
else.
gs_accit-bschl = '50'.
endif.
when 'A'.
if gs_accit-shkzg = 'S'.
gs_accit-bschl = '70'.
else.
gs_accit-bschl = '75'.
endif.
when 'M'.
if gs_accit-shkzg = 'S'.
gs_accit-bschl = '40'.
else.
gs_accit-bschl = '50'.
endif.
endcase.
endif.
if not gs_accit-umskz is initial.
if gs_accit-bschl+1 = '1'.
gs_accit-bschl+1 = '9'.
endif.
endif.
So as you can see, if the item is for vendore (KOART = K), BAPI use the key 31 and 21:
when 'K'.
if gs_accit-shkzg = 'S'.
gs_accit-bschl = '21'.
else.
gs_accit-bschl = '31'.
endif.
Max
03-28-2006 1:03 PM
Hi ,
Thank you . I think you are right . I should not worry about posting key or account payable or receivable .
Actually I think now I can say my problem in a more clear way .
The problem is in fb03 when you diaplay the posted document ,
1 . In first line there is a field called account bseg_alv-ktonr . there i want to display customer no and
in second line I want to display g/l account no with negative amount in amount field .
I think it has to do some thing with account types and special gl indicator used for reconcilliation account .
But I don't know how to do it ?
Any help ????
By the use of bapi_acc_gl_posting_post I am getting right postings but I am not getting customer no in the place of amount in first line .
In fb03
fields displayed are
company code section businessplace site profircenter
costcenter item posting key special gl indicator account
description amount currency tax .
Thanks in advance ,
Regards ,
Sun
03-28-2006 2:15 PM
Hi Sun
I've copied and modifed your code in order to run it in my system:
DATA: wa_documentheader TYPE bapiache09,
i_accountgl TYPE STANDARD TABLE OF bapiacgl09
WITH HEADER LINE,
i_accountreceivable TYPE STANDARD TABLE OF bapiacar09
WITH HEADER LINE,
i_currencyamount TYPE STANDARD TABLE OF bapiaccr09
WITH HEADER LINE,
return TYPE STANDARD TABLE OF bapiret2
WITH HEADER LINE.
wa_documentheader-header_txt = 'Vendor- Credit Note'(001).
wa_documentheader-bus_act = 'RFBU' .
wa_documentheader-username = sy-uname.
wa_documentheader-comp_code = 'ZN01'.
wa_documentheader-doc_date = '20051231'.
wa_documentheader-pstng_date = '20051231'.
wa_documentheader-doc_type = 'DI'.
REFRESH i_accountgl.
CLEAR i_accountgl.
i_accountgl-itemno_acc = 2.
i_accountgl-gl_account = '0011999999' .
i_accountgl-item_text = 'Test'.
APPEND i_accountgl.
*-- Account receivable
i_accountreceivable-itemno_acc = 1 .
i_accountreceivable-customer = '0000000050'.
APPEND i_accountreceivable.
REFRESH i_currencyamount.
CLEAR i_currencyamount.
i_currencyamount-itemno_acc = 1.
i_currencyamount-currency = 'EUR'.
i_currencyamount-amt_doccur = 100.
APPEND i_currencyamount.
CLEAR i_currencyamount.
i_currencyamount-itemno_acc = 2.
i_currencyamount-currency = 'EUR'.
i_currencyamount-amt_doccur = - 100.
APPEND i_currencyamount.
REFRESH: return .
CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
EXPORTING
documentheader = wa_documentheader
CUSTOMERCPD =
CONTRACTHEADER =
TABLES
accountgl = i_accountgl
accountreceivable = i_accountreceivable
currencyamount = i_currencyamount
return = return.
READ TABLE return WITH KEY type = 'E' TRANSPORTING NO FIELDS.
CHECK sy-subrc <> 0.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = wa_documentheader
IMPORTING
obj_type = wa_documentheader-obj_type
obj_key = wa_documentheader-obj_key
obj_sys = wa_documentheader-obj_sys
TABLES
accountgl = i_accountgl
accountreceivable = i_accountreceivable
currencyamount = i_currencyamount
return = return.
COMMIT WORK AND WAIT.
This code works fine, it create a document where the first item is customer item and second item is G/L account.
In your code you have missed the APPEND statament for i_accountreceivable table.
Max
03-28-2006 2:20 PM
Hi,
i don't get your problem with ta FB03 !
-> pls describe exactly and complete!
or is your problem the configuration of the posted document?
-> than use TA FB00 / or FAKP
Andreas
03-29-2006 6:42 AM
Hi max ,
Thanks !!!
I consider it as a great help , because you took pains to solve my virtual problem . Thanks to anderson also for noticing it .
Thanks to SDN .
Sun
11-03-2015 5:13 AM
Dear Sir,
I have developed a BAPI (BAPI_ACC_DOCUMENT_POST) to post entry in FB65
it is working fine but the problem is when i am trying to reverse the same through FB08
it is going in dump below is the code, please help me where i am going wrong.
read table it_final into wa_final index 1."""""""""""''header details
clear: wa_header.
** wa_header-obj_type = 'BKPFF'.
** wa_header-obj_key = '$'.
** CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
** IMPORTING
** own_logical_system = wa_header-obj_sys
** EXCEPTIONS
** own_logical_system_not_defined = 1
** OTHERS = 2.
** wa_header-bus_act = 'RMRP'.
wa_header-bus_act = 'RFBU'.
wa_header-comp_code = wa_final-bukrs.
wa_header-username = sy-uname.
wa_header-header_txt = 'Debit Note Auto Post'.
wa_header-doc_date = wa_final-zdate."wa_final-bldat.
wa_header-pstng_date = wa_final-zdate."wa_final-budat.
wa_header-ref_doc_no = wa_final-dnumber.
wa_header-doc_type = 'KG'.
describe table it_final lines cnt.
do cnt times.
n = n + 1.
rlv_counter = rlv_counter + 1.
read table it_final into wa_final1 index n."rlv_counter.
wa_payable-itemno_acc = '0000000001'."rlv_counter."
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = wa_final1-lifnr
importing
output = wa_final1-lifnr.
wa_payable-vendor_no = wa_final1-lifnr.
wa_payable-businessplace = '1000'.
wa_payable-sectioncode = '1000'.
wa_payable-bus_area = wa_final1-gsber."02.11
wa_payable-pymt_cur = 'INR'.
append wa_payable to it_payable.
clear wa_payable.
wa_gl-itemno_acc = rlv_counter."'0000000002'.
wa_gl-gl_account = wa_final1-kstar.
wa_gl-bus_area = wa_final1-gsber.
wa_gl-profit_ctr = wa_final1-gsber.
wa_gl-plant = wa_final1-werks.
wa_gl-orderid = wa_final1-aufnr.
wa_gl-quantity = wa_final1-mbgbtr.
wa_gl-material = wa_final1-matnr.
wa_gl-base_uom = wa_final1-meinb.
concatenate wa_final1-refbn 'Debit' into wa_gl-item_text separated by '-'.
append wa_gl to it_gl.
clear: wa_gl.
lv_amount = wa_final1-famount * -1.
wa_amount-itemno_acc = '0000000001'."rlv_counter."
wa_amount-amt_doccur = wa_final1-famount.
wa_amount-currency = 'INR'.
wa_amount-curr_type = '10'.
wa_amount-disc_base = wa_final1-famount.
append wa_amount to it_amount.
clear:wa_amount.
wa_amount-itemno_acc = rlv_counter."'0000000002'.
wa_amount-amt_doccur = lv_amount.
wa_amount-currency = 'INR'.
wa_amount-curr_type = '10'.
wa_amount-disc_base = lv_amount.
append wa_amount to it_amount.
clear:wa_amount,wa_gl,wa_payable.
clear:wa_final1.
enddo.
delete adjacent duplicates from it_payable comparing vendor_no.
sort it_amount by itemno_acc.
loop at it_amount into wa_amount.
collect wa_amount into it_amount1.
endloop.
refresh it_return.
call function 'BAPI_ACC_DOCUMENT_POST'
exporting
documentheader = wa_header
importing
obj_type = wa_header-obj_type
obj_key = wa_header-obj_key
obj_sys = wa_header-obj_sys
tables
accountgl = it_gl
accountpayable = it_payable
currencyamount = it_amount1
return = it_return.
clear :it_gl,it_payable,it_amount1.
endcase.
data: return like bapiret2.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'
importing
return = return.
read table it_return into wa_return index 1.
if wa_return-type = 'E'.
message 'Error' type 'E'.
else.
message s018(zmm) with wa_return-message_v2+0(10).
endif.
Below attached is the short dump.
Thanks & Regards,
uday..,