Some pricing logic can be shared across multiple price plan. A simple example is the logic to derive the Country Name from the Number Dialed. This logic can be encapsulated and used by many Charges. Here in SAP CC we can use the Pricing Macro object to provide re-usable function.
- Similar to a sub-routine (ABAP)
- Can be used across multiple Charges
- Accepts specified input parameters
- Returns specified output parameters
- Can be used in two ways:
1. Macros Rating Function – Macro generates final rated amount directly
2. Macro Operator – Macro performs some logic and results are returned to calling price plan for further computation.
Let’s create a Pricing Macro that will take a phone number, look at it’s prefix and return the name of the country associated to the prefix. Prefix +61 for Australia, +33 for France and +1 for US of A.
Create a new Pricing Macro. Select File ->New Pricing Macro
Set up the input and output parameters of the pricing macro
- Rating context properties: Phone Number (string) <- similar to your import parameter in your sub-routine
- Generated properties: County Name <-similar to your export parameter in your sub-routine
Add a Prefix Switching component into the macro to check prefixes +33, +61 and +1
At the Prefix Switching Definition, Change the Property Name to ‘Phone Number’. The property ‘Phone Number’ is inherited from the Pricing Macro’s Rating Context Properties.
Add the Output Property Updates to each branch in your logic. Set the value to the appropriate country.
We have earlier defined the exporting parameter ‘Country Name’ at the ‘Generated properties’ view of the Pricing Macro’s definition. In the Output Property Component, when the prefix is +33, we assign the value of this parameter to France.
Add a ‘Free’ rating component to each branch.
Repeat the steps with the rest of the prefixes.
Let’s go ahead and execute the Trial Run Price Plan.
Enter +61 as the value of the input property Phone Number. Then click the Start button that looks like a play symbol on the top left of the Rating Trial Run application. The output should be ‘Australia’. Aussie! Aussie! Aussie! Oi! Oi! Oi!
Now try it with other values and verify that the output value is correct.
Save the Pricing Macro. File->Save->In the Database
Select the Catalog T01 then Click Save.
Finally, let’s use the Pricing Macro in one of the Charge that have been created in the previous chapter.
Select the [T01]Mobile Usage Charge and click Open.
Click on the node just before the fee is calculated. Insert a Pricing Macro Operator under this branch.
Give the name of the Macro Operator as ‘Look up country name’. Choose the ‘Get country name from phone number’ Pricing Macro. Select the ‘Number Dialed’ property as the Mapping Property of the importing parameter of the Pricing Macro’s Phone Number (that’s a mouthful). Note that the property ‘Number Dialed’ comes from the CIC which is linked with the Charge.
Test the Price Plan to see the output of the Pricing Macro utilization.
Save the modified Charge in the Database.
And it’s Done…!