cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_ACC_DOCUMENT_POST Error G/L account is not defined in chart of accounts CCOA

Abapper0114
Explorer
0 Kudos
668

Hello Experts,

Our requirement is to convert BDC to BAPI_ACC_DOCUMENT_POST. The function of this program is to create a credit memo to offset the invoice.

This is the old code(BDC):

 

 

And I changed it to BAPI:

 

 

And now I'm getting and error where G/L account 6000170 is not defined in chart of accounts CCOA 

I also don't know why I should define in chart of accounts when this should be a newly created record?

I've already seen other posts regarding this and nothing seems to be working. This is my first time using this BAPI so I'm also not sure of the mapping. Any help would be great. Thank you!

Accepted Solutions (0)

Answers (3)

Answers (3)

prateek_dhawan18
Participant
0 Kudos

You are using the GL account without leading zeroes. Use the below code

CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
input = gl_account
IMPORTING
output = gl_account.

Abapper0114
Explorer
0 Kudos
GL_ACCOUNT already has the leading zeroes so FM is not needed. When I debug the BAPI in program, there was already leading zeroes in GL_ACCOUNT like '0006000170'. Above code is also not hardcoded, I just modified for easy reading.
prateek_dhawan18
Participant
0 Kudos

Why are you not populating criteria parameter of BAPI.

DATA: Lw_CRITERIA TYPE BAPIACKEC9.

Lw_CRITERIA-ITEMNO_ACC = P_LINES.

* Customer

Lw_CRITERIA-FIELDNAME = 'KNDNR'.

Lw_CRITERIA-CHARACTER = P_VBAK-KUNNR.

APPEND Lw_CRITERIA TO P_CRITERIA.

* Material

Lw_CRITERIA-FIELDNAME = 'ARTNR'.

Lw_CRITERIA-CHARACTER = P_VBAP-MATNR.

APPEND Lw_CRITERIA TO P_CRITERIA.

This way populate all fields which you are passing in line item

prateek_dhawan18
Participant
0 Kudos

Hi 

Take help from functional and get the config done.

1st. you need to create the account at COA Level in T.Code FSP1 or FSP0 .

2nd. you need to create the account at company code level using T.Code FSS0

You can also do both steps in one at T.Code FS00

DominikTylczyn
SAP Champion
SAP Champion
0 Kudos

Hello @Abapper0114 

An account has to be created before you can post to it. 

Probably you need to add leading zeros to the account number before passing it to the BAPI.

Best regards

Dominik Tylczynski

Abapper0114
Explorer
0 Kudos
But when I debug the program, there was already leading zeroes in GL_ACCOUNT like '0006000170'. This also is not hardcoded, I just modified for easy reading.