<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Contract Billing Plan in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807201#M1587749</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can update billing plan using following Function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; UPDATE Billing Plan
*&amp;amp;---------------------------------------------------------------------*

 i_bapi_view-header = 'X'.
    i_bapi_view-item = 'X'.
    i_bapi_view-partner = 'X'.
    i_bapi_view-contract = 'X'.
    i_bapi_view-sdcond = 'X'.
    i_bapi_view-sdcond_add = 'X'.
    i_bapi_view-billplan = 'X'.
    i_bapi_view-configure = 'X'.
    sales_documents-vbeln = v_order.
    APPEND sales_documents.

    CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
      EXPORTING
        i_bapi_view            = i_bapi_view
      TABLES
        sales_documents        = sales_documents
        order_headers_out      = order_headers_out
        order_items_out        = order_items_out
        order_contracts_out    = order_contracts_out
        order_billingplans_out = order_billingplans_out
        order_billingdates_out = order_billingdates_out
        order_partners_out     = order_partners_out
        order_conditions_out   = order_conditions_out.


    LOOP AT order_billingplans_out WHERE itm_number = '000000'.
      hfplnr = order_billingplans_out-bill_plan.
    ENDLOOP.

    LOOP AT tab WHERE kbetr IS NOT INITIAL.
      LOOP AT order_conditions_out WHERE itm_number = tab-itm_number
                                   AND cond_type = 'ZZRE'.

        MOVE-CORRESPONDING order_conditions_out TO cond_ch.
        IF order_conditions_out-cond_type = 'ZZRE'.
          cond_ch-cond_value = tab-kbetr.
          APPEND cond_ch.
        ENDIF.
      ENDLOOP.
    ENDLOOP.


* 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'. "--&amp;gt; UPDATE!!
    APPEND hfpla2.
    CLEAR pos.
    CALL FUNCTION 'BILLING_SCHEDULE_SAVE'
      TABLES
        fpla_new = hfpla2
        fpla_old = hfpla
        fplt_new = hfplt " --&amp;gt; NEW
        fplt_old = hfplt.

    CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'
      EXPORTING
        i_no_messages = ' '.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; END OF UPDATE Billing Plan Header level
*&amp;amp;---------------------------------------------------------------------*

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; UPDATE Billing Plan Item  level
*&amp;amp;---------------------------------------------------------------------*

    LOOP AT zbill.
      MOVE v_order TO doc .
      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'. "--&amp;gt; UPDATE!!

      APPEND zfpla2.
    ENDLOOP.
    CLEAR pos.
    CALL FUNCTION 'BILLING_SCHEDULE_SAVE'
      TABLES
        fpla_new = zfpla2
        fpla_old = zfpla
        fplt_new = zfplt " --&amp;gt; NEW
        fplt_old = zfplt.

    CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'
      EXPORTING
        i_no_messages = ' '.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Krupaji on Apr 9, 2011 7:21 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 Apr 2011 05:20:26 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-04-09T05:20:26Z</dc:date>
    <item>
      <title>Contract Billing Plan</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807200#M1587748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using VA42, I have to create the Billing Plan for contract line items.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I find many Function Modules and BAPIs to update the existing Billing Plan for the contract line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea about how to create one? Any BAPI/FM?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pranu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2011 19:40:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807200#M1587748</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-04-08T19:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Contract Billing Plan</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807201#M1587749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can update billing plan using following Function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; UPDATE Billing Plan
*&amp;amp;---------------------------------------------------------------------*

 i_bapi_view-header = 'X'.
    i_bapi_view-item = 'X'.
    i_bapi_view-partner = 'X'.
    i_bapi_view-contract = 'X'.
    i_bapi_view-sdcond = 'X'.
    i_bapi_view-sdcond_add = 'X'.
    i_bapi_view-billplan = 'X'.
    i_bapi_view-configure = 'X'.
    sales_documents-vbeln = v_order.
    APPEND sales_documents.

    CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
      EXPORTING
        i_bapi_view            = i_bapi_view
      TABLES
        sales_documents        = sales_documents
        order_headers_out      = order_headers_out
        order_items_out        = order_items_out
        order_contracts_out    = order_contracts_out
        order_billingplans_out = order_billingplans_out
        order_billingdates_out = order_billingdates_out
        order_partners_out     = order_partners_out
        order_conditions_out   = order_conditions_out.


    LOOP AT order_billingplans_out WHERE itm_number = '000000'.
      hfplnr = order_billingplans_out-bill_plan.
    ENDLOOP.

    LOOP AT tab WHERE kbetr IS NOT INITIAL.
      LOOP AT order_conditions_out WHERE itm_number = tab-itm_number
                                   AND cond_type = 'ZZRE'.

        MOVE-CORRESPONDING order_conditions_out TO cond_ch.
        IF order_conditions_out-cond_type = 'ZZRE'.
          cond_ch-cond_value = tab-kbetr.
          APPEND cond_ch.
        ENDIF.
      ENDLOOP.
    ENDLOOP.


* 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'. "--&amp;gt; UPDATE!!
    APPEND hfpla2.
    CLEAR pos.
    CALL FUNCTION 'BILLING_SCHEDULE_SAVE'
      TABLES
        fpla_new = hfpla2
        fpla_old = hfpla
        fplt_new = hfplt " --&amp;gt; NEW
        fplt_old = hfplt.

    CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'
      EXPORTING
        i_no_messages = ' '.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; END OF UPDATE Billing Plan Header level
*&amp;amp;---------------------------------------------------------------------*

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; UPDATE Billing Plan Item  level
*&amp;amp;---------------------------------------------------------------------*

    LOOP AT zbill.
      MOVE v_order TO doc .
      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'. "--&amp;gt; UPDATE!!

      APPEND zfpla2.
    ENDLOOP.
    CLEAR pos.
    CALL FUNCTION 'BILLING_SCHEDULE_SAVE'
      TABLES
        fpla_new = zfpla2
        fpla_old = zfpla
        fplt_new = zfplt " --&amp;gt; NEW
        fplt_old = zfplt.

    CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'
      EXPORTING
        i_no_messages = ' '.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Krupaji on Apr 9, 2011 7:21 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Apr 2011 05:20:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807201#M1587749</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-04-09T05:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Contract Billing Plan</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807202#M1587750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know I can update. Thanks.&lt;/P&gt;&lt;P&gt;But my question is how to create.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a conversion and cut over, the contracts are created and now I want to create the billing plans.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pranu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Apr 2011 05:24:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807202#M1587750</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-04-09T05:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: Contract Billing Plan</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807203#M1587751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;when u create contract order automatically billing plan created above code u can update billing plan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Apr 2011 06:04:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807203#M1587751</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-04-09T06:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Contract Billing Plan</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807204#M1587752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;also check following link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="2927737"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1568197"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Apr 2011 04:39:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807204#M1587752</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-04-11T04:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Contract Billing Plan</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807205#M1587753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your Function Modules will work if the Billing Plan Number is available.&lt;/P&gt;&lt;P&gt;In other words, it will update the existing Billing Plans that are present in FPLT table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the FM you gave, we have to pass the Billing Plan Number (FPLNR). FPLNR is available in VBKD.&lt;/P&gt;&lt;P&gt;This will return the Plan Details and I can edit it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What My Question is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. How to create one. &lt;/P&gt;&lt;P&gt;My contract does does not have FPLNR in VBKD and FPLT is empty. &lt;/P&gt;&lt;P&gt;I want to create the Billing Plan so that the FPLNR will be created and FPLT will be populated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Plan B for me is to run BDC but I am more intrested in FM or BAPI.&lt;/P&gt;&lt;P&gt;Any help would be appretiated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pranu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Apr 2011 20:59:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807205#M1587753</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-04-11T20:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Contract Billing Plan</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807206#M1587754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 03:14:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/contract-billing-plan/m-p/7807206#M1587754</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-11-04T03:14:43Z</dc:date>
    </item>
  </channel>
</rss>

