PDA

Ver la Versión Completa : BAPI para fb02


mystic_soul
30/11/10, 14:51:10
Hola a todos! como estan..
Les queria preguntar si existia una bapi para la trx FB02, ya que necesito modificar las retenciones.Creo que la bapi es BAPI_ACC_DOCUMENT_POST, pero no estoy muy seguro..
Si tienen un ejemplo como para tener una idea, me viene barbaro..

Gracias de antemano!

Saludos!

seimeinomi
30/11/10, 14:59:09
Hola,

En el siguiente post podes encontrar ejemplos.


http://www.mundosap.com/foro/showthread.php?t=1638

mystic_soul
30/11/10, 17:11:30
Gracias seimeinomi por tu respuesta!
Aplico la bapi bapi_Acc_document_post, pero me crea un nuevo documento en vez de modificarlo.. por ahi me falta pasarle mas tablas..

Paso el codigo..

LOOP AT t_bkpf.
* Header
g_header-bus_act = 'RFBU'. "'RFBU'. "Invoicing : RMRP
g_header-username = sy-uname.
g_header-header_txt = t_bkpf-belnr. "Referrence of Old Doc
g_header-comp_code = t_bkpf-bukrs.
g_header-doc_date = t_bkpf-bldat.
g_header-pstng_date = t_bkpf-budat.
g_header-fisc_year = t_bkpf-gjahr.
g_header-fis_period = t_bkpf-monat.
g_header-doc_type = t_bkpf-blart."'ZT'.
g_header-ref_doc_no = t_bkpf-xblnr.

LOOP AT t_bseg WHERE bukrs EQ t_bkpf-bukrs AND
belnr EQ t_bkpf-belnr AND
gjahr EQ t_bkpf-gjahr.

l_itemno = l_itemno + 10 .

t_accpay-itemno_acc = l_itemno.
t_accpay-vendor_no = t_bseg-lifnr.
t_accpay-bus_area = t_bseg-gsber.
t_accpay-pmnttrms = t_bseg-zterm.
t_accpay-pymt_meth = t_bseg-zlsch.
t_accpay-pmnt_block = t_bseg-zlspr.
t_accpay-tax_code = t_bseg-mwskz.
t_accpay-item_text = t_bseg-sgtxt.

APPEND t_accpay.

IF t_bseg-shkzg EQ 'H'.
t_bseg-wrbtr = ( -1 ) * t_bseg-wrbtr.
t_bseg-wmwst = ( -1 ) * t_bseg-wmwst.
ENDIF.

CLEAR t_amnt.
t_amnt-itemno_acc = l_itemno.
t_amnt-curr_type = '00' . "Document Currency
t_amnt-currency = t_bkpf-waers. "t_bseg-swaer.
t_amnt-amt_doccur = t_bseg-wrbtr.
t_amnt-tax_amt = t_bseg-wmwst.
APPEND t_amnt.

***---- With Holding Tax----------------*
LOOP AT t_with_item WHERE bukrs EQ t_bseg-bukrs AND
belnr EQ t_bseg-belnr AND
gjahr EQ t_bseg-gjahr AND
buzei EQ t_bseg-buzei.

t_wtax-itemno_acc = l_itemno.
t_wtax-wt_type = t_with_item-witht.
t_wtax-wt_code = t_with_item-wt_withcd.
t_wtax-bas_amt_lc = t_with_item-wt_qsshh.
APPEND t_wtax.
ENDLOOP.
ENDLOOP.



ENDLOOP.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = g_header
* CUSTOMERCPD =
* CONTRACTHEADER =
IMPORTING
obj_type = l_obj_type
obj_key = l_obj_key
* OBJ_SYS =
TABLES
* accountgl = t_acctgl
* ACCOUNTRECEIVABLE =
accountpayable = t_accpay
* accounttax = t_acctax
currencyamount = t_amnt
* CRITERIA =
* VALUEFIELD =
* EXTENSION1 =
return = t_return
* PAYMENTCARD =
* CONTRACTITEM =
* extension2 = t_extn
* REALESTATE =
accountwt = t_wtax
.

g_invoicedocnumber = l_obj_key+0(10).
g_fiscalyear = l_obj_key+14(4).
g_compcode = l_obj_key+10(4).

DELETE t_return WHERE type EQ 'S'.
IF t_return[] IS INITIAL.
***---- Commit Work -----------*
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.

Saludos!