PDA

Ver la Versión Completa : Campo Amt_base En Bapi Acc_document_post


nievesmp
24/06/09, 08:09:30
Estoy trabajando con la bapi acc_document_post me contabiliza (pero no me carga el amt_base) cuando no le paso la tabla 'accounttax'.

Si le paso la tabla 'accounttax' me dice 'el campo amt_base es requerido, introduzca un valor válido'. Pero si que se le está pasando el valor correspondiente! y lo he comprobado en la tabla final, el formato y valor en la posición correspondiente es el correcto.

No se si tiene que ver porque el indicador de iva, (TAX_CODE) hemos tenido que crear un z (1%), ya que no vamos a aplicarle ninguno, solo necesito que cargue el amt_base tal como se lo estoy pasando.

Alguien tiene idea de como puedo lograr esto???? Muchas Gracias


**&---------------------------------------------------------------------*
**& Form RELLENA_CABECERA
**&---------------------------------------------------------------------*
form rellena_cabecera.
****** formato fecha documento
dia = t_fok-budat(2).
mes = t_fok-budat+3(2).
ano = t_fok-budat+6(4).

concatenate ano mes dia into fecha.
clear w_documentheader.
w_documentheader-bus_act = 'RFBU'.
w_documentheader-username = sy-uname.
w_documentheader-comp_code = t_fok-bukrs.
w_documentheader-fisc_year = sy-datum(4).
w_documentheader-doc_date = fecha(8).
w_documentheader-pstng_date = fecha(8).
w_documentheader-doc_type = t_fok-blart.
w_documentheader-ref_doc_no = t_fok-num_reg.
w_documentheader-header_txt = t_fok-bktxt.
clear n_docum.

move t_fok-num_reg to n_docum.

endform. "RELLENA_CABECERA
*
*
**&---------------------------------------------------------------------*
**& Form rellena_pos_cuenta_mayor
**&---------------------------------------------------------------------*
form rellena_pos_cuenta_mayor.


call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = t_fok-hkont
importing
output = t_accountgl-gl_account.

t_accountgl-itemno_acc = t_fok-jnllinn.
t_accountgl-item_text = t_fok-sgtxt.
t_accountgl-ref_key_1 = t_fok-xref1.
t_accountgl-ref_key_2 = t_fok-xref2.
t_accountgl-ref_key_3 = t_fok-xref3.
t_accountgl-doc_type = t_fok-blart.
t_accountgl-comp_code = t_fok-bukrs.
t_accountgl-bus_area = t_fok-gsber.
t_accountgl-fisc_year = sy-datum(4).
dia = t_fok-budat(2).
mes = t_fok-budat+3(2).
ano = t_fok-budat+6(4).
concatenate ano mes dia into fecha.
t_accountgl-pstng_date = fecha.
clear fecha.
****** Formato fecha valor
dia = t_fok-valut(2).
mes = t_fok-valut+3(2).
ano = t_fok-valut+6(4).
concatenate ano mes dia into fecha.
t_accountgl-value_date = fecha.
* t_accountgl-trade_id = t_fok-bukrs.
t_accountgl-costcenter = t_fok-kostl.

if t_fok-hkont = 433100.
t_accountgl-alloc_nmbr = 'CR9999'.
endif.

endform. "rellena_pos_cuenta_mayor


*&---------------------------------------------------------------------*
*& Form rellena_posiciones_moneda
*&---------------------------------------------------------------------*
form rellena_posiciones_moneda.

* t_currencyamount-exch_rate = t_fok-kursf.
* t_currencyamount-curr_type = '00'.

replace all occurrences of ',' in t_fok-wrbtr with '.'.
condense t_fok-wrbtr no-gaps.

replace all occurrences of ',' in t_fok-misamt with '.'.
condense t_fok-misamt no-gaps.

case w_acc_docum-shkzg.
when 'S'.
if t_fok-wrbtr is not initial.
t_currencyamount-itemno_acc = t_fok-jnllinn.
t_currencyamount-currency = t_fok-waers.
t_currencyamount-amt_doccur = t_fok-wrbtr.
t_currencyamount-disc_base = t_fok-wrbtr.
t_currencyamount-amt_base = t_fok-misamt.
t_currencyamount-tax_amt = t_fok-wrbtr.
endif.

when 'H'.
if t_fok-wrbtr is not initial.
t_currencyamount-itemno_acc = t_fok-jnllinn.
t_currencyamount-currency = t_fok-waers.
t_currencyamount-amt_doccur = - t_fok-wrbtr.
t_currencyamount-disc_base = - t_fok-wrbtr.
t_currencyamount-amt_base = - t_fok-misamt.
t_currencyamount-tax_amt = - t_fok-wrbtr.
endif.
endcase.

clear w_acc_docum.

endform. "rellena_impuestos

form rellena_impuesto.
t_accounttax-itemno_acc = t_fok-jnllinn.
t_accounttax-direct_tax = 'X'.
t_accounttax-TAX_CODE = 'Z1'.
endform.

*&---------------------------------------------------------------------*
*& Form rellena_ext
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form rellena_ext.
clear w_extension2.
w_extension2-structure = 'ZBAPI_ACC_DOCUM'.
* Posición
w_acc_docum-posnr = t_fok-jnllinn.
* Clave Contable
w_acc_docum-bschl = t_fok-bschl.
case t_fok-bschl.
when 50 or 31.
w_acc_docum-shkzg = 'H'.
when 40 or 25 or 21.
w_acc_docum-shkzg = 'S'.
endcase.
move w_acc_docum to w_extension2-valuepart1.
append w_extension2 to t_extension2.

endform. "rellena_ext

*&---------------------------------------------------------------------*
*& Form CARGA_DOCUMENTO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form carga_documento.
clear t_return.
refresh t_return.
call function 'BAPI_ACC_DOCUMENT_CHECK'
exporting
documentheader = w_documentheader
tables
* accountpayable = t_accountpayable
* accountreceivable = t_poscliente
accountgl = t_accountgl
accounttax = t_accounttax
currencyamount = t_currencyamount
return = t_return
* extension1 = t_extension1.
extension2 = t_extension2.
read table t_return index 1 into w_return.
if not w_return-type = 'S'.
* Muestra errores
call function 'C14ALD_BAPIRET2_SHOW'
tables
i_bapiret2_tab = t_return.
else.
clear t_return.
refresh t_return.

"* Contabilizar documento
call function 'BAPI_ACC_DOCUMENT_POST'
exporting
documentheader = w_documentheader
tables
accountgl = t_accountgl
currencyamount = t_currencyamount
return = t_return
extension2 = t_extension2.

read table t_return index 1 into w_return.

if w_return-type = 'S'.
read table t_return
into w_return
with key id = 'RW'
number = '605'
type = 'S'.
* write: /'Documento contable generado: ', w_return-message_v2(10).

"* Guarda cambios
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
endif.
endif.
check not t_fok[] is initial.
* check p_test is initial.
endform. "CARGA_DOCUMENTO

drmezzetta
17/07/09, 17:41:15
Probá cargarle el tipo de cambio, es en el campo exch_rate de la tabla currencyamount.

saludos.