Skip to Content
Technical Articles
Author's profile photo Kimveasna Pen

[LTMOM] Extend purchasing contracts to allow scale conditions


In this post, I will describe my own experience to extend migration object “Purchasing contract” in order to allow input of condition scales.

As per SAP deliverd template, we can only enter simple conditions, without quantity nor value scales. As described in my previous post about Migration Cockpit, I will demonstrate that it is not much difficult than to use BAPI to create a contract.

Though this blog post is specific to purchasing contracts, you should apply the same approach for any migration object enhancement.

  1. Assess the current situation
  2. Understand and make BAPI work
  3. Set up mappings in LTMC
  4. Debug BAPI call in case of error


Assess the current situation

Out of the box, scales cannot be filled in the delivered template:

This can be confirmed if you open the object in the migration modeler (LTMOM), nothing in the source structure:


And nothing in the structure mapping:

But don’t be afraid, we are at home, remember target structures are actually structures of BAPI BAPI_CONTRACT_CREATE:

This simply means once we know how to call BAPI, we know how to call it from Migration Cockpit. But hold on, this may sound as a dumb question, but do you know how to create a contract actually?


Make BAPI work first

The following may be obvious, but the correct approach is not to go and fill randomly your structure mappings and field mappings until it works. Just take a breath, go step by step

  1. Do you really know how to manually create a contract in (ME31K for instance)?
  2. Then, do you know how to create the exact same contract with BAPI?
  3. Then, and only then, go and map structure and fields accordingly in LTMOM


Create manually a sample contract with ME31K

First things first, start by creating a sample contract with scale conditions (as you would like Migration Cockpit to create them). You can use ME31K or Fiori app, as you wish.

In my case, I want my contract to contain price conditions with scales.

Try not to make it too simple, put at least 2 items, different values, etc.


Try to create the same contract with BAPI

Now that we have a sample contract, our goal is to be able to programmatically reach the same document. We are really lucky, as this BAPI is not just a lonely “Create” function, but contains method like “GetDetails”.

I will not go through a long explanation of what is exactly a BAPI, but you may know you can see it (the real object which holds this function) with SWO1:

Or with transaction BAPI:

Or even simpler, in object list of the function group:

Method display, actually BAPI_CONTRACT_GETDETAIL is a great helper function in our case as it will speed up our analysis: a call to BAPI_CONTRACT_GETDETAIL with our sample contract number as argument will reveal a lot of the expected input parameters for scales in BAPI_CONTRACT_CREATE.

Call it in SE37:

And output structures and values reflect more or less the expected input parameters:

In my case, my sample contract contains 2 items and both price conditions have 3 steps. I will save you time by summarizing my analysis steps, but I have inferred that the important fields to be populated in input parameters are:

Scale types, to be provided in ITEM_CONDITION

And of course, the scales themselves

Then, I create a variant in SE37 that I can execute in a test sequence with BAPI_TRANSACTION_COMMIT: my BAPI analysis is complete, I know for sure the required fields to manage scale conditions in a contract. I can set the relevant mapping in LTMOM.

Define mappings in Migration Cockpit Modeler

I repeat it again and again, you must be sure of your BAPI parameter before you do any mapping in LTMC. Start by adapting source structures by adding scales under item structure (it is a copy-paste of  BAPIMEOUTITEMSCALEQUAN)

Next, map the required target structures:

Finally, map the required fields of ITEM_COND_VALIDI:


And for scales (quantity):


You may have noticed 2 custom rules:

  • INIT_LINE_NO : this resets global variable g_scale_item to 1
  • INCREMENT_LINE_NO : this increments global variable g_scale_item

g_scale_item is a global variable (you can use the same way as you use to do in LSMW) which will be used to set value in ITEM_COND_SCALE-LINE_NO automatically.

Once all changes are done, generate function group.

Debug your migration cockpit object

If you have reached this step, you know by heart your required BAPI parameters for BAPI_CONTRACT_CREATE: this is going to be the final step, all previous mappings operations which you have set up will be applied in the generated functions.

All these mappings are the less “visible” parts of the cockpit (but you can still debug it if required). To ensure you get to BAPI_CONTRACT_CREATE with all parameters filled as expected, set an external breakpoint in it, and check all parameters are filled correctly. If not, fix your mapping, retry, etc.



I hope this explanation is clear enough and will help you in extending SAP-delivered migration templates to meet your requirements. Remember LTMOM is not a monolithic tool, the logic of data creation remains outside, in BAPI function (or any other function like the one for customer/supplier). Once you know how to create with a BAPI call, you are in a safe place.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Basis Basis
      Basis Basis

      Great post! Thank you very much for sharing this.

      One question though, at the target structures what are the rules you are defining for the ITEM_COND_SCALE?

      I have tried the same approach and when loading one contract with more than one line items and scales for one or more line items, I get an error at the first step of the LTMC that the "Quantity scale for items contains records that do not exist at a higher level in the hierarchy", whereas the file is absolutely consistent.

      Any clues?

      Thank you in advance,


      Author's profile photo Kimveasna Pen
      Kimveasna Pen
      Blog Post Author

      Hello Maria,

      I can only guess an explanation:

      • have you defined keys between structures and sub-structures?
      • check that keys of your scale lines refer to existing contract lines and item lines (that is, each record in scale tab must have all its predecessors (header tab > item tab) in the same file


      Author's profile photo Stratos Kyriazopoulos
      Stratos Kyriazopoulos

      Hello Pen,

      Also thank you for the post, working also succesfully,,

      One question: Can you please share the attributes of the field: S_EKPO-UNIT (not clear in EKPO), that you are using in the structure S_EKPO?

      The reason is that data type definition is required, in order to have succesful results in T10_ITEM_CONDITION mapping.

      Thank you in advance,


      Author's profile photo Panagiotis Anastasopoulos
      Panagiotis Anastasopoulos

      Very helpful article, thank you for posting and analyzing.