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: 

Help Requires...........

Former Member
0 Kudos

Hi Gurus,

I am working on an interface where I am using BAPI_ACC_DOCUMENT_POST for posting an accounting document and I have not being provided with the vendor number but I have been provided with the G/L accounts for both the posting key 40 and 50 but when I am running this program, I am getting this error, "Account 206221 in company code 1000 cannot be directly posted to" and this G/L a/c is associated with posting key 50, can you please have a look at the following code and please let me know my mistake.

data: begin of it_input_file occurs 0,

pos_date(10),

bukrs(4),

pos_per(2),

currency(3),

h_text(25),

doc_type(2),

pos_key(2),

glaccount(10),

amount(16),

bus_area(4),

kostl(10),

item_text(50),

order(20),

allocation(10),

prctr(10),

doc_date(10),

end of it_input_file.

if it_input_file-pos_key eq 50.

move:

v_count to glaccount-ITEMNO_ACC,

it_input_file-glaccount to glaccount-gl_account,

it_input_file-kostl to glaccount-COSTCENTER,

it_input_file-prctr to glaccount-PROFIT_CTR,

it_input_file-bus_area to glaccount-bus_area,

it_input_file-item_text to glaccount-ITEM_TEXT.

append glaccount.

move:

v_count to currencyamount-ITEMNO_ACC,

it_input_file-currency to currencyamount-CURRENCY.

currencyamount-AMT_DOCCUR = it_input_file-amount * -1.

append currencyamount.

clear: glaccount, currencyamount.

else.

move:

v_count to glaccount-ITEMNO_ACC,

it_input_file-glaccount to glaccount-gl_account,

it_input_file-kostl to glaccount-COSTCENTER,

it_input_file-prctr to glaccount-PROFIT_CTR,

it_input_file-bus_area to glaccount-bus_area,

it_input_file-item_text to glaccount-ITEM_TEXT.

  • it_input_file-assignment to glaccount-ALLOC_NMBR.

append glaccount.

move:

v_count to currencyamount-ITEMNO_ACC,

it_input_file-currency to currencyamount-CURRENCY,

it_input_file-amount to currencyamount-AMT_DOCCUR .

append currencyamount.

clear: glaccount, currencyamount.

endif.

FORM call_bapi .

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

DOCUMENTHEADER = documentheader

IMPORTING

OBJ_TYPE = obj_type

OBJ_KEY = obj_key

OBJ_SYS = obj_sys

TABLES

ACCOUNTGL = glaccount

ACCOUNTPAYABLE = ap

CURRENCYAMOUNT = currencyamount

RETURN = return.

read table return with key type = 'S'.

if syst-subrc eq 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

IMPORTING

RETURN = return2.

perform create_success_log.

else.

perform create_failure_log.

endif.

Message was edited by:

Rajeev Gupta

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You asked this question earlier. The answer is the same. You need to use an account that can be posted to. This is handled in config. So your business analyst is the person to ask, not the forum.

If your anaalyst is not handy, try looking in BSAS. You should be able to find an account there.

Rob

6 REPLIES 6

naimesh_patel
Active Contributor
0 Kudos

You are trying to post to the account in which you can't post directly. This GL should be some kind of the recon account. SO, you can't post directly.

If you try to post directly with this account, still will give you the same message.

Use some other account. Consult your functional consutlant for some more postable account.

Regards,

Naimesh Patel

Former Member
0 Kudos

You asked this question earlier. The answer is the same. You need to use an account that can be posted to. This is handled in config. So your business analyst is the person to ask, not the forum.

If your anaalyst is not handy, try looking in BSAS. You should be able to find an account there.

Rob

0 Kudos

Since these values are coming from the file, you should send the file back to the person who gave it to you and tell him or her the problem and ask them to fix it. It's not your responsibility.

Rob

0 Kudos

Thanks for the Reply , Is Rest everything looks good with the code, I mean in my previous assignment I was provinding the GL account when the posting key was 40 and when the posting key was 50 I was providing the vendor number, but in this scenario I haven't provided the vendor number but provided the G/L account for both the possting keys, so was just wondering if I was doing it right or not

Thanks

Rajeev

0 Kudos

Your code is good to go.

I think you have some misunderstanding for your pervious assignment because we can't post vendor account with the 50 posting key.

40 and 50 keys are only allowed for the GL account.

Regards,

Naimesh Patel

0 Kudos

No, there are still problems with the code. After the BAPI call, you check sy-subrc to see if you should commit. The return code will be zero because the bapi raises no exceptions. You have to analyze the return table in order to determine whether to do a commit. (Look for a success message with a document number.)

Rob