Fonction SAP BAPI_RPC_CALCULATE_PRICES - Request Calculations and Adjust Requested Calculations

Paramètre Reférence Type Long. Valeur par déf. Facultatif Description
RPCCONTROLIN BAPIRPCCONTROL u 16 X Control Sales Price Calulation for BAPI

Paramètre Reférence Long. Facultatif Description
CALCITEMIN BAPICALCITEMIN 385 BAPI Structure for Pricing Item (Import)
CALCITEMINX BAPICALCITEMINX 163 X Change BAPI Reference Structure for Structure BAPICALCITEMIN
CALCITEMOUT BAPICALCITEMOUT 641 BAPI Structure for Pricing Item (Export)
EXTENSIONIN BAPIPAREX 990 X Reference Structure for BAPI Parameters EXTENSIONIN/EXTENSIONOUT
EXTENSIONOUT BAPIPAREX 990 X Reference Structure for BAPI Parameters EXTENSIONIN/EXTENSIONOUT
RETURN BAPIRET2 548 Return parameter

Functionality
This BAPI, or the CalculatePrices method in the RetailPricing
business object, facilitates communication between the sales pricecalculation function of the SAP System and one or more external systems.
You can use this BAPI to request and adjust calculations in externalsystems:

  • Requesting a Pricing Item

  • Every pricing item required must be requested precisely once using thisBAPI. Requesting a pricing item causes the system to suggest all therelevant pricing data (such as markup, margins and sales prices, forexample).
    • Adjusting a Requested Pricing Item

    • If the pricing items requested do not meet your expectations - forexample, if the sales price suggested by the system is either too highor too low, the pricing item can be adjusted using this BAPI.
      Depending on whether a calculation is to be requested or whether arequested calculation is to be adjusted, the interface tables CALCITEMINand CALCITEMINX can be filled in different ways. You will find furtherinformation on this in the documentation for the individual tables.
      Results of the Calculation
      Each time the BAPI is called up, the result of the calculation isentered in the CALCITEMOUT export table. Any errors that may haveoccured are displayed in the RETURN export table. You will find furtherinformation in the interface documentation for the relevant tables.
      Customer-Specific Enhancements
      Further fields that are not contained in the CALCITEMIN, CALCITEMINX orCALCITEMOUT interface tables can be entered using the enhancement tablesEXTENSIONIN and EXTENSIONOUT and the BAPI. You can find furtherinformation on this in the interface documentation for the individualtables.

      Example
      A dialog for calculating store-specific sales prices is to be created inan external system. A store, a quantity of articles and a validityperiod for the calculation (required fields) are to be entered in aninitial screen. The system should then suggest the appropriate pricingitems in a subsequent screen. The suggested final price should be thesame as the current valid final price.
      The data entered in the initial screen should be transferred to the BAPIusing table CALCITEMIN (see "Pricing key" below). For the final price tobe suggested in the way described above, the VKERV field must containthe value "02". When the BAPI is called up this time, the CALCITEMINXtable does not have to be filled as pricing items have only beenrequested. Once the BAPI has been called up, the calculations requestedare to be found in the CALCITEMOUT export table.
      Users should be able to enter the prices suggested on the subsequentscreen interactively. After each change the changed pricing items shouldbe adjusted (markup, margins, and so on).
      To do this, the contents of the fields must be transferred to theCALCITEMIN table along with the pricing key. The changed fields are alsoto be marked in the CALCITEMINX table, using the pricing key to ensurethat the items are unambiguously assigned. When the BAPI is called up,the adjusted pricing items are displayed in the CALCITEMOUT exporttable.

      Notes
      Pricing key
      Pricing items are identified using the logical key:

      • Sales_Org

      • Distr_Chan

      • Plant

      • Price_List

      • Material

      • Sales_Unit

      • Sales_Unit_ISO.

      • Certain fields have to be filled, depending on the level at which thecalculation is to be performed. You will find details of this in theinterface documentation on table CALCITEMIN.
        Initialization
        Every time you call module BAPI_RPC_CALCULATE_PRICES, a series of datais saved and adjusted in the main memory of different function groups inthe receiving SAP system. You can use moduleBAPI_RPC_REFRESH_CALCULATIONS to keep the calling system independent ofthe inner status of the function groups mentioned above. For moredetails, see the documentation on the individual modules.

        Description
        The (obligatory) import table CALCITEMIN is used to transfer the datafrom the items to be calculated to the BAPI.

        Value range
        For every entry in the CALCITEMIN table, it must be clear whether thepricing item has been requested or whether the pricing item is to beadjusted.
        Requesting a Pricing Item
        Every pricing item that is required must be requested precisely onceusing this BAPI. Requesting a pricing item means that the systemproposes all the relevant pricing data (such as markup, margins andsales prices, for example).
        In a request of this type, the following pricing key must be filled:

        • Sales_Org

        • Distr_Chain

        • Plant

        • Price_List

        • Material

        • Sales_Unit

        • Sales_Unit_ISO

        • You can use this pricing key to uniquely identify a pricing item at anytime.
          You should note the following when filling in the key fields. Dependingon the organizational level at which the calculation is to beperformed, certain fields must be filled and certain fields must beleft blank. The following table provides an overview: (the fields thatmust contain an entry are marked with an "X", while the fields thatmust be left blank are marked with "_".)
          ------------------------------------------------------------------------
          Pricing level,,Sales_Org,,Distr_Chain,,Plant,,Price_List
          Distribution chain ,,X ,,X ,,_ ,,_
          Plant ,,X ,,X ,,X ,,_
          Price list ,,X ,,X ,,_ ,,X
          ------------------------------------------------------------------------
          Furthermore, the following basic data must be entered when requesting apricing item:
          • SP_Valid_From

          • SP_Valid_To

          • Sales_P_Unit

          • PP_Determ_Sequence

          • SP_Determ_Sequence

          • Adjusting a Requested Pricing Item
            If the pricing item requested does not meet your expectations, forexample, if the sales price suggested by the system is too high or toolow, you can use this BAPI to adjust the pricing item.
            When you adjust the requested calculation, you also need to fill thepricing key described above. Additionally, the changed data can beentered in the appropriate fields. For all price fields, the relevantcurrency (either in SAP notation or ISO norm) must be entered. Thefollowing table provides an overview of which currency fields must beentered for which price fields.
            ------------------------------------------------------------------------
            Price Field ,,Crcy Field,,Crcy Field (ISO)
            Basic_Purchase_Price ,,Purch_Currency ,,Purch_Currency _ISO
            Net_Net_Purchase_Price,,Pricing_Currency,,Pricing_Currency_ISO
            Net_Sales_Price ,,Pricing_Currency,,Pricing_Currency _ISO
            Gross_Sales_Price ,,Pricing_Currency,,Pricing_Currency _ISO
            Final_Price ,,Sales_Currency ,,Sales_Currency _ISO
            ------------------------------------------------------------------------
            Caution: The changed fields must also be marked in the relevantcheckboxes of the CALCITEMINX change table.
            Caution: In order for a requested or adjusted calculation to beposted to the database, the SP_Marked_For_Activation indicator must beset. As this indicator is blank for a requested calculation (defaultvalue), it must be adjusted for the calculation to be posted. Theindicator can be reversed again when the BAPI is called up again - thelast status before a Commit Work is the definitive one.

            Description
            The (optional) import table CALCITEMINX transfers the changeinformation from the items to be calculated to the BAPI.

            Value range
            When you adjust a requested pricing item, the changed data istransferred in the CALCITEMINX import table. The changed fields mustalso be flagged in the relevant checkboxes of the CALCITEMINX importtable.

            Description
            The (obligatory) export table CALCITEMOUT displays all the relevantpricing data for the calculated items from the BAPI.

            Value range
            The pricing data displayed in the CALCITEMOUT table can be divided upinto different sections:
            Pricing key
            The following pricing key is also used with the CALCITEMOUT table touniquely identify a pricing item:

            • Sales_Org

            • Distr_Chan

            • Plant

            • Price_List

            • Material

            • Sales_Unit

            • Sales_Unit_ISO.

            • Adjustable fields
              When you adjust a requested calculation, you can change the fields ofthe CALCITEMIN import table. All the fields in the CALCITEMIN table arealso found in the CALCITEMOUT export table. This ensures that the usercalling up the BAPI receives consistent data. A change in the"Final_Price" in the CALCITEMIN table can thus, for example, lead tochanges in the "Current_Markup", "Net_margin" and "Gross_Margin".
              The fields for this section are:
              • SP_Valid_From

              • SP_Valid_To

              • Sales_P_Unit

              • PP_Determ_Sequence

              • SP_Determ_Sequence

              • Purch_Org

              • Vendor

              • ....

              • ....

              • Net_Sales_Price

              • Gross_Sales_Price

              • Sales_Currency

              • Sales_Currency_ISO

              • Final_Price

              • Net_Margin

              • Gross_Margin

              • SP_Marked_For_Activation

              • Information fields
                Addditional information on article qualities, purchasing and sales-sideprice determination, and data on the current valid sales price are alldisplayed in this section.
                • Matl_Group

                • Matl_Cat

                • Pr_Ref_Mat

                • Price_Fixing

                • PP_Determ_Type

                • SP_Determ_Type

                • Planned_Markup

                • Pricing_Level

                • Current_Sales_Price

                • Current_Pricing_Level

                • Current_SP_Valid_From

                • Current_SP_Valid_To

                • Current_Net_Margin

                • Current_Gross_Margin
                • Description
                  You can use the (optional) import table EXTENSIONIN to transferadditional data from the items for which calculations are to beperformed to the BAPI without having to alter the BAPI interface.

                  Value range
                  The data fields that are to be transferred to the BAPI must first beintegrated into structure BAPI_TE_CALP_IN or BAPI_TE_CALP_INX. Onlyfields from the CALP structure are supported in the BAPI_TE_CALP_INstructure, however, and only fields from the CALP_INX structure aresupported in the BAPI_TE_CALP_INX structure.
                  You can use the EXTENSIONIN import table to make the appropriateentries in these fields.

                  Example
                  In distribution chain 0001/01, material R00001 (unit of measure PC) hasa cash price of 10.00 USD. The corresponding data must be transferredto the BAPI (internal field CALP-MITPR or CALP_INX-MITPR_INX).
                  To do this, proceed as follows:

                  • In the Dictionary, structure BAPI_TE_CALP_IN must be extended to
                  • include the field MITPR (data element MITPR, reference table CALP,reference field VWAER) and structure BAPI_TE_CALP_INX must be extendedto include MITPR_INX (data element BAPIUPDATE).
                    • Before calling up the BAPI, two entries must be made in the extension
                    • table EXTENSIONIN.
                      If the formal and current extension tables have the same name, this canbe done using the following coding:
                      DATA: I_BAPI_TE_CALP_IN LIKE BAPI_TE_CALP_IN,
                      I_BAPI_TE_CALP_INX LIKE BAPI_TE_CALP_INX.
                      CONSTANTS: OFFSET TYPE I VALUE 30.
                      I_BAPI_TE_CALP_IN-SALES_ORG = '0001'.
                      I_BAPI_TE_CALP_IN-DISTR_CHAN = '01'.
                      I_BAPI_TE_CALP_IN-MATERIAL = 'R100001'.
                      I_BAPI_TE_CALP_IN-SALES_UNIT = 'ST'.
                      I_BAPI_TE_CALP_IN-MITPR = '10.00'.
                      CLEAR EXTENSIONIN.
                      EXTENSIONIN-STRUCTURE = 'BAPI_TE_CALP_IN'.
                      CATCH SYSTEM-EXCEPTIONS CONVERSION_ERRORS = 1.
                      MOVE I_BAPI_TE_CALP_IN TO EXTENSIONIN+OFFSET.
                      ENDCATCH.
                      APPEND EXTENSIONIN.
                      I_BAPI_TE_CALP_INX-SALES_ORG = '0001'.
                      I_BAPI_TE_CALP_INX-DISTR_CHAN = '01'.
                      I_BAPI_TE_CALP_INX-MATERIAL = 'R100001'.
                      I_BAPI_TE_CALP_INX-SALES_UNIT = 'ST'.
                      I_BAPI_TE_CALP_INX-MITPR_INX = 'X'.
                      CLEAR EXTENSIONIN.
                      EXTENSIONIN-STRUCTURE = 'BAPI_TE_CALP_INX'.
                      CATCH SYSTEM-EXCEPTIONS CONVERSION_ERRORS = 1.
                      MOVE I_BAPI_TE_CALP_INX TO EXTENSIONIN+OFFSET.
                      ENDCATCH.
                      APPEND EXTENSIONIN.
                      You can also use the RFC-capable function moduleBAPI_TE_CALP_IN_2_EXTENSIONIN to fill the EXTENSIONIN table.
                      Once the BAPI has been called up, the first entry in the EXTENSIONINtable causes the value "10.00" to be transferred to the MITPR field ofthe (internal) CALP structure. The second entry causes the value "X" tobe transferred to the MITPR_INX field of the (internal) CALP_INXstructure.

                      Description
                      You can use the (optional) export table EXTENSIONOUT to displayadditional data on the calculated items from the BAPI, without makingany changes to the BAPI interface.

                      Value range
                      The data fields that are to be displayed from the BAPI must first beincluded in the BAPI_TE_CALP_OUT structure. Only those fields that alsooccur in the CALP structure are supported, however.
                      You can use the EXTENSIONOUT extension table to read the content ofthese fields using algorithms.

                      Example
                      The program that calls up the BAPI should read and further process thereference plant (internal field CALP-VLGWK) that was used to performthe calculation.
                      To do this, proceed as follows:

                      • In the Dictionary, structure BAPI_TE_CALP_OUT must be extended to
                      • include field VLGWK (data element VLGWK).
                        • When the BAPI has been called up, an entry is made in the extension
                        • table EXTENSIONOUT for each pricing item. You can use the followingcode to make these entries easier to read (assuming that the formal andcurrent extension tables have the same name):
                          DATA: T_BAPI_TE_CALP_OUT LIKE BAPI_TE_CALP_OUT OCCURS 0 WITH HEADERLINE.
                          CONSTANTS: OFFSET TYPE I VALUE 30.
                          LOOP AT EXTENSIONOUT WHERE STRUCTURE EQ 'BAPI_TE_CALP_OUT'.
                          CLEAR T_BAPI_TE_CALP_OUT.
                          CATCH SYSTEM-EXCEPTIONS CONVERSION_ERRORS = 1.
                          MOVE EXTENSIONOUT+OFFSET TO T_BAPI_TE_CALP_OUT.
                          ENDCATCH.
                          APPEND T_BAPI_TE_CALP_OUT.
                          ENDLOOP.
                          The RFC-capable function module EXTENSIONOUT_2_BAPI_TE_CALP_O can alsobe used to fill the T_BAPI_TE_CALP_OUT table.

                          Description
                          This obligatory export table contains the event and error logs fromcalling up the method.

                          Value range
                          A number of different error messages are possible, which are notdescribed here.
                          If errors occur when using the method, the obligatory "RETURN" table isfilled. If the method is run successfully, the corresponding eventmessage is returned in the "RETURN" table.