1, 物料特性查看
MM03 在classification视图中,可以找到物料的特性数据
详细信息如下图:可以看到 class type:001, class:Z_PACK_INSTR以及class下面的一个特性GRP_OPENING_DIRECTION和对应的值TR.
2, 代码实现
通过CLAF_CLASSIFICATION_OF_OBJECTS取得物料特性,例子代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
DATA: l_object TYPE kssk-objek, l_class TYPE klah-class, l_matty TYPE atwrt, lit_class TYPE TABLE OF sclass, lit_objda TYPE TABLE OF clobjdat, lwa_objda TYPE clobjdat. * 物料, l_object = '000000000000100524'. "material number * class l_class = 'Z_PACK_INSTR'. "lwa_alloc-class. CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS' EXPORTING class = l_class * CLASSTEXT = 'X' classtype = '001' "Class type * CLINT = 0 * FEATURES = 'X' * LANGUAGE = SY-LANGU object = l_object * OBJECTTABLE = ' ' * KEY_DATE = SY-DATUM INITIAL_CHARACT = '' no_value_descript = 'X' * CHANGE_SERVICE_CLF = 'X' * INHERITED_CHAR = ' ' * CHANGE_NUMBER = ' ' TABLES t_class = lit_class t_objectdata = lit_objda * I_SEL_CHARACTERISTIC = * T_NO_AUTH_CHARACT = EXCEPTIONS no_classification = 1 no_classtypes = 2 invalid_class_type = 3 OTHERS = 4. IF sy-subrc = 0. * 读取特性值 READ TABLE lit_objda INTO lwa_objda WITH KEY atnam = 'GRP_OPENING_DIRECTION'. IF sy-subrc = 0. l_matty = lwa_objda-ausp1. EXIT. ENDIF. ENDIF. |
3, 测试
debug界面中可以看到特性值TR已经被取到
当然,取得物料特性的方法还有很多种,也可以通过BAPI_OBJCL_GETDETAIL这个BAPI或者直接读取数据库表.
需要注意的是:输入函数参数initial_charact为'X'的场合下,如果特性值为空,会输出一个'?' 问号.
以上.
作者辛苦了,祝网站越来越好
2017-07-10 5:56 上午多谢
2017-08-31 8:10 上午