Bapi_acc_document_post Field Enhancements

Source: Internet
Author: User

1. SE11 create structure, must contain the line item number Posnr field, and other fields that need to be extended, such as accounting code posting Key, Reason code reason code
2. SE19 implements Badi enhancement, which is used to EXTENSION2 incoming system tables to the Bapi_acc_document_post parameter table
3. Use the Bapi_acc_document_post parameter table EXTENSION2 to pass in the extension field

The detailed steps are as follows:
1, create the structure, SE11, very simple, no longer repeat, such as:

2. SE19 realizes Badi enhancement acc_document
Through the Acc_document Help document know, method change is used to complete the extension of the field, there is a need to note that the reference business type, this must be selected, otherwise the execution of BAPI will not call this Badi, I use BKPFF, such as:

Activates this Badi implementation.

Double-click the Change method to create, you can see Acc_document implementation Example Cl_exm_im_acc_document (R/3 4.7 version, other versions may not be the same), the example of the change method of the code directly copied, the activation method , the code is as follows

***********************************************************************
* Example to move fields from BAPI parameter EXTENSION2 to structure  *
* ACCIT (Accounting document line items).    & nbsp;                          *
* The dictionary structure (content for extension2-structure) must     *
* contain field Posnr, (TYPE POSNR_ACC) to indentify the correct line *
* Item of the internal Table accit.                                    *
***********************************************************************

Data:wa_extension TYPE Bapiparex,
Ext_value (960) TYPE C,
Wa_accit TYPE Accit,
L_ref TYPE ref to data.

Field-symbols: <l_struc> TYPE Any,
<l_field> TYPE any.

SORT C_extension2 by structure.

LOOP at C_extension2 to Wa_extension.
At NEW structure.
CREATE DATA l_ref TYPE (wa_extension-structure).
ASSIGN l_ref->* to <l_struc>.
ENDAT.
Concatenate Wa_extension-valuepart1 Wa_extension-valuepart2
Wa_extension-valuepart3 WA_EXTENSION-VALUEPART4
Into Ext_value.
MOVE Ext_value to <l_struc>.
ASSIGN COMPONENT ' Posnr ' of STRUCTURE <l_struc> to <l_field>.
READ TABLE c_accit with KEY Posnr = <l_field>
Into Wa_accit.
IF SY-SUBRC is INITIAL.
Move-corresponding <l_struc> to Wa_accit.
MODIFY c_accit from Wa_accit INDEX Sy-tabix.
ENDIF.
Endloop.

3. Use the Bapi_acc_document_post parameter table EXTENSION2 to pass in the extension field
**********************************************************************
*internal TABLE DECLARATION
**********************************************************************

*&--G/L Account ITEM
DATA:ACCOUNTGL TYPE Standard TABLE of BAPIACGL09.

*&-currency ITEMS
Data:currency_amount TYPE Standard TABLE of BAPIACCR09.

*&--return PARAMETER
Data:return TYPE Standard TABLE of BAPIRET2 with HEADER line.

*&--it_extension2 ITEMS
Data:it_extension2 TYPE Standard TABLE of Bapiparex with HEADER line.

*&-workarea for Zexten
Data:wa_zexten like Zexten. "Zexten is the structure that SE11 just created.

**********************************************************************
* Assign Value
**********************************************************************

*& EXTENSION2 Extended Field Enhancements section

Wa_zexten-posnr = ' 0000000010 '. The voucher line item
Wa_zexten-rstgr = ' 171 '. The voucher line item reason code

it_extension2-structure = ' Zexten '.
It_extension2-valuepart1 = Wa_zexten.
APPEND It_extension2.

* The fields of other parameter tables are assigned the following example

Header-header_txt = ' TEST HEADER '. Voucher Header Text
Header-username = Sy-uname. The user name
Header-comp_code = ' 1000 '. " Company code
header-doc_date = ' 20090618 '. " Voucher date in voucher
header-pstng_date = ' 20090618 '. " Billing date in voucher
Header-doc_type = ' S1 '. " Voucher Type
* header-bus_act = ' rfbu '. " Trading business

WA_ACCOUNTGL-ITEMNO_ACC = ' 0000000010 '. The fiscal voucher line item number
Wa_accountgl-gl_account = ' 1002010105 '. "General Ledger accounts
* Wa_accountgl-item_text =.
Wa_accountgl-bus_area = ' 8000 '. "Business scope
APPEND WA_ACCOUNTGL to ACCOUNTGL.
CLEAR WA_ACCOUNTGL.

WA_ACCOUNTGL-ITEMNO_ACC = ' 0000000020 '. The fiscal voucher line item number
Wa_accountgl-gl_account = ' 1301040000 '. "General Ledger accounts
Wa_accountgl-bus_area = ' 8000 '. "Business scope
*wa_accountgl-item_text =.
*wa_accountgl-acct_type = ' R '.
APPEND WA_ACCOUNTGL to ACCOUNTGL.
CLEAR WA_ACCOUNTGL.

WA_CURRENCY_AMOUNT-ITEMNO_ACC = ' 0000000010 '. The line item number
Wa_currency_amount-amt_doccur = ' 500 '. "Amount
wa_currency_amount-currency = ' RMB '.
APPEND Wa_currency_amount to Currency_amount.
CLEAR Wa_currency_amount.

WA_CURRENCY_AMOUNT-ITEMNO_ACC = ' 0000000020 '.
Wa_currency_amount-amt_doccur = '-500 '.
wa_currency_amount-currency = ' RMB '.
APPEND Wa_currency_amount to Currency_amount.
CLEAR Wa_currency_amount.

* Executive BAPI
Call FUNCTION ' Bapi_acc_document_post '
Exporting
Documentheader = HEADER
*CUSTOMERCPD =
*contractheader =
*importing
*obj_type =
*obj_key =
*obj_sys =
TABLES
ACCOUNTGL = ACCOUNTGL

*accountreceivable =
*accountpayable =
*accounttax =
Currencyamount = Currency_amount

*criteria =
*valuefield =
*extension1 =
return = return
*paymentcard =
*contractitem =
EXTENSION2 = It_extension2
*realestate =
.

IF return-type NA ' EA '.
Call FUNCTION ' Bapi_transaction_commit '
Exporting
WAIT = ' X '.
ENDIF.
If you also need to extend other fields, join in the struct Zexten, and then assign values to the corresponding fields before calling BAPI.

Bapi_acc_document_post Field Enhancements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.