Skip to Content

Template Allocations. Other alternative to post Activities

Hi Friends!  I was looking for a topic that no much info is post on the internet and found interesting write about Template Allocation.

Im going to share a  example of what you can do with Templates. The topic is huge and you can find lot info in SAP Help or in the ABC Costing academy course… this is just an appetizer, in order to kwow a bit of this functionality.

The basic:

There are lots ways to post a activity to a receiver (I guess you understand the concept of a sender and a receiver, and also know what is an activity type and how to plan), Examples are PP/PM/PS Notifications, KB21N from CO, CATS (I love cats!), indirect activity allocations or with bapi BAPI_ACC_ACTIVITY_ALLOC_POST.

Imaginary scenario:

PP Work Center have a max of 6 activities to post. Lot of companies say this is to few (well in PM/PS system thees only have 1, i dont understand why, but this is not our topic). Imagine you want to post aditional activities at PeriodEndClosing. Imagine your key user want to post 2 activities, 1 based on the ActualScrap of the PP Order and other based in a activity PP Boys post to the order with CO11N (yep, 6 are not enough).

If you analize carefully all the  options i mention, non of them can accomplish the desired behavior (Well the ZBAPI can do whatever).

*** PS. the indirect activity allocation cant face the requirement of post based in actual activity posted on the PP Order. If you want to validate, go on!

The Customizing

1. I create a Template (tcode CPT2), that have 2 records>

01 Template.jpg


– Type: Represent what the row of the template is going to do. In my example, post activity from cost center.

– Object: Refer to the type, in this case the Sender CostCenter/Activity Type. In this example, is static but we can change it dynamically.

– Actual Quantity: the way the template calculate the actual QTY we will post to the reciever object, in our scenario a PP Order.

+ The 1st line post from the cost center 6000_PP001 with the activity PP0001 (Column Object) to the Reciever Order Based on the actual scrap posted

In order to do that, i use the standard method “OrderHeaderScrapQtyConfirm” that calculate the value. No abap code needed for this. This TemplateFunction do all the hard work!!

+ The 2nd line post from the cost center 6000_PP001 with the activity PP0002 to the Reciever Order, based on the actual quantity of the activity type ‘PP0000’ previosly posted to the PP Order (PP boys post this activvity wth CO11N) , activity ‘PP0000’  was posted from cost center “6000_PP001”.

In order to do this, i create a template function “ZAllocatedActualQtyOrder01” as a copy of standard TemplateFunction “AllocatedActualQtyObjects” and did few changes (2 aditional variables, and 1 line of code).  I did because the standard Function dont accomplish exactly what i want. The message here is I spend less than 10 minutes modifying the function, OK i know the function and also i did by my self so i dont need to tell a abap, give a specification and all the typical stuff necesary for a requirement but this is 1000 times easier and faster than create a ztcode from the scratch).

02 Zfunction.jpg

You specify the parameters that enter to the function. In this case, i set HardCode the Activity Type, but the cost center is a parameter {SenderCostCenter} and as you can imagine refer to the cost center in the column {Object} of the template, in our case “6000_PP001”

2. Create all the overhead stuff and assign to the PP Order. In tcode KTPF assing the Template to the Controlling Area / CostingSheet/Overhead Key/Enviroment. This is the only difference with the classical Overhead customizing .

* there are lot of info of overhead on the internet, so im not going to explain this custo.

03 ktpf.jpg

The Master Data  (No details, there are lot of info about this on the internet)

+ Create Activity, CostElements for activity Posting, Plan the activity in the cost center, and more…

+ Create a New Material FERT. Assing a OverheadGroup. This is our link to the template.

06 MaterialMaster.jpg

+ Create a WorkCenter

+ Create BOM, Routing,

+ Create PP Order, Post Activity and Scrap.

The Template in action:

1. Check the PP Order. You can see the actual activity qty PP0000 is 10.

05 PP Order Activ p000.jpg

2. Also In the next screen you can see the actual Scrap “15” posted to the PP Order.

04 Scrap.jpg

I run the Template Allocation Posting (tcode CPTA )

07 cpta.jpg

System post activity pp0001 with qty = 15 = The confirmed scrap in the pp order and pp0002 with qty = 10 = the actual post of activity pp0000.

08 cpta 2.jpg

Now you check the PP Order Cost and find the activity pp0001 and PP0002 posted with the template

09 PP OrderCost.jpg

What do you think?

The template use TemplateFunctions, assigned to a ABAP function. You can copy and modify the standard functions. In tcode CTU6 you can see all the available standard functions.

10 ctu6.jpg

PS. I spend about 4hours doing the custo and creating the master data from the scratch, taking the screenshots and writing here .. Copy a standard funcion minimize the abap effort.


You must be Logged on to comment or reply to a post.
  • Hi Arturo

    In India, we say, "Gaagar mein (Pronounced as may) Saagar", literally meaning "Filling the Sea in a Pot", which means summarizing a lengthy concept in a crisp summarized form - What I often call as KISS - Keep Info Short & Specific

    Your work is no short than that!!

    Few observations / questions from me.

    1. One correction, I think, you need to make is in this line.. It should be PP0000 and not PP0001

    The Template in action:

    1. Check the PP Order. You can see the actual activity qty PP0001 is 10.

    2. It is a technical need that template should be assigned to Costing sheet. The costing can be blank inside i.e. it may not have any rows in it.. If you can mention this aspect in your document, it will help people

    3. May be you can also mention that there can be rows inside the costing sheet doing their Job and over and above that the template does its job

    4. One question that I have is - what is the need of Overhead group / Overhead Key here when we are not going to have a different rate of overhead for different materials? I think it can be left blank

    5. Second and last question - Incase someone wants to charge a different rate to different materials, how can template allocation help in that?

    In Costing sheets, you can maintain say, 200 USD per Machine hr for OHKEY1 and 300 USD per Machine hr for OHKEY2 and these OHKEYS in turn refer to a group of materials.. Can the same be achieved using template allocation?

    I will be honest to say that I never used Costing sheets in my life and neither did I use Template allocations.. I preferred own workarounds.. However, in one case I developed a custom program for exactly what you explained above (PP0002).. I now feel I should have met you then πŸ™‚

    Br. Ajay M

    • Hi Ajay.

      1. Correction Done. Thank for your time reading!

      2/3. Yep, my costing sheet is blank inside and also can have lines that do their work. I have the screenshots of the costing sheet config but i decided to dont post, because this pot will become a 2liter bottle of water. LOL.

      4. With the overhead group in the material you call a overhead key. You can call various templates for the same material if the overhead gruop has varios overhead keys. Also, you can have material A that call overhead key 1 and template 1.. and Material B that call  overhead key 2 and template 02..

      5. Yes, you can. Not easy but possible. The theory is you can dinamically call the sender "cost center - activity type" in the template with a z function (all the stuff is in functions), so you can decide online if you post activity "pp_xx" or "pp_yy". Abap code is required, but not difficult.

      Aditional points:

      6. I really dont like CostingSheets, simple reason: Full Cost Absortion. I think the cost center must have credits = debits, so net to 0. With costing sheet you cant revaluate and accomplish the behavior.

      7: I learn this stuff in a upgrade (this is something i like about upgrades, learn new stuff), they post the activity based on the Confirmed Qty of the PP Order.

      PS. Thanks for your time posting, its very nice ppl that i often read and learn from give feedback!


        • Hi!. I mean, When you run the overhead in CO43 system post to the order from the cost center with the rate defined in the costing sheet. EG $1,100. System dont "see" the actual cost in the cost center.

          When Actual cost (FI invoices, HR, whatever)  fall into the cost center, this actual cost can be ($1200)  or ($900)  so ( > or <) than the overhead posted to the order ($1100).  I never see a step in Overheads that calculate "actual overhead calculation", like the activities that have actual activity calculation and order revaluation (or the revaluation in ML out of the order).

          Could you confirm this? As far as I know, this step dont exist.

          The difference between Actual cost in the cost center  ( eg $1200)  and the cost posted to the order (the overhead of $1100) is not absorved, so you must create a assesment in order to clear this 1200 - 1100 = $100, this $$ dont charge the Stock Account, directly fall into the P&L.

          This is what i mean about full cost absortion, and this is why i dont like.


      • Hi Arturo,

        Great stuff you mention here. I was thinking of doing exactly what you actually explain above and i was happy to find your doc which supports what i want to do.

        I do have 1 question regarding following:

        4. With the overhead group in the material you call a overhead key. You can call various templates for the same material if the overhead gruop has varios overhead keys. Also, you can have material A that call overhead key 1 and template 1.. and Material B that call  overhead key 2 and template 02..

        I always link Overhead group to OH Key via OKZ2 but that implies that within 1 Plant for 1 Material i can have only 1 OH Key

        Maybe i misunderstood but thought you have a way to have more than one OH Key per Material.

        => Where/how to you map 1 OH Group to more than 1 OH Key?

        Maybe i ask too much but i'm also interested in the line of code you added to create ZAllocatedActualQtyOrder01.



        • Hi Samuel.

          You are correct. Sadly, the OH gruop and the OHkey have 1-1 relation.

          About the change in the code , it was somethng related with the period of the activities.I dont have access to the system i did, but was some validations our customer want.

  • Hi..

    Thank you for your document.

    I have a question.

    To analysis the variance between standard and actual, I think that standard price have the amount and qty for activity pp0001 and pp0002.

    How do you apply the amount and qty for activity pp0001 and pp0002 to standard cost ?

    • Hi BC. Interesting question.

      In the standard Cost Estimate, you can also use a template (in my example, 6000_00001). This is just a fool example, but will give you the concept. I post to the Standard Cost the activity type PP0002 based on the number of WorkCenters in the routing (6000_TE and 6000_TE2) Qty =  2.

      ScreenHunter_03 Mar. 07 23.59.jpg

      In the template for the plan QTY, i just put the standard function  {NumberOfWorkCenters}. Again, no code required.

      ScreenHunter_03 Mar. 07 23.42.jpg

      Just a personal opinion, Maybe the standard functions don accomplish what you want but you can write your own as a copy of the standards!

  • Hi Arturo,

    Really a helpful document for me as I was seriously looking forward to have a good document on template allocation for personal preparation.



  • Hi Arturo/anyone who could explain,

    Can you explain how is the costs in the Template Allocation determined? How does it calculate/determine the Total act. costs namely 49,995 and 22,220 based on the example?

    Thank you.

    • Hi.

      Total cost  22,220 =   Hours * Activity Rate

      + Activity Rate is defined in tcode KP26

      + 10 hours: this value is calculated in the template via the formula.  (1. Check the PP Order. You can see the actual activity qty PP0000 is 10)


  • Hi

    Nice doc....but whether it is Template allocation or OH sheet every possibility of difference between cost booked in CCtr and cost absorbed in order. Only this issue can be eliminated by transferring all down the line costs of OH to production CCtr through Assessment and finally absorbed then in activity rate.....

    This my own view only....once again thanks for nice doc and effort

    • Hi Kumar,

      I don’t agree.

      The power of the Template allocation is that you can calculate the Actual Tariff for the Activity Type and thus transfer all Sender costs towards the Receiver: additional transactions in MEC areΒ KSII – Price Calculation for your CCtr/AT and CON2 to revaluate your (Production) Orders. Same procedure for IO and WBS etc.

      Very strong feature to use when you have to perform Actual Costing as legal requirement for Brazil for example: all cost are moved to the Production order and will be posted as production variance and thus be taken in to account by ML Actual Costing. In this scenario, KSII and CON2 are not even needed (depends how you setup Actual Costing)


  • Hi

    Good job! I have a question about template which is used in CK11N.

    First I wanna show you guys the correct hardcopies in Q1 system:

    (1) customizing part




    (2) Cost estimate part


    Above is correct result which is we want to get. The cost center/activity type(ZZZZ/XXXX)'s value(4min) is derived from work center YYY-123 whick is limited in the first peice hardcopy as you see.

    Now the problem is in my Q2 system, the cost center/activity type(ZZZZ/XXXX)'s value is derived from work center YYY-123 and also YYYY, so the value derived is 12min. This is not what we want. I have no idea why I have already restricted work center"YYY-123" in template customizing,but the CK11N runs both work center YYY-123 and YYYY. I am quite certain that template customizing in Q1 system and Q2 system is the same.

    Any suggestions is appreciated.

  • Hello Arturo

    This document is very good, but I have few questions from assignment view point,

    1. I have a labor activity type='Labor" and I book one hour to the service order

    2. I have another activity type = "OVHD" and I need to book another one hour to the

    service order at the month end. -If you can give little detailed input it will be helpful

    3. I need to know how these variable mentioned by you were created. Meaning that

    activity type itself is a variable. Can you help me little more how am to create the variable?