2014 Jun 19 6:43 AM
dear all
i am new to this,
i want to create a document using tCode: F-02
i used this BAPI: BAPI_ACC_GL_POSTING_POST
now i want to set the "Posting Key" for every line in the document.
people on the internet are saying, use: "EXTENSION1".
but i don't know what the fields mean.
so please i need an example to set the "posting Key"
thanks,
2014 Jun 19 7:43 AM
Hi Ramzy,
Please write the following code.
Step 1: Populate structure extension as below in your program.
Field1 in extension should POSNR ( Line item number ), Field2 should be field name, in your case, it will be BSCHL, Field3 should posting key.
lst_extension1-field1 = l_item_no.
lst_extension1-field2 = 'BSCHL'
lst_extension1-field3 = '40'.
APPEND lst_extension1 TO li_extension1.
Step2: Go inside your BAPI BAPI_ACC_GL_POSTING_POST, you will find a user exit as below screenshot.
Go inside this perform you will find function exit EXIT_SAPLACC4_001. Create a project from CMOD and write following inside the z include.
LOOP AT extension.
* Determine line item
READ TABLE t_accit WITH KEY posnr = extension-field1.
IF sy-subrc IS INITIAL.
* Determine posting key
IF extension-field3 IS NOT INITIAL AND
extension-field2 = 'BSCHL'.
* Update the line item with posting key
t_accit-bschl = '40'.
MODIFY t_accit INDEX sy-tabix.
ENDIF.
Hope this helps for you.
2014 Jun 19 7:10 AM
Hi,
Posting key can be passed by passing -Ve value (for debit posting key), +ve value (for credit posting key ) to the field CURRENCYAMOUNT-AMT_DOCCUR.
Regards
2014 Jun 19 7:15 AM
thanks for your reply, but i want to set specific "Posting key".
thanks,
2014 Jun 19 7:23 AM
Hi,
I hope you wanted to pass either debit posting key or credit posting key for each line item.
In that case, for a line item if you want to set debit posting key multiply the value of AMT_DOCCUR with -1 other wise pass the value with out multiplying with -1.
Regards,
2014 Jun 19 7:31 AM
2014 Jun 19 7:40 AM
2014 Jun 19 7:43 AM
if i use "BAPI_ACC_DOCUMENT_POST" ? then i can change the Posting Key?
what about "Extension1" in BAPI_ACC_GL_POSTING_POST ?
2014 Jun 19 7:46 AM
2014 Jun 19 7:43 AM
Hi Ramzy,
Please write the following code.
Step 1: Populate structure extension as below in your program.
Field1 in extension should POSNR ( Line item number ), Field2 should be field name, in your case, it will be BSCHL, Field3 should posting key.
lst_extension1-field1 = l_item_no.
lst_extension1-field2 = 'BSCHL'
lst_extension1-field3 = '40'.
APPEND lst_extension1 TO li_extension1.
Step2: Go inside your BAPI BAPI_ACC_GL_POSTING_POST, you will find a user exit as below screenshot.
Go inside this perform you will find function exit EXIT_SAPLACC4_001. Create a project from CMOD and write following inside the z include.
LOOP AT extension.
* Determine line item
READ TABLE t_accit WITH KEY posnr = extension-field1.
IF sy-subrc IS INITIAL.
* Determine posting key
IF extension-field3 IS NOT INITIAL AND
extension-field2 = 'BSCHL'.
* Update the line item with posting key
t_accit-bschl = '40'.
MODIFY t_accit INDEX sy-tabix.
ENDIF.
Hope this helps for you.
2014 Jun 19 8:29 AM
i want to thank you for your reply, but when i try to edit the function "EXIT_SAPLACC4_001"
it asks me for Access key, i already have one but it is not working ?
do you have any idea ?
thanks ,
2014 Jun 19 8:50 AM
2014 Jun 19 8:51 AM
HI Ramzy,
The below thread might help how to write the code in the include. Please do follow the steps and let me know if you need further assitance.
User exit asking for access key in CMOD
Thanks
2024 Oct 29 10:34 AM
2014 Jun 19 8:26 AM
Hi Ramzy -
Please check the below link, details are avaialble using BAPI_ACC_DOCUMENT_POST and the extension and the BADI ACC_DOCUMENT ( method - Change)
http://scn.sap.com/message/14643146#14643146
Let us know in case any further help
Regards,
Atul Mohanty
2014 Jun 19 10:52 AM
thanks
but i am creating this document for customer.
so it gives me this error: "Account 1250701 in company code 2000 cannot be directly posted to"
and i didnt pass the GL account it give me error you musr set the GL Account.
FYI, i didit by my hand from the screen F-02 and it is working very good.
here is the sample of my code:
("ITEMNO_ACC", "1");
table.SetValue("CUSTOMER", "241");
table.SetValue("GL_ACCOUNT", "0001250701");
2014 Jun 19 10:59 AM