Application Development and Automation 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: 
Read only

BAPI to post asset in FB01

cryan_marco
Participant
0 Likes
2,671

Hi,

I am trying to post debit and credit asset (posting key 70 and 75) using BAPI_ACC_DOCUMENT_POST, unfortunately I don't know how it should be done or if this BAPI is really capable of posting asset just like in FB01 transaction.

I also tried user exit EXIT_SAPLACC4_001 and BTE RWBAPI01, but it is not even being called when I execute BAPI_ACC_DOCUMENT_POST.

Do you have an idea how should I do this? Is BAPI_ACC_DOCUMENT_POST can be used to post asset just like in FB01? If not, do you know what BAPI or FM should I use instead?

I will really appreciate any help. Thanks in advance.

Regards,

Ryan

Hi,

I am trying to post debit and credit asset (posting key 70 and 75) using BAPI_ACC_DOCUMENT_POST, unfortunately I don't know how it should be done or if this BAPI is really capable of posting asset just like in FB01 transaction.

I also tried user exit EXIT_SAPLACC4_001 and BTE RWBAPI01, but it is not even being called when I execute BAPI_ACC_DOCUMENT_POST.

Do you have an idea how should I do this? Is BAPI_ACC_DOCUMENT_POST can be used to post asset just like in FB01? If not, do you know what BAPI or FM should I use instead?

I will really appreciate any help. Thanks in advance.

Regards,

Ryan

6 REPLIES 6
Read only

Former Member
0 Likes
2,075

Hi,

This BAPI is possible of posting assets like FB01 tcode.

Check some threads on asset here:

/message/7181346#7181346 [original link is broken]

Regards,

Amit

Read only

0 Likes
2,075

Hi Amit,

Thank you for the reply.. I followed the instructions from the links you have given me, but I am still getting this error..

Account <999999> in company code <XXXX> cannot be directly posted to.

I asked our FI consultant to change the config to allow posting in the GL accounts of Assets. She said we should not change it. It is too risky. The user can post document without specifying the asset.

Can I still use BAPI_ACC_DOCUMENT_POST without changing the config? Thanks.

Regards,

Ryan

Read only

0 Likes
2,075

Hi Ryan,

Please find the code attached for the BAPI. I found it working

 LOOP AT t_hold INTO g_hold.
*------------------Document Header
    g_hold_copy = g_hold.

    CLEAR ls_documentheader.

    p_bukrs  = g_hold-bukrs.
    p_date   = g_hold-pstng_date.
    p_pdate  = g_hold-pstng_date.
    p_dtype  = g_hold-doc_type.
    gv_xblnr = g_hold-ref_doc_no.

    AT NEW kunnr.
      CLEAR: lt_currencyamount,
               lt_accountreceivable,
               lt_accountgl.

      ls_documentheader-bus_act    = 'RFBU'.
      ls_documentheader-username   = sy-uname.
      ls_documentheader-comp_code  = p_bukrs.
      ls_documentheader-doc_date   = p_date.
      ls_documentheader-pstng_date = p_pdate.
      ls_documentheader-doc_type   = p_dtype.
      ls_documentheader-ref_doc_no = gv_xblnr.

*-----------------------GL Account
    ENDAT.

    AT END OF kunnr.

      CLEAR ls_accountgl.

      ls_accountgl-itemno_acc = g_hold_copy-pstkey_gl.
      ls_accountgl-gl_account = g_hold_copy-gl_account.
      ls_accountgl-costcenter  = g_hold_copy-costcenter.
      ls_accountgl-tax_code = g_hold_copy-tax_code.
      ls_accountreceivable-item_text  = g_hold_copy-line_text.
*
      APPEND ls_accountgl TO lt_accountgl.

      lv_total_value = g_hold_copy-glamount.
      lv_value = lv_total_value * -1.

      WRITE lv_value TO lv_value_char
          CURRENCY 'NZD'.

      SHIFT lv_value_char LEFT DELETING LEADING space.


      ls_currencyamount-itemno_acc = g_hold_copy-pstkey_gl.
      ls_currencyamount-curr_type  = '00'.
      ls_currencyamount-currency   = 'NZD' .
      ls_currencyamount-amt_doccur = lv_value_char.

      APPEND ls_currencyamount TO lt_currencyamount.

*----------------------Account Receivable

      CLEAR ls_accountreceivable.

      ls_accountreceivable-itemno_acc = g_hold_copy-pstkey.
      ls_accountreceivable-customer   = g_hold_copy-kunnr.
      ls_accountreceivable-item_text  = g_hold_copy-line_text.
      ls_accountreceivable-pmnttrms   = g_hold_copy-zterm.

      APPEND ls_accountreceivable TO lt_accountreceivable.


*-------------------------------------------------

      CLEAR ls_currencyamount.

      ls_currencyamount-itemno_acc = g_hold_copy-pstkey.
      ls_currencyamount-curr_type  = '00'.
      ls_currencyamount-amt_doccur = g_hold_copy-amount.
      ls_currencyamount-currency  = 'NZD'.

      APPEND ls_currencyamount TO lt_currencyamount.

*-----------------------Calling BAPI


      CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
        EXPORTING
          documentheader    = ls_documentheader
        TABLES
          accountgl         = lt_accountgl
          accountreceivable = lt_accountreceivable
          currencyamount    = lt_currencyamount
          return            = lt_return.

      READ TABLE lt_return INTO ls_return
        WITH KEY type   = 'S'
                 id     = 'RW'
                 number = 605.
      IF sy-subrc EQ 0.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

*      ELSE.
*        lv_error = 'X'.
*
*        EXIT.
      ENDIF.
    ENDAT.

Rgds,

Raj

Read only

0 Likes
2,075

Hi,

Why dont you record BDC for FB01 if you are having problems with the BAPI?

Can user post a/c docs without specifying assets in FB01? If yes, then no need of changing any config.

Also check FM's under Function group AMFA, and see if they fulfil your requirement.

Regards,

Amit

Read only

0 Likes
2,075

Hi,

Have same requirement to post asset document with this BAPI, did you got solution?
We are also getting 2 errors, This G.l is not defined in chart of accounts or this G.l can not be posted directly, both is incorrect erros for asset posting.

Read only

brahim_homri
Discoverer
0 Likes
1,395

How did you solve it please ?