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

Not able to post document using BAPI_ACC_GL_POSTING_POST

Former Member
0 Likes
2,821

Hi all,

While trying to post documents in FB60 using BAPI_ACC_GL_POSTING_POST we are getting error Account not assigned to company code. But we are able to post documents manually using the same account and company code. Couls any one help me out to resolve this issue.

Thanks & Regards,

Neela.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,424

Hi,

Try using the BAPI

BAPI_ACC_DOCUMENT_POST

18 REPLIES 18
Read only

Former Member
0 Likes
2,425

Hi,

Try using the BAPI

BAPI_ACC_DOCUMENT_POST

Read only

Former Member
0 Likes
2,424

This is complete procedure to use 'BAPI_ACC_DOCUMENT_POST'. It can be used for GL, AR or AP documents.

Step 1:

For Header information, fill u201CDocumentHeaderu201D structure as:

obj_type = 'BKPFF'

obj_key = '$'

obj_sys = CONCATENATE syst-sysid 'CLNT' syst-mandt

bus_act = 'RFBU'

username = syst-uname .

comp_code = Company Code

doc_date = Document Date

pstng_date = Posting Date

doc_type = Document Type like AB, SA.

ref_doc_no = Reference Document

To populate the line item data, fill internal table u201Caccountglu201D or u201Caccountpayableu201D or u201Caccountreceivableu201D as:

itemno_acc = Line Number (like 10,20)

gl_account = GL Account Code (For GL Line Items only)

vendor_no = Vendor Number (For AP Line Items only)

customer = Customer Number (For AR Line Items only)

acct_type = 'S' or u2018Ku2019 or u2018Du2019. (GL = u2018Su2019, AP = u2018Ku2019, AR = u2018Du2019)

costcenter = Cost Center

orderid = Internal Order

tax_code = Tax Code

item_text = Item Text

quantity = Quantity

base_uom = Unit for Quantity

Note:

u2022 Separate internal tables should be created for GL lines, AP Lines and AR Lines.

u2022 If posting GL line items then only u201Caccountglu201D internal table should be filled.

u2022 If posting AP document then GL lines should be filled in table u201Caccountglu201D and Vendor lines should be filled in table u201Caccountpayableu201D.

u2022 If posting AR document then GL lines should be filled in table u201Caccountglu201D and Customer lines should be filled in table u201Caccountreceivableu201D.

u2022 Extension of each line of u201Caccountglu201D, u201Caccountpayableu201D and u201Caccountreceivableu201D must be there in u201Ccurrencyamountu201D.

To populate the amount, fill u201Ccurrencyamountu201D structure as:

itemno_acc = Line Number (like 10,20, but pair of u201Caccountglu201D line)

amt_doccur = Amount {Credit amount should be with sign

currency = Currency

Step 2:

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = st_documentheader

IMPORTING

obj_key = w_objkey

TABLES

accountgl = i_gl {GL Line Items}

accountpayable = i_ap {AP Line Items

accountreceivable = i_ar {AR Line Items}

currencyamount = i_amt {Amount of all above}

return = i_bapiret. {Return messages}

Read only

0 Likes
2,424

Hi,

Since i am using this for GL document i have filled the internal table u201Caccountglu201D.But still i get the same error " Account does not exists in the chart of accounts".

Thanks & Regards,

Neela.

Read only

0 Likes
2,424

Hi,

Try using coversion_exit to account number before passing to the BAPI.

Read only

0 Likes
2,424

Hi,

Try using the conversion exit for account number. and then shift the output result to 7 places left as the output is 17 characters where as the account number in ska1 table is 10 chars

check the below code for your reference.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = fs_item-glacc

IMPORTING

output = fs_item-glacc.

SHIFT fs_item-glacc BY 7 PLACES LEFT.

SELECT SINGLE *

FROM ska1

INTO lfs_ska1

WHERE ktopl = lfs_bukrs-ktopl

AND saknr = fs_item-glacc.

hope this helps

regards

padma

Read only

0 Likes
2,424

Hi Padmavathi,

Thank u for the response it helped me a lot but i get another error FI/CO interface: Line item entered several times. What is the reason for this error. How could it be resolved.

Thanks & Regards,

Neela

Read only

0 Likes
2,424

Hi Neela,

Make sure you have filled field 'ITEMNO_ACC' in table 'ACCOUNTGL' with unique line number, and make sure it linked with the same field in table 'CURRENCYAMOUNT'

Read only

0 Likes
2,424

Hi,

Make sure that you append records into the line item table correctly and also make sure that you clear and refresh the internal table data inside the loop. I guess your code is append the same record more than once.

Check in debug the entries in the line item table.

regards

padma

Read only

0 Likes
2,424

Hi,

I am posting the part of the code in which the item table and value table are appended. Pls check and guide me if any changes required becos i still get the error "FI/CO interface: Line item entered several times".

  • Fill header item values.

doc_values-itemno_acc = idx1.

doc_values-currency_iso = 'INR'.

doc_values-amt_doccur = wa_fb60-wrbtr.

APPEND doc_values.

CLEAR doc_values.

  • Fill Line Item Document

doc_item-itemno_acc = idx1.

doc_item-comp_code = wa_fb60-bukrs

doc_item-gl_account = wa_gl-hkont.

doc_item-pstng_date = sy-datlo.

doc_item-item_text = wa_gl-zuonr.

doc_item-costcenter = wa_gl-kostl.

*doc_item- = 'M5253'.

APPEND doc_item.

CLEAR doc_item.

  • Fill Line 1 of Document Value.

doc_values-itemno_acc = idx1.

doc_values-currency_iso = 'INR'.

doc_values-amt_doccur = wa_gl-wrbtr1.

APPEND doc_values.

CLEAR doc_values.

Read only

0 Likes
2,424

DATA:
g_docheader LIKE bapiache08,
gi_accountgl TYPE STANDARD TABLE OF bapiacgl08,
g_accountgl LIKE bapiacgl08,
gi_amount TYPE STANDARD TABLE OF bapiaccr08,
g_amount LIKE bapiaccr08,
gi_return TYPE STANDARD TABLE OF bapiret2,
g_return LIKE bapiret2.
START-OF-SELECTION.
g_docheader-obj_type = 'BKPFF'.
g_docheader-obj_key = '1'.
g_docheader-obj_sys = 'B3TCLNT800'.
g_docheader-username = sy-uname.
g_docheader-header_txt = 'BAPI test'.
g_docheader-comp_code = '1000'.
g_docheader-doc_date = sy-datum.
APPEND g_amount TO gi_amount.
* Item 1
g_accountgl-itemno_acc = '0000000001'.
g_accountgl-gl_account = 'GIVE YOUR GL A/C NO'.
g_accountgl-pstng_date = sy-datum.
APPEND g_accountgl TO gi_accountgl.
* Item 2
g_accountgl-itemno_acc = '0000000002'.
g_accountgl-gl_account = 'GIVE YOUR GL A/C NO'.
g_accountgl-pstng_date = sy-datum.
APPEND g_accountgl TO gi_accountgl.
* Item 1
g_amount-itemno_acc = '0000000001'.
g_amount-currency = 'EUR'.
g_amount-amt_doccur = 5000.
APPEND g_amount TO gi_amount.
* Item 2
g_amount-itemno_acc = '0000000002'.
g_amount-currency = 'EUR'.
g_amount-amt_doccur = -5000.
APPEND g_amount TO gi_amount.
END-OF-SELECTION.
* Call the BAPI function
CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING
documentheader = g_docheader
* IMPORTING
* OBJ_TYPE =
* OBJ_KEY =
* OBJ_SYS =
TABLES
accountgl = gi_accountgl
currencyamount = gi_amount
return = gi_return
* EXTENSION1 =.
LOOP AT gi_return INTO g_return.
WRITE: / g_return-message.
ENDLOOP. 
Read only

0 Likes
2,424

Resolved

Read only

Former Member
0 Likes
2,424

Every GL Account filled in table ACCOUNTGL, is checked in table SKA1 where Chart of Account is also part of primary key. ACCOUNTGL also has a field for Company Code. You must fill the Company Code because Chart of Account will be taken from Company Code. To see the Chart of Account attached with that Company Code, check the table T001 .

Read only

0 Likes
2,424

Hi Deepak,

Company code is also been populated in accountgl table but still the same error.

  • Fill Line Item Document

doc_item-itemno_acc = idx1.

doc_item-comp_code = 'CRMA'.

doc_item-gl_account = wa_gl-hkont.

doc_item-pstng_date = sy-datlo.

doc_item-item_text = wa_gl-zuonr.

doc_item-costcenter = wa_gl-kostl.

APPEND doc_item.

CLEAR doc_item.

Thanks & Regards,

Neela

Read only

0 Likes
2,424

Theh you need to check GL Account in table SKB1 with combination of Company Code. If that exists then automatically GL Account will exist in SKA1 with same Chart Of Account as of Company Code.

Read only

Former Member
0 Likes
2,424

Hi,

In FB60, While making a debit entry ( 40 ) against G/L, We need to make a corresponding credit entry against vendor. I believe the vendor account was missing.

Better use BAPI_ACC_DOCUMENT_POST. It is a generic one. You can make the entry for vendor in accounts payable.

Hope it helps.

Sujay

Read only

Former Member
0 Likes
2,424

This function module is used when we need to debit from a G/L account and credit another G/L account.

Hope it helps.

Sujay

Read only

Former Member
0 Likes
2,424

Is it possible to post the data to F-02 entries?

means for GL line item we have to give vendor (GL-VENDOR )wit hposting keys 40,39.for vendor splgl indicator 1 will be there .

for gl cost center will be there

Read only

Former Member
0 Likes
2,424

Is it possible to post the data to F-02 entries?

means for GL line item we have to give vendor (GL-VENDOR )wit hposting keys 40,39.for vendor splgl indicator 1 will be there .

for gl cost center will be there