Simplify SAP R/3 development with Excel VBA/VB RFC  
Home> UserExit>MWMTO008



User Exits for TO Processing
Using this customer exit you can influence the storage type search of a material during stock removal.

General information about transfer order processing

Transfer order processing and confirmation in the WM system are divided into the following programs:

  1. SAPML03T Screens, transactions
  2. SAPLL03A Item creation (TO core)
  3. SAPLL03B Function modules for external purposes
  4. SAPLL03T Update tasks

These four programs work together as follows:

SAPML03T contains all the transfer order processing screens. All related transactions are initiated using screens from this program. All corresponding data is read, checked and recorded here (transportation requirements in transfer order: transportation requirements, transfer order: confirmation, etc.)

Actual creation or confirmation of items occurs via function modules in SAPLL03A , where the transfer orders are first created and recorded internally as the putaway and picking strategies and several checks are run. Changes in storage location, storage unit or stock that may arise from individual transfer order items are simulated in internal tables.
Item creation and confirmation occurs in two steps. First, the item is generated internally and all checks are carried out. Then, the internal tables are updated via a second function module and the transfer order items are added internally. You can view this two-step process by running transfer order creation in the foreground (screen SAPML03T 102). First, the system generates the transfer order item, then issues a warning. If entries are made on the screen, the system regenerates the transfer order item (including all checks) and the previous one is discarded. The internal tables are updated after the warning disappears.
The confirmation process follows a similar procedure.

User action 'post' in SAPML03T is carried out after an item is created or confirmed, which in turn calls up function module SAPLL03A , which then activates the update function modules in SAPLL03T. These function modules are normally processed asynchronously (supplement IN UPDATE TASK), but can also occur synchronously (see below). All changes in storage location, storage unit, stock, transportation requirements or transfer orders are made in these function modules.

SAPLL03B contains function modules for creating and confirming transfer orders which can be used instead of transactions. First, the normal screen run of the parameters transmitted is reviewed. Reading, checking and recording of the data and part of the flow logic occurs via external performs in SAPML03T and in a common data area, to avoid redundant code. Item creation and confirmation takes place in function modules found in SAPLL03A.
Function modules L_TO_CREATE_TR and L_TO_CREATE_DN, for example, are used in collective processing in the SAP standard system. Updating occurs synchronously in this case.

Transactions in SAPLL03A and SAPML03T

Some checks within the transfer order creation and confirmation processes depend on the transaction concerned. This transaction (field VORGA) is placed at the disposal of all user exits so that the system can react as required for the transaction involved.

Relevant values:

  1. "TB" Transfer order for transfer requirement
  2. "LF" Transfer order for delivery note
  3. "TL" Transfer complete storage unit

Homogeneous storage units can also be transferred explicitly. In this case, the value of the field is LTAP-HOMVE = 'X'.

  1. "IV" Clear inventory
  2. "U1" Create first item for posting change
  3. "U2" Create second item for posting change
  4. "QB" Confirm storage unit for stock removal from SU-managed block storage area

Within the SU-managed block storage ares, the item type (POSTY) of a TO item is of interest. It is set when the source data is determined and can have the following values:

  1. " " Normal transfer order item
  2. "1" Quant-neutral stock removal that requires verification of storage units during the confirmation process
  3. "2" Storage unit verified during confirmation

Items with item type "1" are deleted as soon as confirmation is complete.

How to call up the customer exit, important requirements

The customer exit takes place on the preparation screen for stock removal, before the first item is created. The search sequence according to the storage type indicator and the standard parameters are proposed and can be changed. Also, it is possible to propose work items for creating transfer orders and, in this way, to implement a type of stock removal strategy across all storage types.
Only A or S messages can be sent.

Parameters and options

The customer exit in the program is FB EXIT_SAPML03T_003. To fill it with data, you must create include ZXLTOU14 and activate the customer exit using Transaction CMOD.
The following parameters are available:

Import parameters

  1. I_LTAK the respective transfer order header from which, for example, reference documents such as the TR number are derived.
  2. I_LTAP Transfer order item

You can obtain further information on filled fields in I_LTAK and I_LTAP from the interface documentation of the function module L_TO_PREPARE_ITEM_INT.

  1. I_MLVS Material master
  2. I_MGEF Hazardous material master
  3. I_T333 Movement type with which the TO is created
  4. I_T340D Warehouse number control
  5. I_VORGA Procedure within TO processing
  6. I_AUSML Total quantity to be removed from stock in base unit of measure. This quantity is relevant if active ingredient processing is active (I_LTAP-WIRME is set to its initial value).
  7. I_AUSME Total quantity to be removed from stock in alternative unit of measure. This quantity is relevant if active ingredient processing is not active ((I_LTAP-WIRME is not set to its initial value).

Changing parameters

  1. C_LGTY0 Source storage type (0)
  2. C_LGTY1 Source storage type (1)
  3. C_LGTY2 Source storage type (2)
  4. C_LGTY3 Source storage type (3)
  5. C_LGTY4 Source storage type (4)
  6. C_LGTY5 Source storage type (5)
  7. C_LGTY6 Source storage type (6)
  8. C_LGTY7 Source storage type (7)
  9. C_LGTY8 Source storage type (8)
  10. C_CONTI Continue search in spite of work items
  11. C_LGTY9 Source storage type (9)

Table parameters

  1. T_LTAPA Table of workitems for stock removal

There are no export parameters. The C parameters as well as table T_LTAPA are passed on by reference and can be changed directly. The units of measure and the conversion factors can be obtained from I_LTAP if active ingredient processing is not active. If active ingredient processing is used, the conversion factors for the batch must be used. With some work items it is important that the required quantity be filled in the base unit of measure as well as the alternative unit of measure (fields T_LTAPA-ANFML and T_LTAPA-ANFME). The fields T_LTAPA-XTAPS and T_LTAPA-TAPOS must have the initial value. The total for all work items must not exceed the quantity to be removed (I_AUSML).

It is important to watch out if the table T_LTAPA is filled and the total of these work items does not match the entire quantity to be removed from stock (I_AUSML). During posting or when the system moves on to the next material, the system in this case only converts the items from T_LTAPA into transfer order items. Any remaining quantity can only be processed by a stock removal in the foreground or background through the creation of TO items

You can influence this system behavior by changing the parameter C_CONTI. If you set this parameter to "X", the system will always try to process any remaining quantity through the creation of TO items. If you set the parameter to "Y", the system will not attempt to create further items, even if transfer orders are created through function modules.

Information on the status of transfer order processing

Using the function module L_TO_CREATE_GET_INFO you can obtain information on the current status of transfer order processing. In addition to Table TAP with the transfer order items already created, you can use the following tables: PSPERR, LSPERR, QSPERR and SSPERR. These tables contain the storage bins, storage units and quants affected by the transfer order. However, the contents of the more important fields do not match the status in the database. Instead, they appear as if the transfer order items created up to now have been posted. The update of the item currently being posted is not included in the table.

If, for example, a bin is read in the user exit, we recommend that you have the system first check in Table PSPERR and then, only if data access is unsuccessful, to read the database. If this is not possible (for example, the bin is read by the index for empty bins), a bin that has been read should still be compared with Table PSPERR.

The only exception to this rule is a quant affected by blocking logic B. In this case, QSPERR has the status that would exist on the basis of the current transfer order. Changes that arise from parallel transfer orders are only partially included. If, for example, transfer orders 1 and 2 (in this sequence) access the same quant and the respective items have already been created internally, QSPERR contains the stock of transfer order 1 minus the current item and for transfer order 2 the stock is minus both items. Therefore, to have the current stock in each case, the database stocks must be compared with the global blocking table (blocking object ELLQUAY via function module "ENQUEUE_READ" read and evaluate). Whether or not this exact stock reading is required should be decided in each individual case.

The following example of a stock removal via user exit may be of help in making this decision:

Bin stock database: 10 pieces
TO 1 removes 5 pcs and first creates the item internally
TO 2 wants to have 10 pcs removed from stock.

The user exit also decides on this bin. The quant is not in the internal table because no internal item yet exists. Irrespective of whether the user exit proposes the bin with a stock of 5 pcs or 10 pcs, transfer order 2 (providing there is a positive stock balance) would at most take 5 pieces and would try to supply the remaining 5 pieces by means of a further item. Within the user exit, the correct stock is not important for the stock removal to be "correct". It is only important if it affects a decision, that is, if the user exit proposes another bin because only 5 pieces could be removed from the first bin.

Table IBDBATCH is available for you to create your own stock removal strategy. This table is important for batch-neutral documents if you want your own stock removal strategy to be influenced by the standard batch search function.

All the above tables are predefined for the user exit. If the system is to access one of these tables within the user exit, the current version must be called up via the function module L_TO_CREATE_GET_INFO. The following example shows you how to call up Tables PSPERR, QSPERR and TAP. The other two tables are not of importance because there is no SU management involved:


The table parameters must always be specified; only the marked tables (with "X") are copied.

Table IBDBATCH can only be called up by user exits from SAPLL03A. Otherwise the content is undefined.

  • EXIT_SAPML03T_003: Storage Type Search for Stock Removal