MSC1N、MSC2N、MSC3N
MCH1、MCHA、AUSP、MCH*开头的几个
1、创建批次
BAPI:BAPI_BATCH_CREATE
BAPI:BAPI_BATCH_CHANGE
BAPI:BAPI_BATCH_DELETE
BAPI:BAPI_BATCH_GET_DETAIL
BAPI: BAPI_OBJCL_GETCLASSES
OBJECTKEY_IMP:物料号 带前导0
OBJECTTABLE_IMP MARA
CLASSTYPE_IMP 022
CALL FUNCTION 'VB_BATCH_2_CLASS_OBJECT'
EXPORTING
I_MATNR = LS_DATA-MATNR
I_CHARG = LS_DATA-CHARG
I_WERKS = LS_DATA-WERKS
IMPORTING
E_OBJEK = LV_OBJEK
E_OBTAB = LV_OBTAB
E_KLART = LV_KLART
E_CLASS = LV_CLASS.
DATA:LV_OBJEK TYPE CUOBN,
LV_OBTAB TYPE TABELLE,
LV_KLART TYPE KLASSENART,
LV_CLASS TYPE KLASSE_D.
SELECT SINGLE CUOBJ_BM FROM MCH1 INTO @DATA(LV_BM)
WHERE MATNR EQ XXX
AND CHARG EQ XXX.
DATA:LV_OBJECTNAME LIKE BAPI1003_KEY-OBJECT,
LV_OBJECTTABLE LIKE BAPI1003_KEY-OBJECTTABLE,
LV_CLASSTYPE LIKE BAPI1003_KEY-CLASSTYPE,
RETURN LIKE TABLE OF BAPIRET2 WITH HEADER LINE.
CALL FUNCTION 'BAPI_OBJCL_GET_OBJECT_OF_KEY'
EXPORTING
CLOBJECTKEYIN = LV_BM
IMPORTING
OBJECTNAME = LV_OBJECTNAME
OBJECTTABLE = LV_OBJECTTABLE
CLASSTYPE = LV_CLASSTYPE
TABLES
RETURN = RETURN.
DATA:I_OBJEK TYPE BAPI1003_KEY-OBJECT,
I_OBTAB TYPE BAPI1003_KEY-OBJECTTABLE,
I_KLART TYPE BAPI1003_KEY-CLASSTYPE,
I_CLASS TYPE BAPI1003_KEY-CLASSNUM.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
OBJECTKEY = I_OBJEK
OBJECTTABLE = I_OBTAB
CLASSNUM = I_CLASS
CLASSTYPE = I_KLART
UNVALUATED_CHARS = 'X'
TABLES
ALLOCVALUESNUM = CLASSVALUATIONSNUM
ALLOCVALUESCHAR = CLASSVALUATIONSCHAR
ALLOCVALUESCURR = CLASSVALUATIONSCURR
RETURN = RETURN.
BAPI:BAPI_OBJCL_CHANGE
5、批量修改批次特性值
BAPI:BAPI_BATCH_SAVE_REPLICA
根据分类别查KLAH表,KLAH-CLASS = 'XXX',获取内部等级号 CLINT
根据KLAH-CLINT = KSML-CLINT取得分类下所有的内部特性号 IMERK
根据KSML-IMERK = CABN-ATINN取得特性详细信息,CABNT是特性描述
VC_I_GET_CONFIGURATION
BAPI_OBJCL_GETDETAIL
200 特性通过数据库取值
SELECT
objek "将分类的对象的键值
atinn "内部特性
atwrt "特性值
atflv "内部浮点自
klart "类别种类
INTO TABLE gt_ausp
FROM ausp
INNER JOIN cabn
ON cabn~atinn = ausp~atinn
WHERE objek = '000000000101004001'
AND klart = '200'
AND atnam = 'WG0078'. " 内部特性
SORT gt_ausp BY objek atinn.
READ TABLE gt_ausp INTO gs_ausp
WITH KEY objek = '000000000101004001'
atinn = 'WG0078'
BINARY SEARCH.
IF sy-subrc = 0.
CALL FUNCTION 'MC_FLTP_CHAR'
EXPORTING
fc_a_fld = gs_ausp-atflv
IMPORTING
fc_r_fld = gs_alv-wg0078.
ENDIF.
DATA: lv_matnr TYPE matnr,
lv_object TYPE objnum,
ls_alloclist TYPE bapi1003_alloc_list,
lt_alloclist TYPE TABLE OF bapi1003_alloc_list,
ls_return TYPE bapiret2,
lt_return TYPE TABLE OF bapiret2,
ls_allocvaluesnum TYPE bapi1003_alloc_values_num,
lt_allocvaluesnum TYPE TABLE OF bapi1003_alloc_values_num,
ls_allocvalueschar TYPE bapi1003_alloc_values_char,
lt_allocvalueschar TYPE TABLE OF bapi1003_alloc_values_char,
ls_allocvaluescurr TYPE bapi1003_alloc_values_curr,
lt_allocvaluescurr TYPE TABLE OF bapi1003_alloc_values_curr,
ls_retur2 TYPE bapiret2,
lt_retur2 TYPE TABLE OF bapiret2.
lv_object = lv_matnr. " 物料号带前置零
CALL FUNCTION 'BAPI_OBJCL_GETCLASSES' " 可以通过 cl03 查看
EXPORTING
objectkey_imp = lv_object " 物料号
objecttable_imp = 'MARA'
classtype_imp = '200'
TABLES
alloclist = lt_alloclist
return = lt_return.
READ TABLE lt_alloclist INTO ls_alloclist INDEX 1.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL' " 也可以用 claf_classification_of_objects 取值
EXPORTING
objectkey = lv_object
objecttable = 'MARA'
classnum = ls_alloclist-classnum
classtype = '200'
TABLES
allocvaluesnum = lt_allocvaluesnum
allocvalueschar = lt_allocvalueschar
allocvaluescurr = lt_allocvaluescurr
return = lt_retur2.
l_objectkeynew = l_matnr.
l_objecttablenew = 'MARA'.
l_classnumnew = ls_tmp-class.
l_classtypenew = ls_tmp-klart.
CLEAR: lt_numout,lt_charout,lt_returnout.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = l_objectkeynew
objecttable = l_objecttablenew
classnum = l_classnumnew
classtype = l_classtypenew
TABLES
allocvaluesnum = lt_numout
allocvalueschar = lt_charout
allocvaluescurr = lt_currout
return = lt_returnout.
CLEAR ls_return.
READ TABLE lt_returnout INTO ls_return WITH KEY type = 'E'.
IF sy-subrc <> 0.
CLEAR lt_returnout.
CALL FUNCTION 'BAPI_OBJCL_DELETE' "删除已有分类
EXPORTING
objectkey = l_objectkeynew
objecttable = l_objecttablenew
classnum = l_classnumnew
classtype = l_classtypenew
* CHANGENUMBER =
* KEYDATE = SY-DATUM
TABLES
return = lt_returnout.
CLEAR ls_return.
READ TABLE lt_returnout INTO ls_return WITH KEY type = 'E'.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE e000 WITH '删除物料' l_objectkeynew '已有分类失败'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
ENDIF.
LOOP AT gt_upload INTO gs_upload WHERE matnr = ls_tmp-matnr AND klart =
ls_tmp-klart AND class = ls_tmp-class.
CLEAR: ls_num, ls_char,l_atinn,l_atfor.
CALL FUNCTION 'CONVERSION_EXIT_ATINN_INPUT'
EXPORTING
input = gs_upload-atnam
IMPORTING
output = l_atinn.
* SELECT SINGLE atfor FROM cabn INTO l_atfor WHERE atinn = l_atinn.
READ TABLE lt_cabn INTO ls_cabn WITH KEY atinn = l_atinn.
IF sy-subrc <> 0.
MESSAGE e000 WITH '特性没有维护,请先维护特性!'.
ENDIF.
l_atfor = ls_cabn-atfor.
IF gs_upload-atwrt IS NOT INITIAL.
IF l_atfor = 'CHAR'.
ls_char-charact = gs_upload-atnam.
ls_char-charact_descr = gs_upload-atbez.
ls_char-value_char = gs_upload-atwrt.
APPEND ls_char TO lt_char.
ELSEIF l_atfor = 'NUM'.
ls_num-charact = gs_upload-atnam.
ls_num-charact_descr = gs_upload-atbez.
ls_num-value_from = gs_upload-atwrt.
APPEND ls_num TO lt_num.
ENDIF.
ENDIF.
ENDLOOP.
CALL FUNCTION 'BAPI_OBJCL_CREATE'
EXPORTING
objectkeynew = l_objectkeynew
objecttablenew = l_objecttablenew
classnumnew = l_classnumnew
classtypenew = l_classtypenew
status = '1'
* standardclass =
* changenumber =
* KEYDATE = SY-DATUM
* NO_DEFAULT_VALUES = ' '
* IMPORTING
* CLASSIF_STATUS =
tables
allocvaluesnum = lt_num
allocvalueschar = lt_char
* ALLOCVALUESCURR =
return = lt_return.
CLEAR: l_type,l_info, ls_return.
READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
CLEAR l_info.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = ls_return-id
msgnr = ls_return-number
msgv1 = ls_return-message_v1
msgv2 = ls_return-message_v2
msgv3 = ls_return-message_v3
msgv4 = ls_return-message_v4
IMPORTING
message_text_output = l_info.
l_type = 'E'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
l_type = 'S'.
l_info = '物料主数据分类视图创建特性成功'.
ENDIF.
SELECT
mch1~matnr,
mch1~charg,
cabn~atnam,
ausp~atwrt,
ausp~atflv
FROM mch1
INNER JOIN ausp
ON ausp~objek = mch1~cuobj_bm
INNER JOIN cabn
ON cabn~atinn = ausp~atinn
WHERE mch1~matnr = '000000000101004001'
AND mch1~charg = '152200110'.
SELECT
vbap~vbeln,
vbap~posnr,
cabn~atinn,"内部特性
cabn~atnam,"特性名称
ibsymbol~atwrt,"特性值
ibsymbol~atflv,
ibsymbol~atflb
INTO TABLE @DATA(gt_data)
FROM vbap
INNER JOIN ibin
ON ibin~instance = vbap~cuobj
AND ibin~valto = '99991231235959'
INNER JOIN ibinvalues
ON ibinvalues~in_recno = ibin~in_recno
INNER JOIN ibsymbol
ON ibsymbol~symbol_id = ibinvalues~symbol_id
INNER JOIN cabn
ON cabn~atinn = ibsymbol~atinn
WHERE vbap~vbeln = '2000046612'
AND vbap~posnr = '000010'.
SELECT SINGLE
cuobj
matnr
INTO (l_cuobj,l_matnr)
FROM vbap
WHERE vbeln = w_mseg-kdauf
AND posnr = w_mseg-kdpos.
DATA: t_configuration LIKE STANDARD TABLE OF conf_out WITH HEADER LINE.
IF l_cuobj IS NOT INITIAL.
CALL FUNCTION 'VC_I_GET_CONFIGURATION'
EXPORTING
instance = l_cuobj
language = '1'
iv_max_massprocessing = 10
TABLES
configuration = t_configuration.
ENDIF.