Application Development 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: 

Accts Payable posting using BAPI..

Former Member
0 Kudos

Hi,

I am using BAPI_ACC_DOCUMENT_POST to post acct payables. I have an input file which can have 1 header and multiple detail lines. My question is do I need to pass both accts payable and accts GL structures to this BAPI when i post accts payable data ?

Also I want to understand how many lines items need to be filled in these structures as I am getting an error that says "Line item entered several times" and I am not able to figure out whats the issue ?

Inclusing the currency structure currently I am populting lines 10 and 20 if there are 2 details lines, am I right ? Pl explain with an example.

thks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi ,

You need to use GL Structure as shown below.The error says that you have entered itemno value twice with the same value[000000001] in one of these structures,please do see the below code to understand better.

*--Populating GL Structure

wa_accountgl-itemno_acc = v_itemnoacc.

wa_accountgl-gl_account = wa_lineitem-gl_account.

wa_accountgl-profit_ctr = wa_lineitem-profit_center.

wa_accountgl-costcenter = wa_lineitem-cost_center.

wa_accountgl-item_text = wa_lineitem-line_item_text.

wa_accountgl-wbs_element = wa_lineitem-wbs_element.

wa_accountgl-trade_id = wa_lineitem-trading_partner.

wa_accountgl-network = wa_lineitem-network.

wa_accountgl-comp_code = wa_lineitem-line_company.

wa_accountgl-cs_trans_t = wa_lineitem-transaction_type.

wa_accountgl-doc_type = wa_lineitem-document_type.

APPEND wa_accountgl TO it_check_accountgl.

CLEAR wa_accountgl.

*--Populating Currency Item Structure

wa_currencyamount-itemno_acc = v_itemnoacc.

TRANSLATE wa_lineitem-line_amount USING ', '.

CONDENSE wa_lineitem-line_amount NO-GAPS.

wa_currencyamount-amt_doccur = wa_lineitem-line_amount * amount_sign_value.

wa_currencyamount-currency = v_currency.

wa_currencyamount-curr_type = '00'.

APPEND wa_currencyamount TO it_check_currencyamount.

CLEAR wa_currencyamount.

Thanks

Sudharshan

13 REPLIES 13

Former Member
0 Kudos

Hi ,

You need to use GL Structure as shown below.The error says that you have entered itemno value twice with the same value[000000001] in one of these structures,please do see the below code to understand better.

*--Populating GL Structure

wa_accountgl-itemno_acc = v_itemnoacc.

wa_accountgl-gl_account = wa_lineitem-gl_account.

wa_accountgl-profit_ctr = wa_lineitem-profit_center.

wa_accountgl-costcenter = wa_lineitem-cost_center.

wa_accountgl-item_text = wa_lineitem-line_item_text.

wa_accountgl-wbs_element = wa_lineitem-wbs_element.

wa_accountgl-trade_id = wa_lineitem-trading_partner.

wa_accountgl-network = wa_lineitem-network.

wa_accountgl-comp_code = wa_lineitem-line_company.

wa_accountgl-cs_trans_t = wa_lineitem-transaction_type.

wa_accountgl-doc_type = wa_lineitem-document_type.

APPEND wa_accountgl TO it_check_accountgl.

CLEAR wa_accountgl.

*--Populating Currency Item Structure

wa_currencyamount-itemno_acc = v_itemnoacc.

TRANSLATE wa_lineitem-line_amount USING ', '.

CONDENSE wa_lineitem-line_amount NO-GAPS.

wa_currencyamount-amt_doccur = wa_lineitem-line_amount * amount_sign_value.

wa_currencyamount-currency = v_currency.

wa_currencyamount-curr_type = '00'.

APPEND wa_currencyamount TO it_check_currencyamount.

CLEAR wa_currencyamount.

Thanks

Sudharshan

0 Kudos

Hey sudarshan,

Thats exactly how I have done...but what happens is for every detail line in my input AP file a GL acct is created , is that correct ?

Also i assign the acct number as follows: i need 10, 20, 30 and so on...

DATA l_lineacc(10) TYPE i.

l_lineacc = 10.

loop.

...

...

wa_accountgl-itemno_acc = l_lineacc.

l_lineacc = l_lineacc + 10.

...

...

endloop.

Any issues in this ??

thks

0 Kudos

hey,

one more thing..my input file has just 1 header and 2 details lines..during debugging i can see the acct numbers populated perfectly as

0000000010

0000000020

in acct gl , acct payable and currency structures...

so what can be wrong ??

0 Kudos

i still get the error

AP Interface Errors

The following error occurred for the accounts payable

that was passed to SAP for your plant

1 827671 1025 100010 Error in document: BKPFF

1 827671 1025 100010 FI/CO interface: Line item entered several times

0 Kudos

What are the structures that you are populating while posting the data please do check with all these as this error occurs only if you have line_Item_No value entered twice.

Please do check once again in debug mode before executing this bapi in depth.

Thanks

Sudharshan

0 Kudos

Hey Sudarshan,

I am populating the following structures..

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = wa_documentheader

TABLES

accountgl = t_accountgl

accountpayable = t_accountpayable

currencyamount = t_currencyamount

return = t_return.

Also the t_return , in debugging more has the following values, note the error number and see of u can help me any further.

type ID Number Message Message3

E RW 609 Error in document: BKPFF

E RW 014 Line item entered several times 00000010

thks

0 Kudos

Hi,

I forgot to specify this point which will definetly solve your problem,

In accounts payable structure you pass itemno_acc ='0000000001' thats fine but when you are populating GL structure and Currency amount Structure you start with next item no like

wa_accountgl-itemno_acc = v_itemnoacc + 1.

wa_currencyamount-itemno_acc = v_itemnoacc + 1.

And also if you are populating extension start with the above itemno + 1.

I hope now you will be able to post the document.

Thanks

Sudharshan

0 Kudos

hey Sudarshan,

i am back to working on this now but still not able to post the data...

i tried ur way but no help...let me throw in some more points..

my input file has data like this..

H827671 08102008 1889.19 1025 blah blah

D827671 489.94 2112000800

D827671 1399.25 2112000600

H denotes header and D denotes detail line..

so i need to process the details lines and post the AP thru the BAPI..now there can be one or many details lines per header ..

so my code stores the header lines in separate internal table and detail lines in another. I loop thru the detail. For every detail, there is a transaction id which is to link to the header record..i hope u understand this..

so i say

loop at detail internal table.

at new transaction id

fill the document header structure for bapi.

end at.

fill acct payable venfor structure for bapi

fill the GL acct structure for bapi

fill the currency amount structure for bapi

at new transaction id

call bapi

end at.

endloop.

does this make sense ?

now, my code earlier had statements to fill the currency strructure twice for every loop pass..one with -ve value and one with +ve. So for 489.94, there will be 2 entries in the currency structure , 489.94 and -489.94. shud we pass this way ??

i tried setting the line number as u said...like for vendor structure i set as 1, then for GL and currency amt i set as 2, 2.

in next loop, vendor structure takes as 1+10 = 11

so GL and currency take 12, 12 and so on...

is this correct ??

thks

0 Kudos

Hi,

Please do check this once again

Load v_lineitem = 1

Update AccountsPayable table and Currency Amount Table of BAPI

Load v_lineitem = 2

Update GLAccount table and Currency Amount Table of BAPI

Here if you see I have written currency structure at both the level.First time item_no(v_lineitem) is 1 with amount equals to header_amount.And second time item_no(v_lineitem) is 2 and the amount will be line item amount.

I know you have been confused just see the below sketch to understand better

line_number = 1.

accountspayable-itemno_acc = line_number .

....

...

append accountspayable.

currencyamount-itemno_acc = line_number .

currencyamount-amt_doccur = headeramount * -1.

append currencyamount.

accountgl-itemno_acc = line_number + 1.

.....

.....

append accountgl.

currencyamount-itemno_acc = wa_lineitem-invoice_line_number + 1.

currencyamount-amt_doccur = line_item_amount .

append currencyamount.

If you see now currency table you will find first row with line number 1 with header amount and from line 2 you will find line item amount .

Let me know if its clear to you now or no.

Thanks

sudharshan

0 Kudos

Yes Sudarshan, I too adopted a similar approach and it worked..thanks a lot.

Former Member
0 Kudos

Hello,

I am having some difficulty with this BAPI as well. I am unsure which field to put the tax amount in.

AMT_DOCCUR or the AMT_BASE.

I have one entry for the AccountPayable line #1 $550.00

I have two entries in the AccountGL I'm making both of them for $250.00 Lines 2 & 3. The tax amount for each is 10% or $25.

So I have two lines in my tax table, one for each invoice. I then have two related lines in the CurrencyAmount module. Each of them should be $25.00.

I have two entries in the Accounttax module lines 4 & 5 each containing the tax code 'VD'. (10%)

I have lines 1-5 in the CurrencyAmount module, one for each the AP line #1, the GL lines 2 & 3, and the AccountTax lines 4&5.

It worked fine before I entered the Tax lines so I'm assuming they are the problem.

When I put the $25 in the AMT_DOCCUR and $250 in the AMT_BASE, I get an error stating 'The tax amount must not be greater than the Base amount'. #747

When I flip it around and put the $250 in the AMT_DOCCUR and the $25 in the AMT_BASE, I get the error

" Balance in Transaction Currency" #702.

Anybody know exactly how to fill this in.

thanks

0 Kudos

I GOT IT!!!!!

0 Kudos

Hi Brett ,

I have a posting to do exactly same scenario you mentioned, Can you throw some light on how you populated ACCOUNTTAX structure that will be great.

Below is my posted question