2007 Oct 09 10:14 AM
Hi Friends,
I tried to create accounting document from the babi 'BAPI_ACC_DOCUMENT_POST'. In a one line item i need to give withholding tax information. How to pass this value to this bapi. I passed the withholding tax info in the ACCOUNTTAX parameter. But that is not working.
thanks in advance.
regards
sritkanth
2007 Oct 09 10:32 AM
Hi,
you have to put all currencyamount for each position (AccountPayable, AccountGL, AccountTax in the table Currencyamount.)
e.g.
itemno 1 (Accountpayable) => 119,0000- (dont forget the "-")
itemno 2 (GLAccount) => 100,00
itemno 3 (taxaccount) => 19,00
Then it will work.
2007 Oct 09 10:32 AM
Hi,
you have to put all currencyamount for each position (AccountPayable, AccountGL, AccountTax in the table Currencyamount.)
e.g.
itemno 1 (Accountpayable) => 119,0000- (dont forget the "-")
itemno 2 (GLAccount) => 100,00
itemno 3 (taxaccount) => 19,00
Then it will work.
2007 Oct 11 12:04 PM
Hi, thank you for your answer,
I passed the line item for with hold tax also. like wat u suggested
itemno 1 (Accountpayable) => 119,0000- (dont forget the "-")
itemno 2 (GLAccount) => 100,00
itemno 3 (taxaccount) => 19,00
But in the Accountpayable line item when i was clicking the Withhold tax button it is showing no withhold tax information. How to resolve this prob.
thanks and regards
srikanth. s
2007 Oct 09 10:37 AM
go through this code
data:gt_accountgl type table of bapiacgl09 with header line,
gt_accountpayable type table of bapiacap09 with header line,
gt_currencyamount type table of bapiaccr09 with header line,
gt_return type table of bapiret2 with header line.
data:wa_documentheader type bapiache09,
vcounter type i.
tables:bdcmsgcoll.
TABLE TO READ FILE DATA
data: begin of gt_uploadfile occurs 0,
input(200) type c,
end of gt_uploadfile,
TABLE FOR DOWNLOAD FILE
begin of gt_downloadfile occurs 0,
output type string,
end of gt_downloadfile,
TO HOLD HEADER DATA
begin of gt_header occurs 0,
counter(1),
identifier(2),
bukrs(5),
accnt(10),
bldat like sy-datum,
budat like sy-datum,
wrbtr(10),
end of gt_header,
begin of gt_item occurs 0,
counter(1),
identifier(2),
hkont(10),
wrbtr(10),
kostl(10),
end of gt_item,
INTERNAL TABLE TOI DISPLAY ERRORS.
begin of gt_summery occurs 0,
identifier(2),
bukrs(5),
accnt(10),
msgv1 like bdcmsgcoll-msgv2,
msgv2 like bdcmsgcoll-msgv2,
msgnr type string,
end of gt_summery,
v_upload type string,
v_download type string,
msg type string,
v_hkont type string,
v_kostl type string,
date1 type datum,
date2 type datum,
v_refkey like bapiache09-obj_key.
*CREATING SELECTION CREITERIA
parameters:p_gfile like ibipparms-path,
p_test as checkbox.
P_DFILE LIKE IBIPPARMS-PATH.
at selection-screen on value-request for p_gfile.
perform f4help_upload.
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_DFILE.
PERFORM F4HELP_DOWNLOAD.
start-of-selection.
v_upload = p_gfile.
V_DOWNLOAD = P_DFILE.
perform uploadfile.
perform sendinto_head_item.
perform buildbapi.
end-of-selection.
perform disp_report.
&----
*& Form F4HELP
&----
text
----
--> p1 text
<-- p2 text
----
form f4help_upload .
call function 'F4_FILENAME'
exporting
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
field_name = 'P_GFILE'
importing
file_name = p_gfile
.
endform. " F4HELP
&----
*& Form F4HELP_DOWNLOAD
&----
text
----
--> p1 text
<-- p2 text
----
form f4help_download .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_DFILE'
IMPORTING
FILE_NAME = P_DFILE
.
endform. " F4HELP_DOWNLOAD
&----
*& Form UPLOADFILE
&----
text
----
--> p1 text
<-- p2 text
----
form uploadfile .
call function 'GUI_UPLOAD'
exporting
filename = v_upload
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '|'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE = VIRUS_SCAN_PROFILE
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH = FILELENGTH
HEADER = HEADER
tables
data_tab = gt_uploadfile
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " UPLOADFILE
&----
*& Form SENDINTO_HEAD_ITEM
&----
text
----
--> p1 text
<-- p2 text
----
form sendinto_head_item .
loop at gt_uploadfile.
if gt_uploadfile-input+0(1) = '1'.
split gt_uploadfile-input at cl_abap_char_utilities=>horizontal_tab
into
gt_header-counter
gt_header-identifier
gt_header-bukrs
gt_header-accnt
gt_header-bldat
gt_header-budat
gt_header-wrbtr.
append gt_header.
clear gt_header.
else.
split gt_uploadfile-input at cl_abap_char_utilities=>horizontal_tab
into gt_item-counter
gt_item-identifier
gt_item-hkont
gt_item-wrbtr
gt_item-kostl.
append gt_item.
clear gt_item.
endif.
BREAK-POINT.
endloop.
endform. " SENDINTO_HEAD_ITEM
&----
*& Form BUILDBAPI
&----
text
----
--> p1 text
<-- p2 text
----
form buildbapi .
loop at gt_header.
GT_HEADER-BUDAT = sy-datum - 5.
GT_HEADER-BLDAT = sy-datum.
vcounter = 1.
gt_header-wrbtr = gt_header-wrbtr * -1.
*FILLING INPORTING PARAMETER STRUCTURE.
wa_documentheader-comp_code = gt_header-bukrs.
wa_documentheader-doc_date = gt_header-bldat.
wa_documentheader-pstng_date = gt_header-budat.
wa_documentheader-username = sy-uname.
wa_documentheader-bus_act = 'RFBU'.
wa_documentheader-doc_type = 'KR'.
gt_accountpayable-itemno_acc = vcounter.
gt_accountpayable-vendor_no = gt_header-accnt.
append gt_accountpayable.
clear gt_accountpayable.
gt_currencyamount-itemno_acc = vcounter.
gt_currencyamount-currency = 'INR'.
gt_currencyamount-amt_doccur = gt_header-wrbtr.
append gt_currencyamount.
clear gt_currencyamount.
loop at gt_item where identifier = gt_header-identifier.
vcounter = vcounter + 1. .
gt_accountgl-itemno_acc = vcounter.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = gt_item-hkont
importing
output = gt_item-hkont.
gt_accountgl-gl_account = gt_item-hkont.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = gt_item-kostl
importing
output = gt_item-kostl.
gt_accountgl-costcenter = gt_item-kostl.
gt_accountgl-pstng_date = gt_header-budat.
append gt_accountgl.
clear gt_accountgl.
gt_currencyamount-itemno_acc = vcounter.
gt_currencyamount-currency = 'INR'.
gt_currencyamount-amt_doccur = gt_item-wrbtr.
append gt_currencyamount.
clear gt_currencyamount.
endloop.
call function 'BAPI_ACC_DOCUMENT_POST'
exporting
documentheader = wa_documentheader
CUSTOMERCPD = CUSTOMERCPD
CONTRACTHEADER = CONTRACTHEADER
importing
OBJ_TYPE = OBJ_TYPE
obj_key = v_refkey
OBJ_SYS = OBJ_SYS
tables
accountgl = gt_accountgl
ACCOUNTRECEIVABLE = ACCOUNTRECEIVABLE
accountpayable = gt_accountpayable
ACCOUNTTAX = ACCOUNTTAX
currencyamount = gt_currencyamount
CRITERIA = CRITERIA
VALUEFIELD = VALUEFIELD
EXTENSION1 = EXTENSION1
return = gt_return
PAYMENTCARD = PAYMENTCARD
CONTRACTITEM = CONTRACTITEM
EXTENSION2 = EXTENSION2
REALESTATE = REALESTATE
.
break-point.
if p_test is initial.
call function 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = WAIT
IMPORTING
RETURN = RETURN
.
endif. .
endloop.
endform. " BUILDBAPI
&----
*& Form disp_report
&----
text
----
--> p1 text
<-- p2 text
----
form disp_report .
loop at gt_return.
write:/ gt_return-type,
gt_return-id,
gt_return-number,
gt_return-message,
gt_return-log_no,
gt_return-log_msg_no,
gt_return-message_v1,
gt_return-message_v2,
gt_return-message_v3,
gt_return-message_v4,
gt_return-parameter,
gt_return-row,
gt_return-field,
gt_return-system.
endloop..
endform. " disp_report
reward points if helpful........
2007 Oct 10 1:13 PM
Hi sritkanth,
you have to pass the withholding tax info to ACCOUNTWT in the BAPI.
Reward points if helpfull.
A+
Ihsen.
2007 Oct 11 12:06 PM
Hi lhsen,
thanks for ur reply. But BAPI_ACC_DOCUMENT_POST the bapi doesn't have the
ACCOUNTWT parameter
pls. help me.
regards
srikanth. s
2007 Oct 11 12:19 PM
Hi srikanth,
I'm using ECC6, which release of SAP are you using,
in ECC6, the BAPI_ACC_DOCUMENT_POST have the ACCOUNTWT parameter,
the BAPI last change by SAP 09.01.2005.
the bapi looks like this :
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader =
CUSTOMERCPD =
CONTRACTHEADER =
IMPORTING
OBJ_TYPE =
OBJ_KEY =
OBJ_SYS =
tables
ACCOUNTGL = G/L account item
ACCOUNTRECEIVABLE = Customer Item
ACCOUNTPAYABLE = Vendor Item
ACCOUNTTAX = Tax item
currencyamount = Currency Items
CRITERIA = CO-PA Account Assignment Characteristics
VALUEFIELD = CO-PA Account Assignment Value Fields
EXTENSION1 = Container for 'Customer Exit' Parameter
return = Return parameter
PAYMENTCARD = Payment Card Information
CONTRACTITEM = Additional Contract Accounts Recieviable
and Payable Document Line Item
EXTENSION2 = Reference Structure for BAPI Parameters
EXTENSIONIN/EXTENSIONOUT
REALESTATE = Real Estate Account Assignment Data
<b>ACCOUNTWT = Withholding tax information for FI Interface</b> .
hope this help you.