Your issue spans all three configuration areas. Let me address each systematically:
1. Document Versioning Rules:
Your version rules configuration is incomplete. Here’s what needs to be checked and fixed:
Transaction: SPRO → Document Management → Control Data → Define Version Rules
Required settings for your version rule:
- Version Creation: Automatic on check-in ✓ (you have this)
- Copy Relationships: Active ✓ (you verified this)
- Relationship Types to Copy: This is likely your problem
The “Copy Relationships” flag is global, but you must specify WHICH relationship types to copy. Check table DRAW_REL_TYPES:
- DRW (Drawing to Part): Must be included
- BOM (BOM to Document): Must be included
- ASS (Assembly relationship): Must be included
If these specific relationship types aren’t in your version rule’s copy configuration, they won’t transfer to new versions.
Verification query:
SELECT * FROM DRAD
WHERE DOKNR = 'Drawing-12345'
AND DOKVR = '02'
If this returns no rows, relationships weren’t copied.
2. Check-in Process Triggers:
The check-in process has multiple trigger points where linking can fail:
Standard check-in flow (CV01N):
- Document version created
- File uploaded to content server
- Relationships copied from previous version
- BOM references updated (if configured)
- Commit database changes
Your error “Target document not found” at step 3 indicates the relationship copy is looking for a document that doesn’t exist yet in the context where the copy logic runs.
Common causes:
- Custom BAdI implementation commits too early
- Relationship copy runs before document is fully created
- Document number range issues causing temporary document IDs
Check transaction SWEL (Business Event Log) to see the sequence of events during check-in. Look for event CHANGED_DOCUMENT and verify the timing of relationship processing.
3. BAdI/User Exit Logic:
This is your root cause. You likely have custom code interfering with standard processing.
Check these BAdI implementations (transaction SE18):
- BADI_DMS_CHECKIN: Custom check-in logic
- BADI_DOCUMENT_MAIN01: Document change enhancements
- CV_DOCUMENT_CHG_BEFORE_SAVE: Pre-save modifications
Look for this pattern in your custom code:
METHOD if_ex_badi_dms_checkin~before_checkin.
" Custom logic here
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING wait = 'X'.
" Problem: Commits before relationship copy!
ENDMETHOD.
If you find early COMMIT WORK or BAPI_TRANSACTION_COMMIT calls, that’s breaking the transaction boundary. The relationship copy logic expects to run in the same database transaction as document creation.
Solution Implementation:
Fix the BAdI logic:
METHOD if_ex_badi_dms_checkin~after_checkin.
" Move custom logic to AFTER_CHECKIN instead
" This runs after relationship copy completes
" If you must commit, do it properly:
CALL FUNCTION 'CV_DOCUMENT_LINK_UPDATE'
EXPORTING
iv_doknr = iv_document_number
iv_dokvr = iv_document_version
iv_copy_links = 'X'.
" Now safe to commit
COMMIT WORK AND WAIT.
ENDMETHOD.
For BOM reference updates, implement automatic synchronization:
" Create a custom program to run after check-in
SELECT * FROM STPO
WHERE IDNRK = @lv_old_drawing_number
INTO TABLE @DATA(lt_bom_items).
LOOP AT lt_bom_items INTO DATA(ls_bom_item).
ls_bom_item-idnrk = lv_new_drawing_number.
MODIFY STPO FROM ls_bom_item.
ENDLOOP.
Complete Fix Checklist:
- Verify version rule includes all relationship types (DRAD, DRAT tables)
- Review custom BAdI code for early commits
- Move custom logic from BEFORE_CHECKIN to AFTER_CHECKIN
- Implement explicit relationship copy call if needed
- Add BOM synchronization logic (separate program or BAdI)
- Test with transaction CV01N and verify in DC10
Testing Procedure:
- Enable database trace (ST05) during check-in
- Check in a new CAD version
- Review trace for COMMIT WORK timing
- Verify DRAD table updated with new version relationships
- Check STPO table for BOM reference updates
The issue is definitely in your BAdI logic prematurely committing changes. Once you move custom code to the correct trigger point and ensure relationship copying completes before commit, the linking will work correctly.