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: 

BAPI_ACC_DOCUMENT_POST - User Exit is not working

Former Member
0 Kudos

Hi all,

I need to perform a posting and pass in some field into the extension table. I have follow the sap note recomendation and created a project in CMOD using ACBAPI01 as the component. I then added the coded into the user exit. When I tried to debug it doesn't not execute the code inside the user exit. Also BAPI_ACC_DOCUMENT_POST was executed w/o any error. However when I check the system, there's no document posted.

Also please correct me if I'm wrong. I'm not so sure what to populate for the following field in the header. Is the following correct?

gt_docheader-obj_type = 'IDOC'.

gt_docheader-obj_key = '$'.

gt_docheader-obj_sys = 'BGS1'.

gt_docheader-bus_act = 'RFBU'.

Thanks in advance

Ricky

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Hi Ricky and Igor,

Rick is right: You can use userexit wherever they are provided. Many BAPIs as i.e.

[code]BAPI_ACC_DOCUMENT_POST

BAPI_ACC_DOCUMENT_CHECK

BAPI_ACC_GL_POSTING_POST

BAPI_ACC_GL_POSTING_CHECK

BAPI_ACC_BILLING_POST

BAPI_ACC_BILLING_CHECK

BAPI_ACC_INVOICE_RECEIPT_POST

BAPI_ACC_INVOICE_RECEIPT_CHECK

BAPI_ACC_GOODS_MOVEMENT_POST

BAPI_ACC_GOODS_MOVEMENT_CHECK

[/code]

are implemented including userexit (to be seen as CALL CUSTOMER-FUNCTION in coding). Only the most impotant and regularily used fields are part of the BAPI interface. If the customer makes an append to any table or structure, the handling of the additional fields does not always happen automatically in the BAPI.

We created a User exit for BAPI BAPI_ACC_GL_POSTING_POST because the customer made extensions to the posting block.

The additional parameter values are passed in the BAPI extension table which is a genereric character table. In include ZXACCU15 we do the transfer of values passed via extension table to table t_accit which is part of the interface of the ueserexit.

If then BAPI is executed but it does not trigger the userexit, then you can put a breakpoint at the statement before CALL CUSTOMER-FUNCTION and see if you get there. If CALL CUSTOMER-FUNCTION is not executed, then try do de-activate the CMOD project and activate it again. This usually helps.

For the document header I can provide you just anaother example which works for us:

[code] ls_documentheader-obj_type = 'BKPFF'.

ls_documentheader-obj_sys = lv_logsys.

ls_documentheader-obj_key = '$'.

ls_documentheader-username = sy-uname.

ls_documentheader-header_txt = 'Investment Notes reconciliation'(026).

ls_documentheader-comp_code = ps_alv_display-bukrs.

ls_documentheader-doc_date = p_bldat.

ls_documentheader-fisc_year = p_gjahr.

ls_documentheader-pstng_date = p_budat.

ls_documentheader-fis_period = p_bper .

ls_documentheader-doc_type = p_blart.

[/code]

Hope this helps.

Regards,

Clemens

8 REPLIES 8

former_member185943
Participant
0 Kudos

Hi, Ricky!

I don't understand the connection between your user-exit and a BAPI. Calling a BAPI and expecting that it will trigger user-exit? I didn't try, but it doesn't seem logical to me. I believe user-exits are triggered only after running transactions, not on BAPIs. But maybe I didn't understand your idea. Please explain more what are you actually doing.

As for the document not being created, you need to commit after posting (the function BAPI_TRANSACTION_COMMIT if you are calling BAPI on different destination, or statement COMMIT WORK. if you are on the same system).

I had my header like this:

s_doc_header-DOC_DATE     = v_bldat.
s_doc_header-PSTNG_DATE   = v_budat.
s_doc_header-DOC_TYPE     = v_blart.
s_doc_header-USERNAME     = sy-uname.
s_doc_header-BUS_ACT      = 'RFBU'.
s_doc_header-COMP_CODE    = <output>-bukrs.
s_doc_header-REF_DOC_NO   = <output>-contract_nr.

I know that these variables mean nothing to you, but at least you can see that I didn't use many constants.

HTH,

Igor

0 Kudos

Hi,

Maybe I had used the wrong terminolgy. It should be customer exit (if i'm not mistaken). Anyway I follow what that had been recommended by SAP in notes 487722.

Ricky

0 Kudos

Ricky,

I still don't know what are you trying to do. Please explain.

Did you try BAPI_TRANSACTION_COMMIT? Did my header example help you?

Regards,

Igor

0 Kudos

I'm trying to perform a posting. At the same time would like to control the posting key myself instead of letting the system to determine it. So I would like to put the posting key into the extension structure. And based on the sap note. I need to go cmod and create a project. then put my code in an exit. Then this will intercept the execution before posting. During that point, I can then read the posting key and modify it before posting. This will hopefully made a posting based on the posting key that i want. But somehow after following each of the recomended steps it still does not work.

Ricky

Clemenss
Active Contributor
0 Kudos

Hi Ricky and Igor,

Rick is right: You can use userexit wherever they are provided. Many BAPIs as i.e.

[code]BAPI_ACC_DOCUMENT_POST

BAPI_ACC_DOCUMENT_CHECK

BAPI_ACC_GL_POSTING_POST

BAPI_ACC_GL_POSTING_CHECK

BAPI_ACC_BILLING_POST

BAPI_ACC_BILLING_CHECK

BAPI_ACC_INVOICE_RECEIPT_POST

BAPI_ACC_INVOICE_RECEIPT_CHECK

BAPI_ACC_GOODS_MOVEMENT_POST

BAPI_ACC_GOODS_MOVEMENT_CHECK

[/code]

are implemented including userexit (to be seen as CALL CUSTOMER-FUNCTION in coding). Only the most impotant and regularily used fields are part of the BAPI interface. If the customer makes an append to any table or structure, the handling of the additional fields does not always happen automatically in the BAPI.

We created a User exit for BAPI BAPI_ACC_GL_POSTING_POST because the customer made extensions to the posting block.

The additional parameter values are passed in the BAPI extension table which is a genereric character table. In include ZXACCU15 we do the transfer of values passed via extension table to table t_accit which is part of the interface of the ueserexit.

If then BAPI is executed but it does not trigger the userexit, then you can put a breakpoint at the statement before CALL CUSTOMER-FUNCTION and see if you get there. If CALL CUSTOMER-FUNCTION is not executed, then try do de-activate the CMOD project and activate it again. This usually helps.

For the document header I can provide you just anaother example which works for us:

[code] ls_documentheader-obj_type = 'BKPFF'.

ls_documentheader-obj_sys = lv_logsys.

ls_documentheader-obj_key = '$'.

ls_documentheader-username = sy-uname.

ls_documentheader-header_txt = 'Investment Notes reconciliation'(026).

ls_documentheader-comp_code = ps_alv_display-bukrs.

ls_documentheader-doc_date = p_bldat.

ls_documentheader-fisc_year = p_gjahr.

ls_documentheader-pstng_date = p_budat.

ls_documentheader-fis_period = p_bper .

ls_documentheader-doc_type = p_blart.

[/code]

Hope this helps.

Regards,

Clemens

Former Member
0 Kudos

Hi,

I tried to debug and I can't find the point when they call the customer exit. I'm using BAPI_ACC_DOCUMENT_POST. What's the different between this and the rest?

Anyway, I manage to post now but the customer exit is still not working. Also, I'm using obj_type = IDOC. I tried BKPFF but it returns me an error. Not so sure why. Maybe you can shed some light.

Ricky

Former Member
0 Kudos

Ricky,

i had the same problem, which was solved by doing what is in the note you mentionned, namely:

Implementing the Business Transaction Event (BTE, also OPEN FI) RWBAPI01 with enhancement structure EXTENSION1 at BAPI_ACC_DOCUMENT_POST

Deactivate user exit, implement BTE in 4 steps ( be sure to activate the product in step 4, not in step 1), activate user exit, set breakpoint in user exit and try out.

Hope it helps,

Regards,

Rolf

Former Member
0 Kudos

Hi Rolf,

Millions thanks. It solved all my problem. Just one last question, how do I transport those settings (BTE) to another system?

Hi everybody,

Thanks. Really appreaciate that.

Ricky