I’ve dealt with this exact problem multiple times. The issue is almost certainly in your BAdI filter configuration and enhancement implementation approach. Let me walk through all three focus areas systematically:
BAdI Filter Configuration:
The filter you’ve defined is incomplete. For document management BAdIs in SAP PLM 2020, you need a compound filter that includes both MIME type and document type. The system evaluates filters using AND logic, so a partial match causes the implementation to be skipped:
* Correct filter definition in SE19
FILTER_TYPE = 'MIME_TYPE'
FILTER_VALUE = 'application/pdf;image/tiff'
FILTER_TYPE2 = 'DOKAR'
FILTER_VALUE2 = 'DRW;CAD;DOC'
Document MIME Type Handling:
The MIME type comparison in the BAdI framework is case-sensitive and uses exact string matching. SAP stores MIME types in lowercase internally, but the archiving API sometimes passes them in mixed case. Your implementation needs defensive MIME type checking:
METHOD if_ex_doc_archive_badi~before_archive.
DATA: lv_mime TYPE string.
lv_mime = to_lower( iv_mime_type ).
IF lv_mime = 'application/pdf' OR lv_mime = 'image/tiff'.
" Add compliance metadata
ev_classification = 'REGULATORY_DOC'.
ENDIF.
ENDMETHOD.
Enhancement Implementation:
The critical issue is that DMS_ARCHIVE_ENHANCEMENT is for content repository archiving, not CV01N archiving objects. You need to implement the correct BAdI definition. For CV01N-based archiving, use DOCUMENT_ARCHIVE01 with the ARCHIVE_PROCESS enhancement spot. This is the proper hook point for document archiving workflows.
Additionally, verify in transaction SE18 that your implementation is assigned to the correct enhancement spot. The implementation class must be explicitly activated (not just the BAdI definition). In SE19, use the “Where-Used” function to confirm the enhancement spot is actually called by the archiving program RSARCH01 or your custom archiving variant.
One more critical point: if you’re using a custom archiving object (defined in AOBJ transaction), you need to register the BAdI in the archiving object’s preprocessing exit. Standard SAP archiving objects have predefined enhancement points, but custom objects require explicit BAdI registration in the ABAP archiving program.
Finally, enable BAdI trace in transaction SADT to see if the filter evaluation is even being attempted. This will show you exactly where the filter matching fails. In most cases I’ve debugged, the issue was either wrong enhancement spot selection or missing compound filter criteria. Fix these three areas and your compliance metadata injection should work correctly.