DATA
:
BEGIN
OF wa_mchb
,
atnam LIKE cabn -atnam , "特征名称
atbez LIKE cabnt -atbez , "特征描述
atwrt LIKE cawn -atwrt , "特性值
END OF wa_mchb .
DATA : it_data LIKE wa_mchb OCCURS 0 WITH HEADER LINE . "定义内表存放特性值
*取物料组特性
DATA : lt_class TYPE TABLE OF sclass . "里面放着物料主数据t-cod是MM03里分类下的分配表
DATA : lt_objectdata TYPE TABLE OF clobjdat . "里面放着物料主数据t-cod是MM03里分类下的物料特性表
DATA : ls_objectdata TYPE clobjdat . " 物料特性结构
DATA : lf_object LIKE ausp -objek . " 一个对象的变量:就是把物料编号增加前导零到18位赋给 lf_object
DATA : BEGIN OF wa_data ,
matnr LIKE mara -matnr ,
END OF wa_data .
DATA :it_data1 LIKE TABLE OF wa_data WITH HEADER LINE .
* 清空工作区和内表准备存放物料特性
CLEAR : lf_object ,ls_objectdata .
REFRESH : lt_class ,lt_objectdata .
* 调用刚才定义的增加前导零,把物料编号增加前导零到18位赋给 lf_object
"zm_convert_alpha_input2: gs_pd-matnr.
SELECT SINGLE matnr INTO it_data1 -matnr FROM mara . " WHERE matnr = '61-05-000185-2'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = it_data1 -matnr
IMPORTING
output = it_data1 -matnr .
lf_object = it_data1 -matnr .
* 调用该函数取出物料特性值
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
classtype = '023'
object = lf_object
TABLES
t_class = lt_class
t_objectdata = lt_objectdata
EXCEPTIONS
no_classification = 1
no_classtypes = 2
invalid_class_type = 3
OTHERS = 4 .
IF sy -subrc <> 0 .
ENDIF .
*循环内表里把特性值名称、特性值、特性值描述取出来放在自定义的内表it_data里.
LOOP AT lt_objectdata INTO ls_objectdata .
it_data -atnam = ls_objectdata -atnam . "特性名称
it_data -atwrt = ls_objectdata -ausp1 . "特性值
IF it_data -atwrt = '?' .
it_data -atwrt = '' .
ENDIF .
it_data -atbez = ls_objectdata -smbez . "特征描述
APPEND it_data .
CLEAR : ls_objectdata .
ENDLOOP .
SORT it_data BY atnam atbez . "排序批次特性表
DELETE ADJACENT DUPLICATES FROM it_data COMPARING ALL FIELDS . "删除重复的数据。
LOOP AT it_data .
WRITE : it_data -atnam , ', ' , it_data -atwrt .
ULINE .
ENDLOOP .
atnam LIKE cabn -atnam , "特征名称
atbez LIKE cabnt -atbez , "特征描述
atwrt LIKE cawn -atwrt , "特性值
END OF wa_mchb .
DATA : it_data LIKE wa_mchb OCCURS 0 WITH HEADER LINE . "定义内表存放特性值
*取物料组特性
DATA : lt_class TYPE TABLE OF sclass . "里面放着物料主数据t-cod是MM03里分类下的分配表
DATA : lt_objectdata TYPE TABLE OF clobjdat . "里面放着物料主数据t-cod是MM03里分类下的物料特性表
DATA : ls_objectdata TYPE clobjdat . " 物料特性结构
DATA : lf_object LIKE ausp -objek . " 一个对象的变量:就是把物料编号增加前导零到18位赋给 lf_object
DATA : BEGIN OF wa_data ,
matnr LIKE mara -matnr ,
END OF wa_data .
DATA :it_data1 LIKE TABLE OF wa_data WITH HEADER LINE .
* 清空工作区和内表准备存放物料特性
CLEAR : lf_object ,ls_objectdata .
REFRESH : lt_class ,lt_objectdata .
* 调用刚才定义的增加前导零,把物料编号增加前导零到18位赋给 lf_object
"zm_convert_alpha_input2: gs_pd-matnr.
SELECT SINGLE matnr INTO it_data1 -matnr FROM mara . " WHERE matnr = '61-05-000185-2'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = it_data1 -matnr
IMPORTING
output = it_data1 -matnr .
lf_object = it_data1 -matnr .
* 调用该函数取出物料特性值
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
classtype = '023'
object = lf_object
TABLES
t_class = lt_class
t_objectdata = lt_objectdata
EXCEPTIONS
no_classification = 1
no_classtypes = 2
invalid_class_type = 3
OTHERS = 4 .
IF sy -subrc <> 0 .
ENDIF .
*循环内表里把特性值名称、特性值、特性值描述取出来放在自定义的内表it_data里.
LOOP AT lt_objectdata INTO ls_objectdata .
it_data -atnam = ls_objectdata -atnam . "特性名称
it_data -atwrt = ls_objectdata -ausp1 . "特性值
IF it_data -atwrt = '?' .
it_data -atwrt = '' .
ENDIF .
it_data -atbez = ls_objectdata -smbez . "特征描述
APPEND it_data .
CLEAR : ls_objectdata .
ENDLOOP .
SORT it_data BY atnam atbez . "排序批次特性表
DELETE ADJACENT DUPLICATES FROM it_data COMPARING ALL FIELDS . "删除重复的数据。
LOOP AT it_data .
WRITE : it_data -atnam , ', ' , it_data -atwrt .
ULINE .
ENDLOOP .