Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_ACC_DOCUMENT_POST extension

Former Member
0 Likes
8,835

I need to add a custom field that does not require between the structures.

give me an example of even a trivial code of how to implement extension structures etc. to pass the field name and value?

4 REPLIES 4
Read only

juan_suros
Contributor
0 Likes
7,464

Calling report should look something like this for any of the Accounting document update BAPIs:

REPORT YACCT_DOC_UPDATE.

DATA ls_header TYPE bapiache08.
DATA lt_glaccount TYPE STANDARD TABLE OF bapiacgl08.
DATA lt_currency TYPE STANDARD TABLE OF bapiaccr08.
DATA lt_ext TYPE STANDARD TABLE OF bapiextc.
DATA lt_return TYPE STANDARD TABLE OF bapiret2.

* This is copied from an old project. Use any values that make sense to you
lt_ext = VALUE #( 
field1 = |{ bkpf-mblnr WIDTH = 10 }{ bkpf-mjahr }{ bkpf-zeile }| 
field2 = '0000000005' 
field3 = 'YACCT_DOC_UPDATE' 
field4 = |{ ekpo-mwskz WIDTH = 2 }{ ekpo-txjcd WIDTH = 16 }| ).

CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING 
  documentheader = ls_header
TABLES 
  accountgl = lt_glaccount 
  currencyamount = lt_currency 
  extension1 = lt_ext
  return = lt_return.
  1. Create an enhancement project in transaction CMOD
  2. Assign enhancement ACBAPI01 to the project
  3. Save and activate the project
  4. Navigate to the component EXIT_SAPLACC4_001
  5. Double-click into the function, continue clicking into include ZXACCU15
  6. Paste the following code:
LOOP AT extension ASSIGNING FIELD-SYMBOL(<ext>) 
WHERE field2 EQ '0000000005'AND field3 EQ 'YACCT_DOC_UPDATE'.
  LOOP AT t_accit ASSIGNING FIELD-SYMBOL(<accit>) FROM 5 TO 5. 
    <accit>-mwskz = <ext>-field4+00(02). "Tax on sales/purchases code 
    <accit>-txjcd = <ext>-field4+02(15). "Tax Jurisdiction
  ENDLOOP.
ENDLOOP.

This should be enough to get you started.

Read only

0 Likes
7,464

I did not understand the procedure well. I need to add the value of the ZTERM field of the BSEG table, but after running the bapi it does not populate the field

Read only

0 Likes
7,464

I see there is a field ACCIT-ZTERM in structure accit, so the code added to include ZXACCU15 should be:

LOOP AT extension ASSIGNING FIELD-SYMBOL(<ext>)
WHERE field1 EQ 'KEY1'
  AND field2 EQ 'KEY2'.
  AND field3 EQ 'KEY3'.
  LOOP AT t_accit ASSIGNING FIELD-SYMBOL(<accit>).
    <accit>-zterm =<ext>-field4.
  ENDLOOP.
ENDLOOP.

I am using "KEY" values in the first three fields of the EXTENSION record to safely identify the passed values from any other use of this table. If you do not have ABAP resources available the solution proposed by "gaurav.karkara3" may be a better idea.

Read only

GK817
Active Contributor
7,464

Most relevant to what you are looking for. Check this.

Gaurav