Skip to Content
0
May 25, 2018 at 03:30 AM

Auto calculate Discount Base Amount in BAPI_ACC_DOCUMENT_POST

765 Views

Hello,

I am trying to find an answer for this question in the blog. I could not get any apt answer for the same, hence posting here. I am using BAPI_ACC_DOCUMENT_POST to post accounting document. Everything works fine. But system doesn't auto calculate the discount base. I am providing the payment terms,baseline date and discount days,percentage to the table ACCOUNTPAYABLE. The field BSEG-SKFBT is saving with zero amount in the document.What should I pass to make the system calculate discount amount. Please share your ideas.

        IF <fs_tbsl>-koart = 'K'.

          w_acpay-itemno_acc = lv_item.

          w_acpay-vendor_no = <fs_file>-hkont.

          PERFORM format_input CHANGING w_acpay-vendor_no.

          PERFORM format_date CHANGING : <fs_file>-zfbdt.

          w_acpay-ref_key_1 = <fs_file>-xref1.

          w_acpay-ref_key_2 = <fs_file>-xref2.

          IF <fs_file>-zterm IS INITIAL.

*            IF <fs_tbsl>-shkzg = 'H'.

*              w_acpay-pmnttrms =  '*'.      "NOTE 2540399

            SELECT SINGLE zterm FROM lfb1 INTO w_acpay-pmnttrms WHERE 
lifnr = w_acpay-vendor_no AND
bukrs = ls_head-comp_code.


*            ENDIF.

          ELSE.
            w_acpay-pmnttrms = <fs_file>-zterm.

          ENDIF.

          w_acpay-item_text = <fs_file>-sgtxt.

          w_acpay-alloc_nmbr = <fs_file>-zuonr.

          w_acpay-tax_code = <fs_file>-mwskz.

          IF <fs_file>-zfbdt IS INITIAL.

            CALL FUNCTION 'FI_TERMS_OF_PAYMENT_PROPOSE'

              EXPORTING

                i_bldat         = ls_head-doc_date

                i_budat         = ls_head-pstng_date

                i_zterm         = w_acpay-pmnttrms

                i_lifnr         = w_acpay-vendor_no

                i_bukrs         = ls_head-comp_code

              IMPORTING

                e_zbd1t         = w_acpay-dsct_days1

                e_zbd1p         = w_acpay-dsct_pct1

                e_zbd2t         = w_acpay-dsct_days2

                e_zbd2p         = w_acpay-dsct_pct2

                e_zbd3t         = w_acpay-netterms

                e_zfbdt         = w_acpay-bline_date

              EXCEPTIONS

                terms_not_found = 1

                OTHERS          = 2.

          ELSE.

            w_acpay-bline_date = <fs_file>-zfbdt.

          ENDIF.

*        w_acpay-pymt_cur = <fs_file>-waers.

          APPEND w_acpay TO it_accountpayable.
ENDIF.

Regards,

Priyanka.