11-20-2007 9:59 PM
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
11-20-2007 10:29 PM
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
11-20-2007 10:02 PM
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
11-20-2007 10:29 PM
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
11-20-2007 10:37 PM
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
11-21-2007 12:38 AM
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
11-21-2007 2:52 AM
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
11-21-2007 3:30 AM
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