如何在VL03N外向交货项目删除时触发自定义警告弹窗?
Nice work tracking down the code path to SAPMV50A -> MV50AF0F_FUNKTION_AUSFUEHREN (right after the FUNKTION_AUSFUEHREN call on line 65)! This is absolutely a valid spot to add your custom logic, and here’s how to do it properly without modifying standard SAP code directly:
Is this location suitable?
Absolutely. The CALL FUNCTION 'FUNKTION_AUSFUEHREN' triggers the standard delete workflow—including the initial "Delete selected item(s)? Y/N" prompt. By adding your code right after this call, you ensure your custom warning runs only after the user has already confirmed the standard popup, which aligns perfectly with your requirement.
Recommended approach: Implicit Enhancement
Since we’re working with standard SAP code, implicit enhancements are the safest and most upgrade-friendly method. Here’s a step-by-step breakdown:
- Open the function module
MV50AF0F_FUNKTION_AUSFUEHRENvia SE37 or SE80. - Scroll to the line immediately following the
CALL FUNCTION 'FUNKTION_AUSFUEHREN'statement. - Right-click on the empty line below it, select Enhance Operations > Insert Implicit Enhancement, and create a new enhancement spot if you don’t have one already.
- In the enhancement block, add your custom warning logic. For example:
" Check if we're in VL03N and processing a delete action IF sy-tcode = 'VL03N' AND gv_vorgang = 'L'. " Adjust flag to match your delete action marker " Show custom warning popup CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING titlebar = 'Custom Deletion Warning' text_question = 'Are you certain you want to delete this delivery item?' button_1 = 'Proceed' button_2 = 'Cancel' IMPORTING answer = lv_user_choice. " Handle user's response IF lv_user_choice = '2'. " User clicked Cancel " Inform user and abort deletion MESSAGE 'Deletion has been canceled.' TYPE 'I'. " Reset relevant flags to stop the delete process gv_loeschen = abap_false. ENDIF. ENDIF. - Activate your enhancement using the enhancement builder (SE24) or the activate button in the editor.
Critical Things to Keep in Mind
- Target the right action: Make sure your condition checks specifically for the delete operation in VL03N—you don’t want this popup appearing for other actions (like changing items) or in other delivery transactions.
- Test edge cases: Verify that if the user cancels the standard popup, your custom one doesn’t appear. Also confirm that canceling your popup actually stops the deletion from happening.
- Avoid conflicts: Check if there are any existing enhancements in this function module before adding your code—you don’t want to overwrite or clash with other customizations.
内容的提问来源于stack exchange,提问作者Duhac

