需求:根据Sales Order 中交货工厂和库存地点的组合不同,设置Schedule line category
解决方法:
(1)在工厂的库存地点中,维护地址中的SerchTerm2为CP;
(2)查找ScheduleLine中,查找User Exit;
在SD标准UserExit - User Exits In Sales Document Processing
因为修改的内容最后写到VBEP表中,所以选用
- USEREXIT_MOVE_FIELD_TO_VBEP
- Use this user exit to assign values to new fields at the level of the sales document schedule lines.
The user exit is called up at the end of the FORM routine VBEP_FUELLEN.
(3)表关系:
TWLAD:Determination of Address from Plant and Storage
ADRC:Addresses (Business Address Services)
1.先查找TWLAD表中的ADRNR(Address number)
2.然后用Address number 到ADRC表中查找到地址信息记录;
(4)代码:
IF VBAK-AUART = 'FPOR' and ( VBAP-WERKS = '1220' or VBAP-WERKS = '1240' or VBAP-WERKS = '1315' ) and VBAP-LGORT <> '' .
SELECT count(*) from TWLAD
INNER JOIN ADRC ON TWLAD~ADRNR = ADRC~ADDRNUMBER
WHERE TWLAD~WERKS = VBAP-WERKS and TWLAD~LGORT = VBAP-LGORT and TWLAD~LFDNR = '001' and ADRC~SORT2 = 'CP' .
IF SY-SUBRC = 0 .
VBEP-ETTYP = 'CP' .
else.
VBEP-ETTYP = 'NP' .
ENDIF.
ENDIF.