Copy Control
SD / O2Cintermediate

SD Copy Control Part 3: Copy Requirements and Data Transfer Routines (VOFM)

Key takeaway

How copying requirements and data transfer routines work: standard routines (001, 301, 004, 051, 151…), creating custom routines (900+) in VOFM, activation and transport, typical use cases, and the rules for writing safe routines that run for every document.

Explanation

📌 KEY POINTS
✅ Copying requirement = ABAP routine that decides whether copying is allowed (sets sy-subrc/bp_subrc ≠ 0 to stop with a message).

✅ Data transfer routine = ABAP routine that moves fields from source to target structures (e.g. VBAK from quotation).

✅ Custom routines use numbers 900–999, are created and activated in VOFM, then assigned in copy control.

✅ Routines run for every copy — they must be fast, side-effect free and never COMMIT or call dialogs.

⚠️ Modifying a standard routine instead of copying it to 9xx changes behavior for every copy control entry using it.

━━━━━━━━━━━━━━━━━━━━
▶ WHERE WE ARE

Part 2 covered the copy control fields. Now the routines behind them.

━━━━━━━━━━━━━━━━━━━━
▶ 1. COPYING REQUIREMENTS

  • Header: e.g. 001 (same sold-to, sales area…), 002 (not blocked…).
  • Item: e.g. 301 (item not rejected, status), 303 (always relevant).
  • Billing: 004 delivery-related item, 002 order-related header.

━━━━━━━━━━━━━━━━━━━━
▶ 2. DATA TRANSFER ROUTINES

  • Header VBAK 051, business data VBKD 001/002, partners, item VBAP 151/102.
  • Used to set or clear fields in the target (e.g. keep customer PO, clear delivery block).

━━━━━━━━━━━━━━━━━━━━
▶ 3. CREATING A CUSTOM ROUTINE

  • VOFM > Requirements > Copying requirements (or Data transfer) > new number 9xx.
  • Copy logic from the closest standard routine, add your check.
  • Activate (Edit > Activate); assign in VTAA/VTLA/VTF*.
  • Transport routine and activation.

━━━━━━━━━━━━━━━━━━━━
▶ 4. SAFE ROUTINE RULES

  • Only read and set the relevant structures; set error via sy-subrc/bp_subrc with a message.
  • No database updates, no COMMIT, no pop-ups.
  • Keep SELECTs minimal (buffered tables).

━━━━━━━━━━━━━━━━━━━━
▶ 5. TYPICAL USE CASES

  • Block copying if the reference has no customer PO number, or if source and target payer differ.
  • Copy customer PO number from quotation to order.
  • Stop billing if a user status is not "Approved".

━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP

  1. Identify the standard routine used today.
  2. Copy it to 9xx in VOFM and add logic.
  3. Activate and assign in copy control.
  4. Test positive and negative cases; transport.

✅ CHECKPOINT: copying a quotation without customer PO number into the order type is rejected with your message.

Code example

ABAP Code
* ===== STEP 1: copying requirement 901 (header) - reference must carry a customer PO =====* VOFM > Requirements > Copying requirements > 901 "Reference with customer PO"FORM bedingung_pruefen_901. * ===== STEP 2: keep the standard header checks of routine 001 =====  PERFORM bedingung_pruefen_001.  CHECK bp_subrc = 0. * ===== STEP 3: CVBKD = business data of the SOURCE document =====  IF cvbkd-bstkd IS INITIAL.*   ===== STEP 4: reject copying - return code for the copy control framework =====*   issue the message through the program's standard message handling*   (see how routine 001 raises its messages and follow the same pattern)    bp_subrc = 4.  ENDIF.ENDFORM. * ===== STEP 5: activate in VOFM (Edit > Activate), assign in VTAA header level (e.g. QT → ZOR) =====* Note: source structures are prefixed C (CVBAK, CVBAP, CVBKD); verify the available* structures and message pattern in your release before implementing.

Real project scenario

A client needed to prevent release orders against a contract when the release order's payer differed from the contract payer, because rebate settlement depended on it. A developer modified standard routine 001 directly, which then applied to every copy control entry in the system, blocking unrelated scenarios such as returns with an alternative payer. The change was reverted; a custom routine 901 was created by copying 001 plus the payer check and assigned only to the CQ → OR entry in VTAA.

Common mistakes

  • Modifying standard routines instead of copying to 9xx.
  • Forgetting to activate the routine after creating it.
  • Database updates or COMMIT inside routines.
  • Expensive SELECTs in routines that run per item.
  • Not transporting activation or assignment.

Best practices

  • Copy standard routines to 900–999 and assign only where needed.
  • Keep routines small, read-only and fast.
  • Document each routine's purpose and assignments.
  • Test positive and negative cases.
  • Review custom routines in each upgrade.

Interview angle

Questions: "Difference between copying requirement and data transfer routine?", "How do you create a custom routine?", "What must a routine never do?"
Strong answer: requirement checks whether copying is allowed (sets return code with message), data transfer routine moves data; custom routines 900–999 in VOFM, activated and assigned in copy control, transported; routines must be fast and side-effect free, never COMMIT or dialog, and standard routines are copied, not modified.

Practice this lesson

Quick check

1. What does the 'Copying requirement' (VOFM requirement) assigned at header or item level in copy control primarily determine?

2. What is the difference between a copying requirement and a data transfer routine?

3. You need an extra check before a quotation can be copied into an order. What is the correct way to implement it?

Interview questions

1. How does the incompletion procedure for an Inquiry document type ensure downstream data quality when it is later copied to a quotation or sales order?

Answer it in your own words first, then compare.

2. A customer requests a quotation for a configurable make-to-order material, and later this quotation is copied into a sales order. What copy control settings must be verified to ensure the configuration data and pricing carry over correctly?

Answer it in your own words first, then compare.

Practice more with Interview AI →

Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.

More lessons in this topic

Interview questions on this topic

Related SAP topics