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

Billing schedule Dates using a BAPI/FM for a sales order line

Hello,

I am trying to update a sales order line with an Item category which inturn updates the Billing Plan.

I am able to update the sales order with required details and the default billing plan.

Now I want to change the Billing schedule i.e the Billing Plan dates Invoice end date and the percantage etc whcih I am trying to do using

SD_ORDER_BILLING_SCHEDULE AND BILLING_SCHEDULE_MAINTAIN AND THEN BILLING_SCHEDULE_SAVE.

This for some reason will not update the Billing schedule.

It triggers the user exists etc but even though I pass all the required details in the Old and new FPLA and FPLT tables...it is not helping.

When I tried using BILLING_SCHEDULE_DIALOG it opens the screen with the Billing plan in edit mode.

Is there any other way to do the updates.I tried changing in the User exist etc. I also checked the program sdfpla02.

Many thanks,

Krishna.

Edited by: Krishna on Mar 21, 2011 8:30 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Mar 22, 2011 at 06:35 AM

    See the following example

    * Read the billing plan
        CALL FUNCTION 'BILLING_SCHEDULE_READ'
          EXPORTING
            fplnr = hfplnr
          TABLES
            zfpla = hfpla
            zfplt = hfplt.
        MOVE hfpla TO hfpla2.
    *READ TABLE zfpla2 INDEX 1.
        hfpla2-lodat = p_stat.
        hfpla2-tndat = p_end.
        hfpla2-rfpln = ''.
        hfpla2-lodar = ''.
        hfpla2-tndar = ''.
        hfpla2-fpart = p_bplan.
        hfpla2-perio = p_bplan.
        hfpla2-horiz = p_hori.
    *** Very important to set field updkz = 'U' ***
        hfpla2-updkz = 'U'. "--> UPDATE!!
        APPEND hfpla2.
        CLEAR pos.
        CALL FUNCTION 'BILLING_SCHEDULE_SAVE'
          TABLES
            fpla_new = hfpla2
            fpla_old = hfpla
            fplt_new = hfplt " --> NEW
            fplt_old = hfplt.
    
        CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'
          EXPORTING
            i_no_messages = ' '.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait = 'X'.
    
     CALL FUNCTION 'SD_SALES_DOCUMENT_READ'
            EXPORTING
              document_number = doc.
    
          MOVE zbill-itm_number TO pos.
    
          CALL FUNCTION 'SD_SALES_BILLINGPLAN_READ'
            EXPORTING
              i_vbeln                = doc
              i_posnr                = pos
            IMPORTING
              e_fpla                 = e_fpla
            TABLES
              e_fplt                 = e_fplt
            EXCEPTIONS
              no_billingplan_allowed = 1
              no_billingplan_found   = 2
              OTHERS                 = 3.
    
          IF sy-subrc NE 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    
    * Read the billing plan
          CALL FUNCTION 'BILLING_SCHEDULE_READ'
          EXPORTING
          fplnr = e_fpla-fplnr
    * I_VFKDAT =
    * I_BFKDAT =
          TABLES
          zfpla = zfpla
          zfplt = zfplt.
    
    * Upddate the ZFPLT2 table with the new values
    *MOVE zfplt TO zfplt2.
          MOVE zfpla TO zfpla2.
    
    *READ TABLE zfpla2 INDEX 1.
          zfpla2-lodat = zbill-datesfrom.
          zfpla2-tndat = zbill-datesto.
          zfpla2-rfpln = ''.
          zfpla2-lodar = ''.
          zfpla2-tndar = ''.
          zfpla2-fpart = p_bplan.
          zfpla2-horiz = p_hori.
    *** Very important to set field updkz = 'U' ***
          zfpla2-updkz = 'U'. "--> UPDATE!!
    
          APPEND zfpla2.
        ENDLOOP.
        CLEAR pos.
        CALL FUNCTION 'BILLING_SCHEDULE_SAVE'
          TABLES
            fpla_new = zfpla2
            fpla_old = zfpla
            fplt_new = zfplt " --> NEW
            fplt_old = zfplt.
    
        CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'
          EXPORTING
            i_no_messages = ' '.
    
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait = 'X'.
    *-
    

    Add a comment
    10|10000 characters needed characters exceeded

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.