‎2010 Oct 21 4:20 PM
I'm trying to implement BAPI_ACC_DOCUMENT_POST. I'm following the examples for filling the structures, but I'm not really sure if Im filling well.
this is the code, hoping you can help me. Thanks!!
LOOP AT t_itab.
PERFORM llena_header.
READ TABLE t_zctasing WITH KEY XBLNR = t_itab-tarifa
BUKRS = t_itab-sociedad
ZDIVISION = t_itab-division.
IF sy-subrc EQ 0.
PERFORM llena_accountgl.
PERFORM llena_accounttax.
ENDIF.
* PERFORM llena_accountgl.
PERFORM llena_currencyamount.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
exporting
documentheader = t_header
* customercpd = gd_customercpd
* contractheader = gd_fica_hd
* importing
* obj_type = l_type
* obj_key = l_key
* obj_sys = l_sys
tables
accountgl = t_accountgl
accounttax = t_accounttax
currencyamount = t_currencyamount
return = t_return.
* IF sy-subrc = 0.
* CLEAR commit_ret.
* CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT = 'X'
* IMPORTING
* RETURN = commit_ret.
* ENDIF.
CLEAR : t_header,
t_accountgl[],
t_accounttax[],
t_currencyamount[],
t_return[].
ENDLOOP.
FORM llena_header .
t_header-username = sy-uname.
t_header-header_txt = t_itab-descripcion.
t_header-comp_code = t_itab-sociedad.
t_header-doc_date = sy-datum.
t_header-pstng_date = sy-datum.
t_header-fis_period = sy-datum+2(2).
t_header-doc_type = t_itab-clase_docto.
t_header-ref_doc_no = t_itab-tarifa.
t_header-bus_act = 'RFBU'.
ENDFORM. " llena_header
*&---------------------------------------------------------------------*
*& Form llena_accountgl
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM llena_accountgl .
CLEAR t_accountgl.
IF t_zctasing-ziep EQ 'X'.
IF t_itab-iva EQ '10'.
t_accountgl-tax_code = 'A1'.
ELSEIF t_itab-iva EQ '15'.
t_accountgl-tax_code = 'A2'.
ELSEIF t_itab-iva EQ '16'.
t_accountgl-tax_code = 'A3'.
ELSEIF t_itab-iva EQ '11'.
t_accountgl-tax_code = 'A4'.
ENDIF.
ELSEIF t_itab-iva EQ '11'.
t_accountgl-tax_code = 'S2'.
ELSEIF t_itab-iva EQ '16'.
t_accountgl-tax_code = 'S1'.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = t_zctasing-zcta
IMPORTING
OUTPUT = t_zctasing-zcta.
clear t_accountgl.
t_accountgl-itemno_acc = 1.
t_accountgl-gl_account = t_zctasing-zcta.
t_accountgl-item_text = 'BAPI Test G/L line item'. "#EC NOTEXT
t_accountgl-comp_code = t_itab-sociedad.
t_accountgl-bus_area = t_itab-division.
append t_accountgl.
ENDFORM. " llena_accountgl
*&---------------------------------------------------------------------*
*& Form llena_accounttax
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM llena_accounttax .
SELECT SINGLE *
FROM T030K
WHERE ktopl EQ 'MM01' AND
ktosl EQ 'MWS' AND
mwsKz EQ t_accountgl-tax_code.
clear t_accounttax.
t_accounttax-itemno_acc = 2.
t_accounttax-gl_account = t030k-konts.
t_accounttax-tax_code = t_accountgl-tax_code.
t_accounttax-acct_key = 'MWS'.
t_accounttax-cond_key = 'MWAS'.
* t_accounttax-itemno_tax = 2.
append t_accounttax.
ENDFORM. " llena_accounttax
*&---------------------------------------------------------------------*
*& Form llena_currencyamount
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM llena_currencyamount .
DATA : v_importe_iva TYPE bapiaccr09-amt_doccur,
v_importe TYPE bapiaccr09-amt_doccur.
v_importe_iva = t_itab-importe * t_itab-iva.
v_importe_iva = v_importe_iva / 100.
v_importe = t_itab-importe - v_importe_iva.
clear t_currencyamount.
t_currencyamount-itemno_acc = 1.
* t_currencyamount-curr_type = '10'.
t_currencyamount-currency = 'MXN'.
t_currencyamount-amt_doccur = t_itab-importe.
append t_currencyamount.
clear t_currencyamount.
t_currencyamount-itemno_acc = 2.
* t_currencyamount-curr_type = '10'.
t_currencyamount-currency = 'MXN'.
t_currencyamount-amt_base = t_itab-importe.
t_currencyamount-amt_doccur = v_importe_iva.
append t_currencyamount.
* clear t_currencyamount.
* t_currencyamount-itemno_acc = 3.
** t_currencyamount-curr_type = '10'.
* t_currencyamount-currency = 'MXN'.
** t_currencyamount-amt_doccur = '3840.00'.
* append t_currencyamount.
‎2010 Oct 21 4:43 PM
Do you have a specific issue, such as no document or is there something wrong with your posted document? I don't see the extension parameter - have you implemented the BTE for the posting keys (covered in many posts on this forum)? Why is the commit code commented out?
‎2010 Oct 21 5:09 PM
When the bapi end, in the internal table t_return, have an error 702 (Balance in transaction currency), I'm new in this module, I never used BTE, I'm looking some information about structure extension1, Do you have an example about this??
I'm trying to post a document for receivables doubtful.
‎2010 Oct 21 5:29 PM
See test report ACC_BAPI_TEST_DOCUMENT. You will get better idea how to fill up all different parameters/tables.
regards,
Pranav
‎2010 Oct 21 5:40 PM
I think it's telling you that the sum of the debits has to equal the sum of the credits and they don't.
Rob
‎2010 Oct 21 7:27 PM
Yes.
Following the report ACC_BAPI_TEST_DOCUMENT, change my code as follows:
Even still get error 702 " Balance in transaction currency". What's happening?? help please!!!
t_accountgl-itemno_acc = 2.
t_accountgl-gl_account = t_zctasing-zcta. "'0021510201'.
t_accountgl-item_text = 'BAPI Test G/L line item'. "#EC NOTEXT
t_accountgl-comp_code = t_itab-sociedad.
t_accountgl-bus_area = t_itab-division.
t_accountgl-profit_ctr = t_zctasing-zprctr.
t_accountgl-tax_code = 'S1'.
append t_accountgl.
FORM llena_currencyamount .
DATA : v_importe_iva TYPE bapiaccr09-amt_doccur,
v_importe TYPE bapiaccr09-amt_doccur,
v_iva(5) TYPE c.
CONCATENATE '1.' t_itab-iva INTO v_iva. " '1.16'
v_importe_iva = ( t_itab-importe / v_iva ) * t_itab-iva.
v_importe_iva = v_importe_iva / 100.
v_importe = t_itab-importe - v_importe_iva.
clear t_currencyamount.
t_currencyamount-itemno_acc = 1.
t_currencyamount-curr_type = '10'.
t_currencyamount-currency = 'MXN'.
t_currencyamount-amt_doccur = t_itab-importe * ( -1 ). "'565.58'
append t_currencyamount.
clear t_currencyamount.
t_currencyamount-itemno_acc = 2.
t_currencyamount-curr_type = '10'.
t_currencyamount-currency = 'MXN'.
t_currencyamount-amt_doccur = v_importe. " '487.57'
append t_currencyamount.
clear t_currencyamount.
t_currencyamount-itemno_acc = 3.
t_currencyamount-curr_type = '10'.
t_currencyamount-currency = 'MXN'.
t_currencyamount-amt_base = v_importe. " '487.57'
t_currencyamount-amt_doccur = v_importe_iva. " '78.01'
append t_currencyamount.
ENDFORM. " llena_currencyamount
‎2010 Oct 21 9:38 PM
Please make GL account line item number matches with the currency amount number... otheriwse it will throw such an error.
Nabheet
‎2010 Oct 22 12:25 AM
‎2010 Oct 22 1:58 PM
Moderator message - Per forum rules, please tell the forum just what solved the problem. You can also assign Po1nts to helpful answers. This encourages people to help you in the future. Rob
‎2010 Oct 22 3:15 PM
the structure ACCOUNTRECEIVABLE(BAPIACAR09) structure was missing to fill.
FORM llena_receivable .
CLEAR t_accountreceivable.
t_accountreceivable-itemno_acc = 1.
t_accountreceivable-customer = t_itab-cliente.
t_accountreceivable-item_text = t_itab-tarifa.
APPEND t_accountreceivable.
ENDFORM.
Edited by: Hugo0355 on Oct 22, 2010 4:16 PM
‎2010 Oct 22 3:23 PM