Use Bapi_acc_document_post to create accounting voucher enhancements

Source: Internet
Author: User

Business requirements: And the bank to do an interface, to pass through the bank to generate accounting vouchers, accounting vouchers transaction code is F-02, found the BAPI method Bapi_acc_document_post.
Yesterday, the test found that there are some parameters in the input and table parameters of Bapi_acc_document_post not at all,
If the accounting code posting Key, Reason code reasonCo de, then how to pass the values of these fields?
In SDN check out the solution to the problem, found that there are many friends who have encountered this problem,
Summing up, the solution is broadly as follows:
1. SE11 create structure, must contain the line item number Posnr field, and other fields that need to be expanded,
   such as the accounting code posting Key, reason codereason Co de2, SE19 implementation Badi enhanced acc_document, this enhancement is used to Bapi_acc_document_ Post parameter Table EXTENSION2 incoming system table 3, using the Bapi_acc_document_post parameter table EXTENSION2, passing the extension field
The detailed steps are as follows: 1, create the structure, SE11, very simple, no longer repeat, such as:
2, SE19 realize Badi enhancement acc_document through Acc_document Help document know, method change is used to complete the extension of the field,
There is also a need to note that the reference business type, this must be selected, or the execution of BAPI will not call this Badi, I use the BKPFF,
Such as:
Activates this Badi implementation.
Double-click the Change method to create, you can view Acc_document implementation Example Cl_exm_im_acc_document (R/3 4.7 version, other versions may be different names)
Copy the code of the change method of this instance directly, activate the method, the code is as follows
************************************************************************ ExampleTo move fields fromBAPI parameter EXTENSION2 to structure**accit(Accounting Document line items).                             **  theDictionary Structure(content forEXTENSION2-STRUCTURE)must**contain field Posnr, (TYPE POSNR_ACC)To indentify the correct line**Item of theInternalTable 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-Valuepart2wa_extension-valuepart3 wa_extension-Valuepart4Into 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.
***********************************************************************INTERNAL TABLE DECLARATION***********************************************************************&--G/L Account ITEMDATA:ACCOUNTGL TYPE Standard TABLE of BAPIACGL09.*&-CURRENCY ITEMSDATA:Currency_amount TYPE Standard TABLE of BAPIACCR09.*&--RETURN PARAMETERDATA:RETURN TYPE Standard TABLE of BAPIRET2 with HEADER line.*&--It_extension2 ITEMSDATA:It_extension2 TYPE Standard TABLE of Bapiparex with HEADER line.*&-Workarea for ZextenDATA:Wa_zexten like Zexten. "ZextenJust now .SE11The structure that was created*********************************************************************** Assign Value***********************************************************************&EXTENSION2Extended Field Enhancements SectionWa_zexten-Posnr= ' 0000000010 '. The voucher line itemwa_zexten-rstgr = ' 171 '. "Voucher line Item reason codeIt_extension2-STRUCTURE= ' Zexten '.It_extension2-VALUEPART1=Wa_zexten.APPEND It_extension2.* The fields of other parameter tables are assigned the following exampleHEADER-Header_txt= ' TEST HEADER '.The voucher header textheader-username = Sy-uname. "User nameHEADER-Comp_code= ' + '.the company Codeheader-doc_date = ' 20090618 '. "voucher date in voucherHEADER-pstng_date= ' 20090618 '.The billing date in the voucherheader-doc_type = ' S1 '. "Voucher Type*HEADER-bus_act= ' Rfbu '."Trading BusinessWA_ACCOUNTGL-ITEMNO_ACC = ' 0000000010 '. "Accounting Voucher line item numberWA_ACCOUNTGL-Gl_account= ' 1002010105 '. "General ledger accounts* Wa_accountgl-item_text =.Wa_accountgl-bus_area = ' 8000 '. "Business ScopeAPPEND WA_ACCOUNTGL to ACCOUNTGL.CLEAR WA_ACCOUNTGL.WA_ACCOUNTGL-ITEMNO_ACC= ' 0000000020 '. The fiscal voucher line item numberwa_accountgl-gl_account = ' 1301040000 '. "General ledger accountsWA_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 '. "Line Item NumberWa_currency_amount-Amt_doccur= ' $ '. "Amountwa_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 BAPICall FUNCTION ' Bapi_acc_document_post 'ExportingDocumentheader = HEADER* CUSTOMERCPD =* Contractheader =* Importing* Obj_type =* Obj_key =* Obj_sys =TABLESACCOUNTGL = 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 'ExportingWAIT = ' 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.

Use Bapi_acc_document_post to create accounting voucher 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.