Difference between revisions of "SAP FI BAPI"
From SapWiki
| (5 intermediate revisions by the same user not shown) | |||
| Line 205: | Line 205: | ||
===SAP Note 487722 - Using EXTENSION1 for accounting BAPIs=== | ===SAP Note 487722 - Using EXTENSION1 for accounting BAPIs=== | ||
| − | + | ===Implementing CMOD/SMOD exit ACBAPI01 with enhancement structure EXTENSION1, exit EXIT_SAPLACC4_001, include ZXACCU15=== | |
| − | + | ===Implementing the Business Transaction Event (BTE, also OPEN FI) RWBAPI01 with enhancement structure EXTENSION1 at BAPI_ACC_DOCUMENT_POST=== | |
| − | + | Transaction FIBF: | |
#Call the menu path "Settings > Products -> ...of a customer" and create a product that mirrors the function which is to be mapped in the BTE. | #Call the menu path "Settings > Products -> ...of a customer" and create a product that mirrors the function which is to be mapped in the BTE. | ||
#Create a function module that contains the same interface, such as example module SAMPLE_INTERFACE_RWBAPI01. | #Create a function module that contains the same interface, such as example module SAMPLE_INTERFACE_RWBAPI01. | ||
| Line 214: | Line 214: | ||
#Finally, activate the product you have created in the first step so that the module will run. | #Finally, activate the product you have created in the first step so that the module will run. | ||
| − | + | ejemplo para colocar Nº de Personal: | |
| − | * extension 1, ver funcion Z_SAMPLE_INTERFACE_RWBAPI01, BTE RWBAPI01 (tran. FIBF) | + | <nowiki>* extension 1, ver funcion Z_SAMPLE_INTERFACE_RWBAPI01, BTE RWBAPI01 (tran. FIBF) |
| − | + | CLEAR it_ext. | |
| − | + | it_ext-field1 = it_accountgl-itemno_acc. | |
| − | + | it_ext-field2 = 'PERNR'. | |
| − | + | MOVE p_pernr TO it_ext-field3. | |
| − | + | APPEND it_ext. | |
| − | + | ||
| − | + | CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST' | |
| − | + | EXPORTING | |
| − | + | documentheader = ls_documentheader | |
| − | + | IMPORTING | |
| − | + | obj_type = l_type | |
| − | + | obj_key = l_key | |
| − | + | obj_sys = l_sys | |
| − | + | TABLES | |
| − | + | accountgl = it_accountgl | |
| − | + | accountpayable = it_accountpayable | |
| − | + | currencyamount = it_currencyamount | |
| − | + | extension1 = it_ext | |
| − | + | return = it_return | |
| − | . | + | . |
| + | |||
| + | FUNCTION z_sample_interface_rwbapi01. | ||
| + | *"---------------------------------------------------------------------- | ||
| + | *"*"Interfase local | ||
| + | *" TABLES | ||
| + | *" IT_ACCIT STRUCTURE ACCIT | ||
| + | *" IT_ACCCR STRUCTURE ACCCR | ||
| + | *" RETURN STRUCTURE BAPIRET2 | ||
| + | *" EXTENSION STRUCTURE BAPIACEXTC | ||
| + | *" IT_ACCWT STRUCTURE ACCIT_WT | ||
| + | *" CHANGING | ||
| + | *" VALUE(DOCUMENT_HEADER) LIKE ACCHD STRUCTURE ACCHD | ||
| + | *"---------------------------------------------------------------------- | ||
| + | DATA : ls_bapi_extension TYPE bapiacextc. | ||
| + | DATA ld_posnr TYPE posnr_acc. | ||
| + | |||
| + | CLEAR: ls_bapi_extension. | ||
| + | |||
| + | LOOP AT extension INTO ls_bapi_extension. | ||
| + | ld_posnr = ls_bapi_extension-field1. | ||
| + | * evaluate fieldname | ||
| + | CASE ls_bapi_extension-field2. | ||
| + | WHEN 'PERNR'. | ||
| + | * set document Status | ||
| + | READ TABLE it_accit | ||
| + | WITH KEY posnr = ld_posnr. | ||
| + | CHECK sy-subrc EQ 0. | ||
| + | it_accit-pernr = ls_bapi_extension-field3. | ||
| + | MODIFY it_accit INDEX sy-tabix. | ||
| + | ENDCASE. | ||
| + | ENDLOOP. | ||
| + | |||
| + | ENDFUNCTION.</nowiki> | ||
| + | ==BAPI_EXCHRATE_CREATEMULTIPLE - Insert One or More Exchange Rates in SAP Tables== | ||
| + | |||
| + | ==POSTING_INTERFACE_DOCUMENT== | ||
| + | |||
| + | Post document using the internal posting interface | ||
| + | |||
| + | Function module 'POSTING_INTERFACE_DOCUMENT' creates a batch input | ||
| + | transaction ( or Call Transaction ... Using ...) for a document to be | ||
| + | posted with FB01 or FBB1. | ||
| + | |||
| − | + | [[Category:BAPI]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 16:48, 20 June 2026
Contents
- 1 BAPI_ACC_DOCUMENT_POST
- 2 Notas BAPI FI
- 2.1 SAP Note 487722 - Using EXTENSION1 for accounting BAPIs
- 2.2 Implementing CMOD/SMOD exit ACBAPI01 with enhancement structure EXTENSION1, exit EXIT_SAPLACC4_001, include ZXACCU15
- 2.3 Implementing the Business Transaction Event (BTE, also OPEN FI) RWBAPI01 with enhancement structure EXTENSION1 at BAPI_ACC_DOCUMENT_POST
- 3 BAPI_EXCHRATE_CREATEMULTIPLE - Insert One or More Exchange Rates in SAP Tables
- 4 POSTING_INTERFACE_DOCUMENT
BAPI_ACC_DOCUMENT_POST
- Ejemplo con extensión
FORM document_post USING p_pernr
p_begda
p_endda
p_monto
p_modo
CHANGING p_subrc
p_return TYPE bapiret2.
DATA:
ls_documentheader LIKE bapiache09,
l_customercpd LIKE bapiacpa09,
l_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.
DATA: lt_p0001 TYPE TABLE OF p0001 WITH HEADER LINE,
lt_p0185 TYPE TABLE OF p0185 WITH HEADER LINE.
DATA: l_type LIKE ls_documentheader-obj_type,
l_key LIKE ls_documentheader-obj_key,
l_sys LIKE ls_documentheader-obj_sys.
DATA l_pos TYPE posnr_acc.
DATA l_amount TYPE bapicurr-bapicurr.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = p_pernr
infty = '0001'
* IMPORTING
* SUBRC =
TABLES
infty_tab = lt_p0001
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT lt_p0001 WHERE begda <= p_endda
AND endda >= p_begda.
ENDLOOP.
* CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
* IMPORTING
* own_logical_system = ls_documentheader-obj_sys.
* ls_documentheader-obj_type = 'BKPFF'.
* ls_documentheader-obj_key = '$'.
ls_documentheader-bus_act = 'RFBU'.
* ls_documentheader-obj_key =
ls_documentheader-username = sy-uname.
ls_documentheader-header_txt = 'Bonificación'. "#EC NOTEXT
* gd_documentheader-obj_key_r =
* GD_DOCUMENTHEADER-reason_rev =
ls_documentheader-comp_code = lt_p0001-bukrs.
* GD_DOCUMENTHEADER-AC_DOC_NO =
ls_documentheader-fisc_year = sy-datum(4).
ls_documentheader-doc_date = sy-datum.
ls_documentheader-doc_type = 'SA'.
ls_documentheader-pstng_date = sy-datum.
* GD_DOCUMENTHEADER-TRANS_DATE =
* GD_DOCUMENTHEADER-VALUE_DATE =
ls_documentheader-fis_period = sy-datum+4(2).
* GD_DOCUMENTHEADER-DOC_TYPE =
* GD_DOCUMENTHEADER-REF_DOC_NO =
* GD_DOCUMENTHEADER-COMPO_ACC =
ls_documentheader-bus_act = 'RFBU'.
* l_documentheader-ref_doc_no = '1'.
DATA l_valor(100).
l_pos = l_pos + 1.
CLEAR: it_accountgl.
l_valor = '11111'. "cuenta
it_accountgl-itemno_acc = l_pos.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = l_valor
IMPORTING
output = it_accountgl-gl_account.
CONCATENATE 'Bonificación Empleado' p_pernr INTO it_accountgl-item_text
SEPARATED BY space.
it_accountgl-value_date = sy-datum.
APPEND it_accountgl.
* 2da pos
CLEAR it_accountgl.
l_pos = l_pos + 1.
l_valor = '22222000'. "N° cuenta
it_accountgl-itemno_acc = l_pos.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = l_valor
IMPORTING
output = it_accountgl-gl_account.
CONCATENATE 'Bonificación Empleado' p_pernr INTO it_accountgl-item_text.
APPEND it_accountgl.
* ver SAP Note 487722 - Using EXTENSION1 for accounting BAPIs
* extension 1
CLEAR it_ext.
it_ext-field1 = it_accountgl-itemno_acc.
it_ext-field2 = 'PERNR'.
MOVE p_pernr TO it_ext-field3.
APPEND it_ext.
* montos
l_amount = p_monto.
CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
EXPORTING
currency = 'CLP'
amount_internal = l_amount
IMPORTING
amount_external = l_amount.
CLEAR it_currencyamount.
it_currencyamount-itemno_acc = 1.
* it_currencyamount-curr_type = '00'.
it_currencyamount-currency = 'CLP'.
* IT_CURRENCYAMOUNT-CURRENCY_ISO =
it_currencyamount-amt_doccur = l_amount.
* IT_CURRENCYAMOUNT-EXCH_RATE = .
* it_currencyamount-amt_base =
* IT_CURRENCYAMOUNT-DISC_BASE =
* it_currencyamount-exch_rate_v =
* it_currencyamount-disc_amt =
APPEND it_currencyamount.
CLEAR it_currencyamount.
it_currencyamount-itemno_acc = 2.
*it_currencyamount-curr_type = '00'.
it_currencyamount-currency = 'CLP'.
* IT_CURRENCYAMOUNT-CURRENCY_ISO =
it_currencyamount-amt_doccur = l_amount * -1.
* IT_CURRENCYAMOUNT-EXCH_RATE =
* it_currencyamount-amt_base =
* IT_CURRENCYAMOUNT-DISC_BASE =
* it_currencyamount-exch_rate_v =
* it_currencyamount-disc_amt =
APPEND it_currencyamount.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = ls_documentheader
* customercpd = ls_customercpd
* contractheader = ls_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
.
LOOP AT it_return INTO p_return WHERE type = 'E'.
ENDLOOP.
IF sy-subrc NE 0.
p_subrc = 0.
ELSE.
p_subrc = 1.
MESSAGE ID p_return-id TYPE 'I' NUMBER p_return-number
WITH p_return-message_v1
p_return-message_v2
p_return-message_v3
p_return-message_v4 DISPLAY LIKE 'E'.
ENDIF.
ENDFORM. " PAGO_ANTICIPADO
Notas BAPI FI
SAP Note 487722 - Using EXTENSION1 for accounting BAPIs
Implementing CMOD/SMOD exit ACBAPI01 with enhancement structure EXTENSION1, exit EXIT_SAPLACC4_001, include ZXACCU15
Implementing the Business Transaction Event (BTE, also OPEN FI) RWBAPI01 with enhancement structure EXTENSION1 at BAPI_ACC_DOCUMENT_POST
Transaction FIBF:
- Call the menu path "Settings > Products -> ...of a customer" and create a product that mirrors the function which is to be mapped in the BTE.
- Create a function module that contains the same interface, such as example module SAMPLE_INTERFACE_RWBAPI01.
- Call menu path "Settings -> Process function modules > ...of a customer" enter process = RWBAPI01, the function module created and the product.
- Finally, activate the product you have created in the first step so that the module will run.
ejemplo para colocar Nº de Personal:
* extension 1, ver funcion Z_SAMPLE_INTERFACE_RWBAPI01, BTE RWBAPI01 (tran. FIBF)
CLEAR it_ext.
it_ext-field1 = it_accountgl-itemno_acc.
it_ext-field2 = 'PERNR'.
MOVE p_pernr TO it_ext-field3.
APPEND it_ext.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = ls_documentheader
IMPORTING
obj_type = l_type
obj_key = l_key
obj_sys = l_sys
TABLES
accountgl = it_accountgl
accountpayable = it_accountpayable
currencyamount = it_currencyamount
extension1 = it_ext
return = it_return
.
FUNCTION z_sample_interface_rwbapi01.
*"----------------------------------------------------------------------
*"*"Interfase local
*" TABLES
*" IT_ACCIT STRUCTURE ACCIT
*" IT_ACCCR STRUCTURE ACCCR
*" RETURN STRUCTURE BAPIRET2
*" EXTENSION STRUCTURE BAPIACEXTC
*" IT_ACCWT STRUCTURE ACCIT_WT
*" CHANGING
*" VALUE(DOCUMENT_HEADER) LIKE ACCHD STRUCTURE ACCHD
*"----------------------------------------------------------------------
DATA : ls_bapi_extension TYPE bapiacextc.
DATA ld_posnr TYPE posnr_acc.
CLEAR: ls_bapi_extension.
LOOP AT extension INTO ls_bapi_extension.
ld_posnr = ls_bapi_extension-field1.
* evaluate fieldname
CASE ls_bapi_extension-field2.
WHEN 'PERNR'.
* set document Status
READ TABLE it_accit
WITH KEY posnr = ld_posnr.
CHECK sy-subrc EQ 0.
it_accit-pernr = ls_bapi_extension-field3.
MODIFY it_accit INDEX sy-tabix.
ENDCASE.
ENDLOOP.
ENDFUNCTION.
BAPI_EXCHRATE_CREATEMULTIPLE - Insert One or More Exchange Rates in SAP Tables
POSTING_INTERFACE_DOCUMENT
Post document using the internal posting interface
Function module 'POSTING_INTERFACE_DOCUMENT' creates a batch input transaction ( or Call Transaction ... Using ...) for a document to be posted with FB01 or FBB1.