12-13-2008 5:22 AM
Hi Friends,
Can any one help me in passing on the TAX parameters and currency parameters to
BAPI_ACC_DOCUMENT_POST.
this is the code i am using . it is posting the document and a TAX line is not created .
LOOP AT IT_ITEM WHERE HEAD_COL = IT_HEADER-FIRST_COL.
V_ITEM = V_ITEM + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V_ITEM
IMPORTING
OUTPUT = V_ITEM.
* IT_ACCGL-ITEMNO_ACC = V_ITEM. "IT_ITEM-NEWBS.
*for vendor / gl accounts based on newbs
IF IT_ITEM-NEWBS = '40' OR IT_ITEM-NEWBS = '50'.
IT_ACCGL-GL_ACCOUNT = IT_ITEM-NEWKO.
IT_ACCGL-ITEMNO_ACC = V_ITEM. "IT_ITEM-NEWBS.
IT_ACCGL-ITEM_TEXT = IT_ITEM-SGTXT.
IT_ACCGL-TAX_CODE = IT_ITEM-MWSKZ.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = IT_ITEM-AUFNR
IMPORTING
OUTPUT = IT_ACCGL-ORDERID.
IT_ACCGL-ALLOC_NMBR = IT_ITEM-ZUONR.
CONCATENATE IT_HEADER-BUDAT+0(4) IT_HEADER-BUDAT+5(2) IT_HEADER-BUDAT+8(2) INTO IT_ACCGL-PSTNG_DATE.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = IT_ITEM-KOSTL
IMPORTING
OUTPUT = IT_ACCGL-COSTCENTER.
IT_ACCGL-ITEM_TEXT = IT_ITEM-SGTXT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = IT_ITEM-PRCTR
IMPORTING
OUTPUT = IT_ITEM-PRCTR.
IT_ACCGL-PROFIT_CTR = IT_ITEM-PRCTR.
APPEND IT_ACCGL.
*for Account tax
IT_ACCTAX-ITEMNO_ACC = V_ITEM.
IT_ACCTAX-ACCT_KEY = 'VST'.
IT_ACCTAX-GL_ACCOUNT = IT_ITEM-NEWKO.
IT_ACCTAX-TAX_CODE = IT_ITEM-MWSKZ.
IT_ACCTAX-TAX_RATE = IT_MWDAT-KBETR.
APPEND IT_ACCTAX.
**CURRENCY
*populate it_curr - BAPI currency table
IT_CURR-ITEMNO_ACC = V_ITEM. "IT_ITEM-NEWBS.
IT_CURR-CURRENCY = IT_HEADER-WAERS.
IT_CURR-AMT_DOCCUR = IT_ITEM-WRBTR.
IT_CURR-EXCH_RATE = IT_HEADER-KURSF.
CLEAR IT_BSEG.
READ TABLE IT_BSEG WITH KEY BELNR = IT_ITEM-NEWKO
MWSKZ = IT_ITEM-MWSKZ
WRBTR = IT_ITEM-WRBTR.
IT_CURR-AMT_BASE = IT_BSEG-FWBAS.
V_BUKRS = IT_HEADER-BUKRS.
V_MWSKZ = IT_ITEM-MWSKZ.
V_WAERS = IT_HEADER-WAERS.
V_WRBTR = IT_ITEM-WRBTR.
CALL FUNCTION 'CALCULATE_TAX_FROM_GROSSAMOUNT'
EXPORTING
I_BUKRS = V_BUKRS
I_MWSKZ = V_MWSKZ
* I_TXJCD = ' '
I_WAERS = V_WAERS
I_WRBTR = V_WRBTR
* IMPORTING
* E_FWNAV =
* E_FWNVV =
* E_FWSTE =
* E_FWAST =
TABLES
T_MWDAT = IT_MWDAT
EXCEPTIONS
BUKRS_NOT_FOUND = 1
COUNTRY_NOT_FOUND = 2
MWSKZ_NOT_DEFINED = 3
MWSKZ_NOT_VALID = 4
ACCOUNT_NOT_FOUND = 5
DIFFERENT_DISCOUNT_BASE = 6
DIFFERENT_TAX_BASE = 7
TXJCD_NOT_VALID = 8
NOT_FOUND = 9
KTOSL_NOT_FOUND = 10
KALSM_NOT_FOUND = 11
PARAMETER_ERROR = 12
KNUMH_NOT_FOUND = 13
KSCHL_NOT_FOUND = 14
UNKNOWN_ERROR = 15
OTHERS = 16
.
IF SY-SUBRC = 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
IT_CURR-TAX_AMT = IT_MWDAT-KBETR.
IT_CURR-AMT_BASE = IT_MWDAT-KAWRT.
ENDIF.
APPEND IT_CURR.
***Extension1
*populate it_extension1 - BAPI extension1 table
V_NEWBS = IT_ITEM-NEWBS.
IT_EXTENSION1-FIELD1(10) = V_ITEM.
IT_EXTENSION1-FIELD1+10(2) = IT_ITEM-MWSKZ.
IF NOT IT_ITEM-MWSKZ IS INITIAL.
IT_EXTENSION1-FIELD2(10) = V_ITEM.
IT_EXTENSION1-FIELD2+10(1) = 'X'.
ENDIF.
*for posting key
IT_EXTENSION1-FIELD3 = V_NEWBS.
***for posting key IN EXTENSION2
IT_EXTENSION2-STRUCTURE = 'ACCIT'.
IT_TES-POSNR = V_ITEM.
IT_TES-BSCHL = V_NEWBS.
IT_TES-KBETR = IT_MWDAT-KBETR.
** IT_TES-MWSKZ = IT_ITEM-MWSKZ.
** IT_TES-XMWST = 'X'.
IT_EXTENSION2-VALUEPART2(10) = V_ITEM.
IT_EXTENSION2-VALUEPART2 = IT_ITEM-MWSKZ.
IF NOT IT_ITEM-MWSKZ IS INITIAL.
IT_EXTENSION2-VALUEPART3(10) = V_ITEM.
IT_EXTENSION2-VALUEPART3+10(1) = 'X'.
ENDIF.
MOVE IT_TES TO IT_EXTENSION2-VALUEPART1. "#EC ENHOK
APPEND IT_EXTENSION2.
ELSEIF IT_ITEM-NEWBS = '21' OR
IT_ITEM-NEWBS = '22' OR
IT_ITEM-NEWBS = '23' OR
IT_ITEM-NEWBS = '24' OR
IT_ITEM-NEWBS = '25' OR
IT_ITEM-NEWBS = '26' OR
IT_ITEM-NEWBS = '27' OR
IT_ITEM-NEWBS = '28' OR
IT_ITEM-NEWBS = '29' OR
IT_ITEM-NEWBS = '30' OR
IT_ITEM-NEWBS = '31' OR
IT_ITEM-NEWBS = '32' OR
IT_ITEM-NEWBS = '33' OR
IT_ITEM-NEWBS = '34' OR
IT_ITEM-NEWBS = '35' OR
IT_ITEM-NEWBS = '36' OR
IT_ITEM-NEWBS = '37' OR
IT_ITEM-NEWBS = '38' OR
IT_ITEM-NEWBS = '39'.
IF IT_HEADER-BLART = 'KR' OR IT_HEADER-BLART = 'KA'.
IT_ACCREC-ITEMNO_ACC = V_ITEM.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = IT_ITEM-NEWKO
IMPORTING
OUTPUT = IT_ITEM-NEWKO.
IT_ACCREC-VENDOR_NO = IT_ITEM-NEWKO.
*for GL account
CLEAR IT_LFB1.
READ TABLE IT_LFB1 WITH KEY LIFNR = IT_ITEM-NEWKO.
IF IT_LFB1-BUKRS = IT_HEADER-BUKRS.
IT_ACCREC-GL_ACCOUNT = IT_LFB1-AKONT.
IT_ACCREC-COMP_CODE = IT_HEADER-BUKRS.
IT_ACCREC-ITEM_TEXT = IT_ITEM-SGTXT.
IT_ACCREC-TAX_CODE = IT_ITEM-MWSKZ.
ENDIF.
APPEND IT_ACCREC.
CLEAR IT_ACCREC.
*for Account tax
IT_ACCTAX-ITEMNO_ACC = V_ITEM.
IT_ACCTAX-ACCT_KEY = 'VST'.
IT_ACCTAX-GL_ACCOUNT = IT_LFB1-AKONT.
IT_ACCTAX-TAX_CODE = IT_ITEM-MWSKZ.
IT_ACCTAX-TAX_RATE = IT_MWDAT-KBETR.
APPEND IT_ACCTAX.
**CURRENCY
*populate it_curr - BAPI currency table
IT_CURR-ITEMNO_ACC = V_ITEM. "IT_ITEM-NEWBS.
IT_CURR-CURRENCY = IT_HEADER-WAERS.
IT_CURR-AMT_DOCCUR = IT_ITEM-WRBTR * -1.
IT_CURR-EXCH_RATE = IT_HEADER-KURSF.
V_BUKRS = IT_HEADER-BUKRS.
V_MWSKZ = IT_ITEM-MWSKZ.
V_WAERS = IT_HEADER-WAERS.
V_WRBTR = IT_ITEM-WRBTR.
CALL FUNCTION 'CALCULATE_TAX_FROM_GROSSAMOUNT'
EXPORTING
I_BUKRS = V_BUKRS
I_MWSKZ = V_MWSKZ
I_WAERS = V_WAERS
I_WRBTR = V_WRBTR
* IMPORTING
* E_FWNAV =
* E_FWNVV =
* E_FWSTE =
* E_FWAST =
TABLES
T_MWDAT = IT_MWDAT
EXCEPTIONS
BUKRS_NOT_FOUND = 1
COUNTRY_NOT_FOUND = 2
MWSKZ_NOT_DEFINED = 3
MWSKZ_NOT_VALID = 4
ACCOUNT_NOT_FOUND = 5
DIFFERENT_DISCOUNT_BASE = 6
DIFFERENT_TAX_BASE = 7
TXJCD_NOT_VALID = 8
NOT_FOUND = 9
KTOSL_NOT_FOUND = 10
KALSM_NOT_FOUND = 11
PARAMETER_ERROR = 12
KNUMH_NOT_FOUND = 13
KSCHL_NOT_FOUND = 14
UNKNOWN_ERROR = 15
OTHERS = 16
.
IF SY-SUBRC = 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
IT_CURR-TAX_AMT = IT_MWDAT-KBETR.
IT_CURR-AMT_BASE = IT_MWDAT-KAWRT.
ENDIF.
APPEND IT_CURR.
***Extension1
*populate it_extension1 - BAPI extension1 table
V_NEWBS = IT_ITEM-NEWBS.
IT_EXTENSION1-FIELD1(10) = V_ITEM.
IT_EXTENSION1-FIELD1+10(2) = IT_ITEM-MWSKZ.
IF NOT IT_ITEM-MWSKZ IS INITIAL.
IT_EXTENSION1-FIELD2(10) = V_ITEM.
IT_EXTENSION1-FIELD2+10(1) = 'X'.
ENDIF.
*for posting key
IT_EXTENSION1-FIELD3 = V_NEWBS.
*for posting key IN EXTENSION2
IT_EXTENSION2-STRUCTURE = 'ACCIT'.
IT_TES-POSNR = V_ITEM.
IT_TES-BSCHL = V_NEWBS.
IT_TES-MWSKZ = IT_ITEM-MWSKZ.
* IT_TES-XMWST = 'X'.
IT_TES-KBETR = IT_MWDAT-KBETR.
MOVE IT_TES TO IT_EXTENSION2-VALUEPART1. "#EC ENHOK
IT_EXTENSION2-VALUEPART2(10) = V_ITEM.
IT_EXTENSION2-VALUEPART2 = IT_ITEM-MWSKZ.
IF NOT IT_ITEM-MWSKZ IS INITIAL.
IT_EXTENSION2-VALUEPART3(10) = V_ITEM.
IT_EXTENSION2-VALUEPART3+10(1) = 'X'.
ENDIF.
*
APPEND IT_EXTENSION2.
ENDIF.
ENDIF.
ENDLOOP.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = IT_DOC
* CUSTOMERCPD =
* CONTRACTHEADER =
IMPORTING
OBJ_TYPE = V_OBJ_TYPE
OBJ_KEY = V_OBJ_KEY
OBJ_SYS = V_OBJ_SYS
TABLES
ACCOUNTGL = IT_ACCGL
* ACCOUNTRECEIVABLE =
ACCOUNTPAYABLE = IT_ACCREC
* ACCOUNTTAX = IT_ACCTAX
CURRENCYAMOUNT = IT_CURR
* CRITERIA =
* VALUEFIELD =
EXTENSION1 = IT_EXTENSION1
RETURN = IT_RETURN
* PAYMENTCARD =
* CONTRACTITEM =
EXTENSION2 = IT_EXTENSION2
* REALESTATE =
* ACCOUNTWT =
.
this is for Vendor account upload to F-02.
in the flat file i am getting the Tax codes J0 and J1. for J0 there is no tax. for j1 we have 17% tax.
I am not clear in passing the values. i tried to pass the values through EXTENSION1 and EXTENSION2 also.
Kindly help me n solving this.
Thanks in Advance.
Vikki.
12-13-2008 5:50 AM
12-14-2008 10:39 AM
Hi All,
Still i am not able to get the required result.
Now i am passing the Values to the Tax values to ACCOUNTTAX strcture.
But the GL is not posted .
Can you give me some code snippets on how to pass on the value to ACCOUNTTAX, CURRENCY................
For each and every Line item how we need to pass on the TAX and CURRECNY details?
For the items which have TAX , a extra line for TAX item should be created/
Is it possible to do this with EXTENSION1 or EXTENSION2?
it will be very helpful to me if you can guide me in solving this.
Awaiting your replies.
Vikki.
12-18-2008 8:43 AM
Hi,
there is no need to use extensions.in accounttax table pass the glaccounts and taxcodes for tax.provide the corresponding line item numbers in currencyamount table with -ve sign for credit amounts.so u need to provide all line items in glaccount,accounttax...in currencyamount table.
for tax amount, just enter the 'baseamount' in 'currencyamount'.system will calculate the tax amount from the tax code u gave in 'accounttax'.
regards
Arjun
12-13-2008 5:52 AM
hi,
i think you are passing your values in wrong table.
to create tax item, there is another table structure provided in bapi is ACCOUNTTAX.
Try to pass the your values correctly there.
This is just a suggestion. be ensure befor going further.
12-18-2008 8:48 AM