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 标准程序的修改。实例
REPORT ZUSEREXIT1.
TABLES:
TSTC, TSTCT,
TADIR, TRDIR, TFDIR, ENLFDIR,
MODSAPT, MODACT.
DATA:
JTAB LIKE TADIR OCCURS 0 WITH HEADER LINE,
field1(30),
v_devclass LIKE TADIR-devclass.
PARAMETERS:
P_TCODE LIKE TSTC-tcode OBLIGATORY.
SELECT SINGLE *
FROM TSTC
WHERE tcode EQ P_TCODE.
IF SY-SUBRC EQ 0.
SELECT SINGLE *
FROM TADIR
WHERE pgmid = 'R3TR' AND
object = 'PROG' AND
obj_name = TSTC-pgmna.
MOVE TADIR-devclass TO v_devclass.
IF SY-SUBRC NE 0.
SELECT SINGLE *
FROM TRDIR
WHERE name = TSTC-pgmna.
IF TRDIR-subc EQ 'F'.
SELECT SINGLE *
FROM TFDIR
WHERE pname = TSTC-pgmna.
SELECT SINGLE *
FROM ENLFDIR
WHERE funcname = TFDIR-funcname.
SELECT SINGLE *
FROM TADIR
WHERE pgmid = 'R3TR' AND
object = 'FUGR' AND
obj_name EQ ENLFDIR-area.
MOVE TADIR-devclass TO v_devclass.
ENDIF.
ENDIF.
SELECT *
FROM TADIR
INTO TABLE JTAB
WHERE pgmid = 'R3TR' AND
object = 'SMOD' AND
devclass = v_devclass.
SELECT SINGLE *
FROM TSTCT
WHERE sprsl EQ SY-LANGU AND
tcode EQ P_TCODE.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
WRITE:/(19) 'Transaction Code - ',
20(20) P_TCODE,
45(50) TSTCT-ttext.
SKIP.
IF NOT JTAB[] IS INITIAL.
WRITE:/(95) SY-ULINE.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 SY-VLINE,
2 'Exit Name',
21 SY-VLINE ,
22 'Description',
95 SY-VLINE.
WRITE:/(95) SY-ULINE.
LOOP AT JTAB.
SELECT SINGLE * FROM MODSAPT
WHERE sprsl = SY-LANGU AND
name = JTAB-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WRITE:/1 SY-VLINE,
2 JTAB-obj_name HOTSPOT ON,
21 SY-VLINE ,
22 MODSAPT-modtext,
95 SY-VLINE.
ENDLOOP.
WRITE:/(95) SY-ULINE.
DESCRIBE TABLE JTAB.
SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ 'No of Exits:' , SY-TFILL.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'User Exit doesn’t exist'.
ENDIF.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'Transaction Code Does Not Exist'.
ENDIF.
AT LINE-SELECTION.
GET CURSOR FIELD field1.
CHECK field1(4) EQ 'JTAB'.
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.
处理时,输入事务代码 ME01,然后按 F8(执行)按钮。以上代码生成以下结果: