SAP ABAP 用户出口(User Exits)

如果标准 SAP 提取器不提供预期数据或所需功能,例如在授权或时间检查中,则在提取中使用用户出口(User Exits)。用户出口通常用于销售和分销(SD)模块。SAP 在销售、运输、运输和计费领域提供了许多出口。当标准 SAP 无法满足所有要求时,用户出口可以进行一些更改。

为了能够访问每个销售区域中可用的出口,请使用以下路径:IMG → Sales and Distribution → System Modifications → User Exits

例如,如果要在 Sales Document Processing 销售文档处理(合同、报价单或销售订单)中找到用户出口,请遵循上述路径,继续展开节点 Sales → User Exits。单击图标文档查看 Sales Document Processing 中可用的所有用户出口。

编号用户出口 & 描述
1

USEREXIT_FIELD_MODIFICATION

用于修改屏幕属性。

2

USEREXIT_SAVE_DOCUMENT

在用户点击 Save 时帮助执行操作。

3

USEREXIT_SAVE_DOCUMENT_PREPARE

检查输入字段、在字段中输入任何值或向用户显示弹出窗口以及确认文档非常有用。

4

USEREXIT_MOVE_FIELD_TO_VBAK

当用户标题更改移动到标题工作区时使用。

5

USEREXIT_MOVE_FIELD_TO_VBAP

当用户项更改移动到 SAP 项工作区时使用。

用户出口的用途与客户出口相同,但它们仅适用于 SD 模块。出口被实现为对功能模块的调用。用户出口是对 SAP 标准程序的修改。

实例

  1. REPORT ZUSEREXIT1.
  2. TABLES:
  3. TSTC, TSTCT,
  4. TADIR, TRDIR, TFDIR, ENLFDIR,
  5. MODSAPT, MODACT.
  6. DATA:
  7. JTAB LIKE TADIR OCCURS 0 WITH HEADER LINE,
  8. field1(30),
  9. v_devclass LIKE TADIR-devclass.
  10. PARAMETERS:
  11. P_TCODE LIKE TSTC-tcode OBLIGATORY.
  12. SELECT SINGLE *
  13. FROM TSTC
  14. WHERE tcode EQ P_TCODE.
  15. IF SY-SUBRC EQ 0.
  16. SELECT SINGLE *
  17. FROM TADIR
  18. WHERE pgmid = 'R3TR' AND
  19. object = 'PROG' AND
  20. obj_name = TSTC-pgmna.
  21. MOVE TADIR-devclass TO v_devclass.
  22. IF SY-SUBRC NE 0.
  23. SELECT SINGLE *
  24. FROM TRDIR
  25. WHERE name = TSTC-pgmna.
  26. IF TRDIR-subc EQ 'F'.
  27. SELECT SINGLE *
  28. FROM TFDIR
  29. WHERE pname = TSTC-pgmna.
  30. SELECT SINGLE *
  31. FROM ENLFDIR
  32. WHERE funcname = TFDIR-funcname.
  33. SELECT SINGLE *
  34. FROM TADIR
  35. WHERE pgmid = 'R3TR' AND
  36. object = 'FUGR' AND
  37. obj_name EQ ENLFDIR-area.
  38. MOVE TADIR-devclass TO v_devclass.
  39. ENDIF.
  40. ENDIF.
  41. SELECT *
  42. FROM TADIR
  43. INTO TABLE JTAB
  44. WHERE pgmid = 'R3TR' AND
  45. object = 'SMOD' AND
  46. devclass = v_devclass.
  47. SELECT SINGLE *
  48. FROM TSTCT
  49. WHERE sprsl EQ SY-LANGU AND
  50. tcode EQ P_TCODE.
  51. FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
  52. WRITE:/(19) 'Transaction Code - ',
  53. 20(20) P_TCODE,
  54. 45(50) TSTCT-ttext.
  55. SKIP.
  56. IF NOT JTAB[] IS INITIAL.
  57. WRITE:/(95) SY-ULINE.
  58. FORMAT COLOR COL_HEADING INTENSIFIED ON.
  59. WRITE:/1 SY-VLINE,
  60. 2 'Exit Name',
  61. 21 SY-VLINE ,
  62. 22 'Description',
  63. 95 SY-VLINE.
  64. WRITE:/(95) SY-ULINE.
  65. LOOP AT JTAB.
  66. SELECT SINGLE * FROM MODSAPT
  67. WHERE sprsl = SY-LANGU AND
  68. name = JTAB-obj_name.
  69. FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
  70. WRITE:/1 SY-VLINE,
  71. 2 JTAB-obj_name HOTSPOT ON,
  72. 21 SY-VLINE ,
  73. 22 MODSAPT-modtext,
  74. 95 SY-VLINE.
  75. ENDLOOP.
  76. WRITE:/(95) SY-ULINE.
  77. DESCRIBE TABLE JTAB.
  78. SKIP.
  79. FORMAT COLOR COL_TOTAL INTENSIFIED ON.
  80. WRITE:/ 'No of Exits:' , SY-TFILL.
  81. ELSE.
  82. FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
  83. WRITE:/(95) 'User Exit doesn’t exist'.
  84. ENDIF.
  85. ELSE.
  86. FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
  87. WRITE:/(95) 'Transaction Code Does Not Exist'.
  88. ENDIF.
  89. AT LINE-SELECTION.
  90. GET CURSOR FIELD field1.
  91. CHECK field1(4) EQ 'JTAB'.
  92. SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
  93. CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.

处理时,输入事务代码 ME01,然后按 F8(执行)按钮。以上代码生成以下结果: