Skip to Content
author's profile photo Former Member
Former Member

BAPI_ACC_DOCUMENT_POST - User Exit is not working

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


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jan 12, 2007 at 10:36 AM

    Hi Ricky and Igor,

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












    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.


    Hope this helps.



    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 12, 2007 at 09:35 AM

    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.



    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Igor Barbaric

      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.


Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.