Hello all,
Is anybody aware of a way, when creating an Accounts Payable invoice, to ensure that the document header field "calculate tax automatically" is populated if any of the line items tax codes have a specific value. We are able to do this in custom interface programs but now we are attempting to do the same thing when accounting clerks are manually creating the Accounts Payable documents.
I tried to use the business transaction event 00001020. This BTE has 2 internal tables that have all the detail of the line items as well as the header information. This event happens before the final check in the transaction.
I am trying to enhance the transaction to have the tax automatically calculated even if the field was not checked when entering the document header information.
When I'm in the debugger I can see that the code is being executed as I intended, but it seems to be too late in the process to have the tax automatically calculated.
Here is the code that I put in the function module.
data: i_u2(2) occurs 0 with header line. "ITAB U2 taxcode
data: w_lines type i.
Build an internal table, I_U2, from line items 'U2'
loop at t_bseg where mwskz = 'U2'.
i_u2 = t_bseg-mwskz.
append i_u2.
endloop.
Determine if any line items contain the tax code 'U2'
describe table i_u2 lines w_lines.
if w_lines > 0.
Set calculate_tax field in the header record
loop at t_bkpf.
t_bkpf-xmwst = 'X'.
modify t_bkpf index sy-tabix.
endloop.
endif.
Has anyone been able to do what I'm attempting using BTE or some other method?
Thanks
Bruce